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
Handle fatal error that has no backtrace #2607
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
0d5990a
handle low level error that has no backtrace
calvinxiao 1dad096
add force_shutdown_after in test case
calvinxiao 99d3fcb
skip test on windows for low level error
calvinxiao f1de8c0
remove extra space
calvinxiao c2a8067
remove two extra lines
calvinxiao 0428303
rename test method to lowlevel_error
calvinxiao File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -285,6 +285,25 @@ def test_force_shutdown_custom_error_message | |
assert_match(/{}\n$/, data) | ||
end | ||
|
||
def test_lowlevel_error_message | ||
skip_if :windows | ||
@server = Puma::Server.new @app, @events, {:force_shutdown_after => 2} | ||
|
||
server_run app: ->(env) do | ||
require 'json' | ||
|
||
# will raise fatal: machine stack overflow in critical region | ||
obj = {} | ||
obj['cycle'] = obj | ||
::JSON.dump(obj) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is not a reliable test for this issue because:
Maybe we can just test creating an exception and using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
end | ||
|
||
data = send_http_and_read "GET / HTTP/1.0\r\n\r\n" | ||
|
||
assert_match(/HTTP\/1.0 500 Internal Server Error/, data) | ||
assert (data.size > 0), "Expected response message to be not empty" | ||
end | ||
|
||
def test_force_shutdown_error_default | ||
@server = Puma::Server.new @app, @events, {:force_shutdown_after => 2} | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Style nitpick: in this case, the ternary doesn't make a lot of sense. Say
e.backtrace
isfalse
(i mean, it can't be, but say that it is): then we're going to callfalse.join("\n")
. What you really care about is the ability torespond_to?
thejoin
method, so you should check for that instead.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.
Current Ruby docs for
Exception#backtrace
state:'In the case no backtrace has been set, nil is returned'
That seems imply that the method always exists? We can't join
nil
...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.
that's why I said it's a style nitpick and not a correctness nitpick 😄 IMO anything passing the test in the ternary should work
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 guess we could check whether the backtrace returns an array?
Sometimes with stuff like this it may better to keep the scope to what Ruby docs state, so if the Ruby API changes, we might see it in tests? Believe it or not, I've seen things like that happen working with Ruby master and even OpenSSL. IOW, keep the test very narrow, and edges cases appear.
JFYI, I have no style... And, thanks for reviewing/merging.