mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Auto merge of #11530 - jdm:sigsegv, r=metajack
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 -->
This commit is contained in:
commit
2c4c2d8779
10 changed files with 83 additions and 1 deletions
|
@ -571,6 +571,15 @@ impl TestBindingMethods for TestBinding {
|
|||
fn FuncControlledAttributeEnabled(&self) -> bool { false }
|
||||
fn FuncControlledMethodDisabled(&self) {}
|
||||
fn FuncControlledMethodEnabled(&self) {}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
fn CrashHard(&self) {
|
||||
static READ_ONLY_VALUE: i32 = 0;
|
||||
unsafe {
|
||||
let p: *mut u32 = &READ_ONLY_VALUE as *const _ as *mut _;
|
||||
ptr::write_volatile(p, 0xbaadc0de);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl TestBinding {
|
||||
|
|
|
@ -456,3 +456,8 @@ interface TestBinding {
|
|||
[Func="TestBinding::condition_satisfied"]
|
||||
const unsigned short funcControlledConstEnabled = 0;
|
||||
};
|
||||
|
||||
partial interface TestBinding {
|
||||
[Pref="dom.testable_crash.enabled"]
|
||||
void crashHard();
|
||||
};
|
||||
|
|
7
components/servo/Cargo.lock
generated
7
components/servo/Cargo.lock
generated
|
@ -3,6 +3,7 @@ name = "servo"
|
|||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"android_glue 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"backtrace 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"browserhtml 0.1.7 (git+https://github.com/browserhtml/browserhtml?branch=gh-pages)",
|
||||
"canvas 0.0.1",
|
||||
"canvas_traits 0.0.1",
|
||||
|
@ -37,6 +38,7 @@ dependencies = [
|
|||
"script_layout_interface 0.0.1",
|
||||
"script_tests 0.0.1",
|
||||
"script_traits 0.0.1",
|
||||
"sig 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"style 0.0.1",
|
||||
"style_tests 0.0.1",
|
||||
"url 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -2159,6 +2161,11 @@ dependencies = [
|
|||
"winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sig"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "simd"
|
||||
version = "0.1.0"
|
||||
|
|
|
@ -75,6 +75,10 @@ euclid = "0.6.4"
|
|||
libc = "0.2"
|
||||
url = "1.0.0"
|
||||
|
||||
[target.'cfg(not(target_os = "android"))'.dependencies]
|
||||
sig = "0.1"
|
||||
backtrace = "0.2"
|
||||
|
||||
[target.'cfg(target_os = "android")'.dependencies]
|
||||
log = "0.3"
|
||||
android_glue = "0.1.3"
|
||||
|
|
|
@ -15,11 +15,13 @@
|
|||
//!
|
||||
//! [glutin]: https://github.com/tomaka/glutin
|
||||
|
||||
#![feature(start)]
|
||||
#![feature(start, core_intrinsics)]
|
||||
|
||||
#[cfg(target_os = "android")]
|
||||
#[macro_use]
|
||||
extern crate android_glue;
|
||||
#[cfg(not(target_os = "android"))]
|
||||
extern crate backtrace;
|
||||
extern crate env_logger;
|
||||
// The window backed by glutin
|
||||
extern crate glutin_app as app;
|
||||
|
@ -30,6 +32,9 @@ extern crate libc;
|
|||
extern crate log;
|
||||
// The Servo engine
|
||||
extern crate servo;
|
||||
#[cfg(not(target_os = "android"))]
|
||||
#[macro_use]
|
||||
extern crate sig;
|
||||
|
||||
use servo::Browser;
|
||||
use servo::compositing::windowing::WindowEvent;
|
||||
|
@ -48,7 +53,33 @@ pub mod platform {
|
|||
pub fn deinit() {}
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "android"))]
|
||||
fn install_crash_handler() {
|
||||
use backtrace::Backtrace;
|
||||
use sig::ffi::Sig;
|
||||
use std::intrinsics::abort;
|
||||
use std::thread;
|
||||
|
||||
fn handler(_sig: i32) {
|
||||
let name = thread::current().name()
|
||||
.map(|n| format!(" for thread \"{}\"", n))
|
||||
.unwrap_or("".to_owned());
|
||||
println!("Stack trace{}\n{:?}", name, Backtrace::new());
|
||||
unsafe {
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
signal!(Sig::SEGV, handler);
|
||||
}
|
||||
|
||||
#[cfg(target_os = "android")]
|
||||
fn install_crash_handler() {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
install_crash_handler();
|
||||
|
||||
// Parse the command line options and store them globally
|
||||
let opts_result = opts::from_cmdline_args(&*args());
|
||||
|
||||
|
|
7
ports/cef/Cargo.lock
generated
7
ports/cef/Cargo.lock
generated
|
@ -1909,6 +1909,7 @@ name = "servo"
|
|||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"android_glue 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"backtrace 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"browserhtml 0.1.7 (git+https://github.com/browserhtml/browserhtml?branch=gh-pages)",
|
||||
"canvas 0.0.1",
|
||||
"canvas_traits 0.0.1",
|
||||
|
@ -1935,6 +1936,7 @@ dependencies = [
|
|||
"script 0.0.1",
|
||||
"script_layout_interface 0.0.1",
|
||||
"script_traits 0.0.1",
|
||||
"sig 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"style 0.0.1",
|
||||
"url 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"util 0.0.1",
|
||||
|
@ -2044,6 +2046,11 @@ dependencies = [
|
|||
"winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sig"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "simd"
|
||||
version = "0.1.0"
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
"dom.mouseevent.which.enabled": false,
|
||||
"dom.mozbrowser.enabled": false,
|
||||
"dom.serviceworker.timeout_seconds": 60,
|
||||
"dom.testable_crash.enabled": false,
|
||||
"dom.testbinding.enabled": false,
|
||||
"gfx.webrender.enabled": false,
|
||||
"js.baseline.enabled": true,
|
||||
|
|
|
@ -6952,6 +6952,12 @@
|
|||
"url": "/_mozilla/mozilla/service-workers/service-worker-registration.html"
|
||||
}
|
||||
],
|
||||
"mozilla/sigsegv.html": [
|
||||
{
|
||||
"path": "mozilla/sigsegv.html",
|
||||
"url": "/_mozilla/mozilla/sigsegv.html"
|
||||
}
|
||||
],
|
||||
"mozilla/storage.html": [
|
||||
{
|
||||
"path": "mozilla/storage.html",
|
||||
|
|
4
tests/wpt/mozilla/meta/mozilla/sigsegv.html.ini
Normal file
4
tests/wpt/mozilla/meta/mozilla/sigsegv.html.ini
Normal file
|
@ -0,0 +1,4 @@
|
|||
[sigsegv.html]
|
||||
type: testharness
|
||||
prefs: [dom.testbinding.enabled:true,dom.testable_crash.enabled:true]
|
||||
expected: CRASH
|
8
tests/wpt/mozilla/tests/mozilla/sigsegv.html
Normal file
8
tests/wpt/mozilla/tests/mozilla/sigsegv.html
Normal file
|
@ -0,0 +1,8 @@
|
|||
<!doctype html>
|
||||
<meta charset="utf-8">
|
||||
<title></title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
(new TestBinding()).crashHard();
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue