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

Obtain backtraces automatically from segfaults #11530

Merged
merged 2 commits into from Jun 21, 2016
Merged

Conversation

@jdm
Copy link
Member

jdm commented May 31, 2016

This enables more meaningful output from observing hard crashes outside of GDB through the judicious use of a SIGSEGV signal handler.


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #9371 (github issue number if applicable).
  • There are tests for these changes OR

This change is Reviewable

@highfive
Copy link

highfive commented May 31, 2016

Heads up! This PR modifies the following files:

  • @KiChjang: components/script/dom/window.rs, components/script/dom/webidls/Window.webidl
@highfive
Copy link

highfive commented May 31, 2016

warning Warning warning

  • These commits include an empty title element, '<title></title>'. Consider adding appropriate metadata.
  • These commits modify unsafe code. Please review it carefully!
@jdm
Copy link
Member Author

jdm commented May 31, 2016

Sample output:

  ▶ CRASH [expected OK] /_mozilla/mozilla/sigsegv.html
  │
  │ Stack trace for thread "ScriptThread PipelineId { namespace_id: PipelineNamespaceId(0), index: PipelineIndex(0) }"
  │ frame #0  - 0x000000010b8c4bd8 - backtrace::backtrace::trace::h970e6004c9e40bad
  │ frame #1  - 0x000000010b8c4a8a - backtrace::capture::Backtrace::new::hcd7fdea4950c7315
  │ frame #2  - 0x000000010866a200 - servo::maybe_install_crash_handler::handler::h6fc2b810d1c9999e
  │ frame #3  - 0x00007fff932955a9 - _sigtramp
  │ frame #4  - 0x000000010a21b994 - _<script..dom..window..Window as script..dom..bindings..codegen..Bindings..WindowBinding..WindowMethods>::CrashHard::he8f60c25f43edc4c
  │ frame #5  - 0x000000010a21b940 - script::dom::bindings::codegen::Bindings::WindowBinding::crashHard::h3bbccc48c3723192
  │ frame #6  - 0x000000010a8dc0a0 - CallJitMethodOp
  │ frame #7  - 0x0000000109cf0744 - script::dom::bindings::utils::generic_call::hfcfa16d78984f863
  │ frame #8  - 0x0000000109cf18ab - script::dom::bindings::utils::generic_method::hebfbdf4166917173
  │ frame #9  - 0x000000010b2180f5 - 2js6InvokeEP9JSContextRKN2JS8CallArgsENS_14MaybeConstruct
  │ frame #10 - 0x000000010b22d6cc - _ZL9InterpretP9JSContextRN2js8RunStateE
  │ frame #11 - 0x000000010b2204dc - 2js9RunScriptEP9JSContextRNS_8RunState
  │ frame #12 - 0x000000010b2354c7 - _ZN2js13ExecuteKernelEP9JSContextN2JS6HandleIP8JSScriptEER8JSObjectRKNS2_5ValueENS_16AbstractFramePtrEPS9_
  │ frame #13 - 0x000000010b235611 - 2js7ExecuteEP9JSContextN2JS6HandleIP8JSScriptEER8JSObjectPNS2_5Value
  │ frame #14 - 0x000000010b124d6e - _ZL8EvaluateP9JSContextN2JS6HandleIP8JSObjectEENS2_IPN2js11StaticScopeEEERKNS1_22ReadOnlyCompileOptionsERNS1_18SourceBufferHolderENS1_13MutableHandleINS1_5ValueEEE
  │ frame #15 - 0x000000010b124f58 - 2JS8EvaluateEP9JSContextRKNS_22ReadOnlyCompileOptionsEPKDsmNS_13MutableHandleINS_5ValueEE
  │ frame #16 - 0x0000000109cd3f23 - _<&'a T as script..dom..window..ScriptHelpers>::evaluate_script_on_global_with_result::_$u7b$$u7b$closure$u7d$$u7d$::h344bec51f9686bb9
  │ frame #17 - 0x0000000109cd39e7 - profile_traits::time::profile::he0498d543cd9fcb4
  │ frame #18 - 0x0000000109cd3111 - _<&'a T as script..dom..window..ScriptHelpers>::evaluate_script_on_global_with_result::h76c867e78b236609
  │ frame #19 - 0x000000010a41c9b8 - script::dom::htmlscriptelement::HTMLScriptElement::execute::h6aceaef2a8bd24ff
  │ frame #20 - 0x000000010a5e424b - script::dom::htmlscriptelement::HTMLScriptElement::prepare::h8a8ad4abc361f2fc
  │ frame #21 - 0x000000010a67bbb3 - script::parse::html::_<impl html5ever..tree_builder..interface..TreeSink for script..dom..servohtmlparser..Sink>::complete_script::hcf96876fa35b76c2
  │ frame #22 - 0x000000010a66008c - _<html5ever..tree_builder..TreeBuilder<Handle, Sink> as html5ever..tree_builder..rules..TreeBuilderStep>::step::h6717b89d5c48abaf
  │ frame #23 - 0x000000010a645f14 - _<html5ever..tree_builder..TreeBuilder<Handle, Sink>>::process_to_completion::hb643491952eea50d
  │ frame #24 - 0x000000010a6417a8 - _<html5ever..tree_builder..TreeBuilder<Handle, Sink> as html5ever..tokenizer..interface..TokenSink>::process_token::hb002158b13c2b5f0
  │ frame #25 - 0x000000010a64097d - _<html5ever..tokenizer..Tokenizer<Sink>>::process_token::h96613b36c8bcd6eb
  │ frame #26 - 0x000000010a68f398 - _<html5ever..tokenizer..Tokenizer<Sink>>::emit_current_tag::hb29fcea57a66309d
  │ frame #27 - 0x000000010a68686a - _<html5ever..tokenizer..Tokenizer<Sink>>::step::h06d64f99ed4db43a
  │ frame #28 - 0x000000010a682a53 - _<html5ever..tokenizer..Tokenizer<Sink>>::run::he0653f58ce20f2f1
  │ frame #29 - 0x000000010a6a3724 - script::dom::servohtmlparser::ServoHTMLParser::do_parse_sync::hd9aec42c2a17c727
  │ frame #30 - 0x000000010a6a34bf - script::dom::servohtmlparser::ServoHTMLParser::parse_sync::_$u7b$$u7b$closure$u7d$$u7d$::hfbaedf513f5a8ad4
  │ frame #31 - 0x000000010a6a33c7 - profile_traits::time::profile::h7ccf70761736ec54
  │ frame #32 - 0x000000010a63bc62 - script::dom::servohtmlparser::ServoHTMLParser::parse_sync::hd41172b10d2d25e1
  │ frame #33 - 0x000000010a6a3f3a - script::dom::servohtmlparser::ServoHTMLParser::resume::h9fc81b1ff2c29337
  │ frame #34 - 0x000000010a418fe4 - script::parse::ParserRef::resume::hbcfccb5178c2f93a
  │ frame #35 - 0x0000000109c85ad0 - script::dom::document::Document::finish_load::h3df863ae9f5d7eae
  │ frame #36 - 0x000000010a5e0cac - _<script..dom..htmlscriptelement..ScriptContext as net_traits..AsyncResponseListener>::response_complete::h7048d1046cce3432
  │ frame #37 - 0x000000010b3b0f45 - net_traits::ResponseAction::process::h8ff59bc5372f3080
  │ frame #38 - 0x000000010a5e7a36 - _<script..network_listener..ListenerRunnable<T> as script..script_thread..Runnable>::handler::h2129057a83fbdef3
  │ frame #39 - 0x000000010a80c359 - script::script_thread::ScriptThread::handle_msg_from_script::h1d4b4e78177a8078
  │ frame #40 - 0x000000010a894031 - script::script_thread::ScriptThread::handle_msgs::_$u7b$$u7b$closure$u7d$$u7d$::h958c16cfb899fc99
  │ frame #41 - 0x000000010a893b90 - script::script_thread::ScriptThread::profile_event::h91c7349ede903acd
  │ frame #42 - 0x000000010a865165 - script::script_thread::ScriptThread::handle_msgs::h393260e1123f1499
  │ frame #43 - 0x000000010a809d4c - script::script_thread::ScriptThread::start::he4b751164e376840
  │ frame #44 - 0x000000010a809d04 - _<script..script_thread..ScriptThread as script_traits..ScriptThreadFactory>::create::_$u7b$$u7b$closure$u7d$$u7d$::_$u7b$$u7b$closure$u7d$$u7d$::h9c87a931d3b80558
  │ frame #45 - 0x000000010a809a51 - profile_traits::mem::ProfilerChan::run_with_memory_reporting::h2fe8a3d88c86e54e
  │ frame #46 - 0x000000010a7f6ca9 - _<script..script_thread..ScriptThread as script_traits..ScriptThreadFactory>::create::_$u7b$$u7b$closure$u7d$$u7d$::h8b8dd4aa0df81df3
  │ frame #47 - 0x000000010a7f5240 - util::thread::spawn_named_with_send_on_panic::_$u7b$$u7b$closure$u7d$$u7d$::hafc74d3f966159c1
  │ frame #48 - 0x000000010a7f4fb7 - _<std..panic..AssertUnwindSafe<F> as core..ops..FnOnce<()>>::call_once::hfb63df66f3d81cf6
  │ frame #49 - 0x000000010a7f4f0e - std::panicking::try::_$u7b$$u7b$closure$u7d$$u7d$::_$u7b$$u7b$closure$u7d$$u7d$::hbb8ea8ee0adef3b2
  │ frame #50 - 0x000000010a7f57e4 - std::panicking::try::call::h6a7fc8aaff82c76c
  │ frame #51 - 0x000000010bbc979b - __rust_try
  │ frame #52 - 0x000000010bbc9735 - __rust_maybe_catch_panic
  │ frame #53 - 0x000000010a7f4e5d - std::panicking::try::_$u7b$$u7b$closure$u7d$$u7d$::h9e2b42f121ff19b2
  │ frame #54 - 0x000000010a7f4d9f - _<std..thread..local..LocalKey<T>>::with::h02933ffed525eb57
  │ frame #55 - 0x000000010a7f4bcf - std::panicking::try::h3eafd724eaca9043
  │ frame #56 - 0x000000010a7f4aae - std::panic::catch_unwind::h5dd2eb86ccae815b
  │ frame #57 - 0x000000010a7f491e - std::thread::Builder::spawn::_$u7b$$u7b$closure$u7d$$u7d$::h7150e20070dde226
  │ frame #58 - 0x000000010a7f59c7 - _<F as alloc..boxed..FnBox<A>>::call_box::hd52b91ee13529093
  │ frame #59 - 0x000000010bbc5458 - std::sys::thread::Thread::new::thread_start::h6f266e069bf4ec2b
  │ frame #60 - 0x00007fff9170e898 - _pthread_body
  │ frame #61 - 0x00007fff9170e729 - _pthread_start
  └
@jdm
Copy link
Member Author

jdm commented May 31, 2016

@highfive highfive assigned metajack and unassigned wafflespeanut May 31, 2016
@jdm jdm force-pushed the jdm:sigsegv branch from 36a4c94 to 07f75b2 May 31, 2016
@highfive
Copy link

highfive commented May 31, 2016

New code was committed to pull request.

fn CrashHard(&self) {
let p: *mut u32 = ptr::null_mut();
unsafe {
*p = 0xdeadbeef

This comment has been minimized.

@KiChjang

KiChjang May 31, 2016

Member

My personal favourite is 0xCAFEBABE, but whatever.

@luser
Copy link
Contributor

luser commented May 31, 2016

FYI you can use rustc-demangle to demangle symbols: https://github.com/alexcrichton/rustc-demangle

@@ -659,6 +660,14 @@ impl WindowMethods for Window {
}

#[allow(unsafe_code)]
fn CrashHard(&self) {
let p: *mut u32 = ptr::null_mut();

This comment has been minimized.

@luser

luser May 31, 2016

Contributor

Did you sanity check that the optimizer doesn't do anything weird here? I don't know what LLVM does but in Breakpad's unit tests we had to jump through hoops to avoid GCC's optimizer optimizing away our crash function:
https://chromium.googlesource.com/breakpad/breakpad/+blame/master/src/client/linux/handler/exception_handler_unittest.cc#195

@Ms2ger
Copy link
Contributor

Ms2ger commented Jun 1, 2016

@bors-servo r-

sig claims to be GPL-3.0

@nox
Copy link
Member

nox commented Jun 1, 2016

Can you put that crashing method in TestBinding?

@metajack
Copy link
Contributor

metajack commented Jun 1, 2016

@jdm @Ms2ger sig is now dual MIT / Apache-2.0. Work can proceed.

@bors-servo
Copy link
Contributor

bors-servo commented Jun 2, 2016

The latest upstream changes (presumably #11114) made this pull request unmergeable. Please resolve the merge conflicts.

@jdm jdm force-pushed the jdm:sigsegv branch 3 times, most recently from 9cf42c1 to 539d1fe Jun 7, 2016
@jdm jdm removed the S-needs-rebase label Jun 7, 2016
@jdm
Copy link
Member Author

jdm commented Jun 7, 2016

All comments addressed. Rather than a null pointer dereference, I went with writing to a pointer into read-only memory.

@jdm jdm force-pushed the jdm:sigsegv branch from 539d1fe to 6b06690 Jun 7, 2016
@highfive
Copy link

highfive commented Jun 7, 2016

New code was committed to pull request.

@metajack
Copy link
Contributor

metajack commented Jun 9, 2016

Reviewed 3 of 3 files at r1, 6 of 6 files at r2, 7 of 7 files at r3, 6 of 6 files at r4, 10 of 10 files at r5, 6 of 6 files at r6, 8 of 8 files at r7, 6 of 6 files at r8.
Review status: all files reviewed at latest revision, 2 unresolved discussions.


Comments from Reviewable

@metajack
Copy link
Contributor

metajack commented Jun 9, 2016

@bors-servo
Copy link
Contributor

bors-servo commented Jun 9, 2016

📌 Commit 6b06690 has been approved by metajack

@bors-servo
Copy link
Contributor

bors-servo commented Jun 20, 2016

Testing commit 091557a with merge 51d5bd3...

bors-servo added a commit that referenced this pull request Jun 20, 2016
Obtain backtraces automatically from segfaults

<!-- Please describe your changes on the following line: -->
This enables more meaningful output from observing hard crashes outside of GDB through the judicious use of a SIGSEGV signal handler.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #9371 (github issue number if applicable).
- [X] There are tests for these changes OR

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11530)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Jun 20, 2016

💔 Test failed - android

jdm added 2 commits May 31, 2016
…the output of a segfault with a complicated backtrace; the actual automation doesn't help us except to verify that the crash continues to happen as excepted.
@jdm jdm force-pushed the jdm:sigsegv branch from 091557a to 99e436e Jun 20, 2016
@jdm
Copy link
Member Author

jdm commented Jun 20, 2016

@bors-servo: r=metajack

@bors-servo
Copy link
Contributor

bors-servo commented Jun 20, 2016

📌 Commit 99e436e has been approved by metajack

@bors-servo
Copy link
Contributor

bors-servo commented Jun 20, 2016

Testing commit 99e436e with merge ef9286b...

bors-servo added a commit that referenced this pull request Jun 20, 2016
Obtain backtraces automatically from segfaults

<!-- Please describe your changes on the following line: -->
This enables more meaningful output from observing hard crashes outside of GDB through the judicious use of a SIGSEGV signal handler.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #9371 (github issue number if applicable).
- [X] There are tests for these changes OR

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11530)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Jun 20, 2016

💔 Test failed - linux-rel

@cbrewster
Copy link
Member

cbrewster commented Jun 21, 2016

@bors-servo
Copy link
Contributor

bors-servo commented Jun 21, 2016

Testing commit 99e436e with merge 2c4c2d8...

bors-servo added a commit that referenced this pull request Jun 21, 2016
Obtain backtraces automatically from segfaults

<!-- Please describe your changes on the following line: -->
This enables more meaningful output from observing hard crashes outside of GDB through the judicious use of a SIGSEGV signal handler.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #9371 (github issue number if applicable).
- [X] There are tests for these changes OR

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11530)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Jun 21, 2016

@bors-servo bors-servo merged commit 99e436e into servo:master Jun 21, 2016
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
@bors-servo bors-servo mentioned this pull request Jun 21, 2016
4 of 4 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

You can’t perform that action at this time.