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

Fix catch-all exception handlers #1435

Merged
merged 12 commits into from
May 7, 2024
Merged

Fix catch-all exception handlers #1435

merged 12 commits into from
May 7, 2024

Conversation

sim642
Copy link
Member

@sim642 sim642 commented Apr 26, 2024

This is an attempt to fix #1420 (comment).

@michael-schwarz You may want to try out of this helps with #1420.

@sim642 sim642 added cleanup Refactoring, clean-up bug labels Apr 26, 2024
@sim642 sim642 added this to the v2.4.0 milestone Apr 26, 2024
@sim642 sim642 self-assigned this Apr 26, 2024
@michael-schwarz
Copy link
Member

Thanks, I'll give it a try today. I just wasted 19h of CPU time on our server because of this issue again.

@michael-schwarz
Copy link
Member

It worked at least on my machine, I'll give it another try on the server once it's done running benchmarks.

@sim642 sim642 marked this pull request as ready for review April 29, 2024 08:51
@sim642
Copy link
Member Author

sim642 commented Apr 29, 2024

I made my best to avoid catching Timeout.Timeout (for #1420) and Sys.Break (for #1221) anywhere, among some other exceptions that really shouldn't be swallowed like that.
Whether it remedies both issues is yet to be seen, but this is an improvement either way.

I also made the timeout timer more robust: it will keep resending the signal every second. So even if execution happens to be inside a catch-all exception handler at any point (in the future), then there will be more opportunities for the special exception. Currently, if it's swallowed once, it will never come again.

@sim642 sim642 removed their assignment Apr 29, 2024
@michael-schwarz
Copy link
Member

The state as of a35dc82 does not fix the issue on our server. I'll try again with the new commits added.

Copy link
Member

@michael-schwarz michael-schwarz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It now works also on the server, the timeout is respected.

try Addr.type_of (choose xs)
with (* WTF? Returns TVoid when it is unknown and stuff??? *)
| _ -> voidType
Addr.type_of (choose xs) (* TODO: what if ambiguous type? what if chooses NullPtr but also contains Addr with proper type? *)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we sure it's safe to remove the void fallback for Not_found?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just moved it to two call sites in a35dc82, where this otherwise lead to crashes on regression tests. And even those are kind of dubious: why should we ever try to get the type of an empty points-to set?
Even so, the worst that can now happen is that there's an uncaught Not_found (if that ever happens), whose stacktrace is easy to see and the fallback can easily be added to such call sites. I wouldn't do that en masse because it itself would cover up problems where we try to operate on empty points-to set when they should've already been handled.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am more worried about the Addr.type_of throwing then providing an empty points-to-set.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is the empty points-to set being provided now?

It was the old behavior which returned the same result for type errors as it did for empty points-to sets, making the results indistinguishable.

Now it's up to the caller to handle whichever exception this raises if the caller provides incorrectly constructed addresses.

Making every invalid offset appear to have void type is hardly the right thing.

Copy link
Member

@michael-schwarz michael-schwarz May 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making every invalid offset appear to have void type is hardly the right thing

I think it may be crucial for not crashing on some of our real-world programs. I think we should do a run for those after merging this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I don't added call-site catching where it was needed for our test suite. If some Not_found or Type_of_error now slips through, it will be uncaught and crashes Goblint with a stacktrace, so it's quite easy to see which call of AD.type_of should have a fallback (or better decide what on the result).
So, yes, if they come up (on sv-benchmarks or our bench stuff), we can easily put in such specific catch.

@sim642 sim642 merged commit 88106e7 into master May 7, 2024
21 checks passed
@sim642 sim642 deleted the try-catch-all branch May 7, 2024 07:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug cleanup Refactoring, clean-up
Projects
None yet
Development

Successfully merging this pull request may close these issues.

dbg.timeout somtimes not respected
2 participants