Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect unmatched lock/unlock #388

Open
hernanponcedeleon opened this issue Jan 29, 2023 · 4 comments
Open

Detect unmatched lock/unlock #388

hernanponcedeleon opened this issue Jan 29, 2023 · 4 comments

Comments

@hernanponcedeleon
Copy link
Owner

The following litmus test has a trivial deadlock

C lock

{
}


P0(int *a, int *b, spinlock_t *l)
{
	spin_lock(l);
	WRITE_ONCE(*a, 1);
}

P1(int *a, int *b, spinlock_t *l)
{
	spin_lock(l);
	WRITE_ONCE(*b, 1);
}

exists (a=1 /\ b=1)

Right now we cannot detect this (not even with the liveness property). There is a proposal to flag such situations. LKMM has several such sanity checks (normally in the *.bell file) which we normally implemented internally. It would make sense to add a check for this situation.

@ThomasHaas
Copy link
Collaborator

This is roughly the same issue as #275 .
I don't think you can do much about this. This program has not a single execution because in litmus tests we "assume" that spin locks succeed.

@hernanponcedeleon
Copy link
Owner Author

I was thinking we could flag executions where the write of a lock was last in co-order. However, you are right, that won't work because due to the assumption locks succeed, the formula is trivially unsat (i.e. no execution at all).

We could try to detect the problem statically, but then there might be situations with involved control-flow that might make the analysis more involved for not measurable benefit.

@ThomasHaas
Copy link
Collaborator

The question is if such a detection is really worthwhile for litmus tests.
Or have you seen real code that relies on spin locks as a primitive?

@hernanponcedeleon
Copy link
Owner Author

rt_mutex makes uses of spinlock (see e.g. here) and I use the primitive to speed up verification. However, I don't expected to encounter trivial deadlock as the one in the test in real kernel code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants