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

Top level exception handler #8735

Merged
merged 2 commits into from
Feb 12, 2020

Conversation

waj
Copy link
Member

@waj waj commented Feb 3, 2020

There are many issues where the reported error contains a Failed to raise an exception: END_OF_STACK. Many times this is because an error happens outside the begin/rescue around __crystal_main and it ends hiding the real source of the issue. (#8387, #6249, #7810, among others)

I added this exception handler a the top level of Crystal.main to dump the unhandled exception. I tried to be as conservative as possible, executing the least amount of Crystal's std code.

@waj waj added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib:runtime labels Feb 3, 2020
@RX14 RX14 added this to the 0.33.0 milestone Feb 7, 2020
@RX14
Copy link
Contributor

RX14 commented Feb 7, 2020

Can we merge this for 0.33.0?

@bcardiff
Copy link
Member

There is a need to a dprintf replacement for Windows. We were thinking of adding a method in the Crystal namespace that will mimic a dprintf in Windows. That's the thing that is missing to avoid breaking the build.

@waj waj force-pushed the fix/main-exception-handler branch from 76b5153 to 3c12033 Compare February 11, 2020 22:17
@@ -96,6 +98,26 @@ module Crystal
def self.main_user_code(argc : Int32, argv : UInt8**)
LibCrystalMain.__crystal_main(argc, argv)
end

protected def self.handle_exceptions
begin
Copy link
Contributor

Choose a reason for hiding this comment

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

begin ... end pair is redundant here.

@bcardiff bcardiff merged commit 8abfebd into crystal-lang:master Feb 12, 2020
@waj waj deleted the fix/main-exception-handler branch February 12, 2020 19:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib:runtime
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants