-
Notifications
You must be signed in to change notification settings - Fork 77
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
Fix longjmp crash on Uninitialized #1210
Conversation
longjmp(*buf_ptr, 1); // NO CRASH: problem?! | ||
} | ||
else { | ||
__goblint_check(1); // reachable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The crash on longjmp
is fixed but apparently this doesn't still become reachable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Returning top here doesn't make code that is otherwise unreachable reachable iirc... I think this is a fundamental limitation that I am not sure how to address best.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought a top jmpbuf would just jump back to every setjmp
without filtering by node/context, but apparently all we do is warn:
analyzer/src/framework/constraints.ml
Lines 1664 to 1666 in 5cc4811
let handle_target target = match target with | |
| JmpBufDomain.BufferEntryOrTop.AllTargets -> | |
M.warn ~category:Imprecise "Longjmp to potentially invalid target, as contents of buffer %a may be unknown! (imprecision due to heap?)" d_exp env |
Maybe we should have an option to do that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is a bit where one wants to propagate things to... Just up the call stack, assuming the invocation was not UB? Also down the callstack because someone might be trying to implement co-routines? Also to completely unrelated places?
The other problem is that quite often the local state propagated somewhere because of an unknown longjmp will not be suitable for incorporation by join, as it is incorporated into an unsuitable function. This might lead to a huge precision loss.
My idea would be to leave this as is, but make this type of warning one of the severe top-level warnings that is reported separately at the end of the analysis (in the sense of #1190 ).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is a bit where one wants to propagate things to... Just up the call stack, assuming the invocation was not UB? Also down the callstack because someone might be trying to implement co-routines? Also to completely unrelated places?
To the same places we normally do: in the same function and up the call stack. It could just be that all setjmp
s incorporate the unknown jump target instead of the same node and context check that normally happens. So unknown jump buffer would mean "all jumpbuffers that we normally could jump to".
The other problem is that quite often the local state propagated somewhere because of an unknown longjmp will not be suitable for incorporation by join, as it is incorporated into an unsuitable function. This might lead to a huge precision loss.
Of course it would be very imprecise, but I'm not sure if it'd cause anything incompatible per se. Ambiguous longjmps to multiple possible targets should be similar. The compatibility is ensured by each upwards propagation of the jumps doing the appropriate return
s and combine_env
s.
My idea would be to leave this as is, but make this type of warning one of the severe top-level warnings that is reported separately at the end of the analysis (in the sense of #1190 ).
I added that, so let's leave it at that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To the same places we normally do: in the same function and up the call stack.
In this case, the clean solution would be to warn and then replace the top set of possible targets with the set of legal jumptargets (which we have at hand anyway), which indeed seems reasonable and also prevents any issues with propagation to ill-suited locations.
On concrat/pigz the longjmp analysis crashes because it takes a
jmp_buf
out from apthread_getspecific
which currently gives top results.This PR replaces the crash with a message and a top value.