https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59856

--- Comment #21 from Josh Triplett <josh at joshtriplett dot org> ---
(In reply to PaX Team from comment #20)
> (In reply to Josh Triplett from comment #13)
> > Note that in addition to complaining if *any* exit to the function doesn't
> > have the correct "out" value, you also need to complain if calls to
> > functions with the context attribute don't have the necessary "in" value. 
> 
> i implemented this now but it generates a warning on good_lock3,
> good_unlock2 and good_if3 (since there're paths where the same lock is taken
> twice before we reach the end of the function where we'd know that the lock
> count imbalance is fine). how should these cases be handled?

Sorry for the delayed response; I didn't see an email update for your previous
comment.

To answer your question: "in" is a minimum, not an exact value.  If a function
(or the __context__ statement) requires context (1,0), meaning that the
function call should occur with the lock held and the function drops the lock
before returning, then you should evaluate the body of the function itself as
though with those exact contexts, but allow calls to that function with any
context >= 1, and have the function return with the context decreased by one. 
So, you could also call the function with context 2, in which case that context
would become 1 after the call.

Sparse experimented with separate attributes/statements for an *exact* context
match (as in, the context must equal 1, not 1 or more, for use with
non-recursive locking), but those got reverted.

Reply via email to