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

Exception#backtrace? raises an IndexError on macOS #5678

Closed
marksiemers opened this issue Feb 3, 2018 · 5 comments
Closed

Exception#backtrace? raises an IndexError on macOS #5678

marksiemers opened this issue Feb 3, 2018 · 5 comments

Comments

@marksiemers
Copy link
Contributor

I have not yet been able to successfully reduce the code. The relevant code is:

      begin
        message = @ex.inspect_with_backtrace
      rescue ex : IndexError
        # ERROR: Any of these will cause another IndexError (at least on macOS)
        # ex.inspect_with_backtrace # or @ex.inspect_with_backtrace
        # ex.backtrace? # or @ex.backtrace?
        message = @ex.message
      end

To reproduce, using macOS, you can follow these steps:

  1. git clone git@github.com:amberframework/amber.git
  2. git fetch && git checkout ms/fix-internal_server_error-error
  3. Uncomment the line at src/amber/controller/error.cr:35 (or line 36): https://github.com/amberframework/amber/pull/625/files#diff-fefe72c37ea251ccaec8417bffb49e8cR35
  4. Run crystal spec spec/amber/router/pipe/error_spec.cr:15

With the line commented out, the tests pass:

$ crystal spec spec/amber/router/pipe/error_spec.cr:15
.....

Finished in 128.61 milliseconds
5 examples, 0 failures, 0 errors, 0 pending

With the line uncommented, we get the Index out of bounds error.

$ crystal spec spec/amber/router/pipe/error_spec.cr:15
....E

Failures:

  1) Amber::Pipe::Error returns status code 500 for all other exceptions

       Index out of bounds
$ crystal -v
Crystal 0.24.1 (2018-01-27)
LLVM: 5.0.1
Default target: x86_64-apple-macosx

$ sw_vers
ProductName:	Mac OS X
ProductVersion:	10.13.3
BuildVersion:	17D47

From what I've looked at in the crystal code base, it may have to do with CallStack. There is a difference in darwin vs linux in that file:

{% if flag?(:darwin) %}

What led me there is:
https://github.com/crystal-lang/crystal/blob/v0.24.1/src/exception.cr#L35

And then here:

private def decode_backtrace

@ysbaddaden
Copy link
Contributor

Does it still happen with crystal master? I fixed a very similar issue recently.

@marksiemers
Copy link
Contributor Author

I'm checking now. Is this the relevant commit: 048f77e

@asterite
Copy link
Member

asterite commented Feb 3, 2018

Probably duplicate of #5224

@marksiemers
Copy link
Contributor Author

I'm running into an unrelated issue when trying to test against master, may just need to update some dependencies (pg).

It is a JSON::Type error - that was updated to JSON::Any, correct?

@marksiemers
Copy link
Contributor Author

This is fixed in master.

Sorry it took me a while to get setup - there are a handful of breaking changes that affect crystal-pg and amber that I had to work through.

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

No branches or pull requests

3 participants