Closed Bug 1406952 Opened 7 years ago Closed 7 years ago

stylo: build script SIGSEGV on Linux/x86

Categories

(Core :: Layout, defect, P2)

x86
Linux
defect

Tracking

()

RESOLVED FIXED
mozilla58
Tracking Status
firefox57 --- fixed
firefox58 --- fixed

People

(Reporter: chrisccoulson, Assigned: emilio)

Details

Attachments

(2 files)

We're currently unable to build Firefox 57 for Ubuntu/x86 at the moment because the Stylo build script appears to crash. The same thing happens with mozilla-central too. Here's a log from where the build fails:

error: failed to run custom build command for `style v0.0.1
(file:///<<BUILDDIR>>/firefox-57.0~b5+build1/servo/components/style)`
process didn't exit successfully:
`/<<BUILDDIR>>/firefox-57.0~b5+build1/obj-i686-linux-gnu/toolkit/library/release/build/style-bd1b064914a910aa/build-script-build`
(signal: 11, SIGSEGV: invalid memory reference)
--- stdout
cargo:rerun-if-changed=build.rs
cargo:out_dir=/<<BUILDDIR>>/firefox-57.0~b5+build1/obj-i686-linux-gnu/toolkit/library/i686-unknown-linux-gnu/release/build/style-69d936cc9e10822e/out
cargo:rerun-if-changed=properties/properties.html.mako
cargo:rerun-if-changed=properties/computed_value_flags.rs
cargo:rerun-if-changed=properties/data.py
cargo:rerun-if-changed=properties/Mako-0.9.1.zip
=== snip ===
cargo:rerun-if-changed=/<<BUILDDIR>>/firefox-57.0~b5+build1/obj-i686-linux-gnu/dist/include/nsCSSAnonBoxList.h
cargo:rerun-if-changed=/<<BUILDDIR>>/firefox-57.0~b5+build1/servo/components/style/gecko/pseudo_element_definition.mako.rs

/<<BUILDDIR>>/firefox-57.0~b5+build1/config/rules.mk:999: recipe for
target 'force-cargo-library-build' failed
make[6]: *** [force-cargo-library-build] Error 101
make[6]: Leaving directory
'/<<BUILDDIR>>/firefox-57.0~b5+build1/obj-i686-linux-gnu/toolkit/library/rust'
/<<BUILDDIR>>/firefox-57.0~b5+build1/config/recurse.mk:73: recipe for
target 'toolkit/library/rust/target' failed
make[5]: *** [toolkit/library/rust/target] Error 2

I got a core dump from this and then extracted a backtrace with gdb afterwards:

(gdb) bt                                                         
#0  0x56b7dde8 in _GLOBAL_OFFSET_TABLE_ ()             
#1  0x566ad5ac in bindgen::clang::Diagnostic::format ()
#2  0x566e3403 in bindgen::Bindings::generate ()                                    
#3  0x566e197b in bindgen::Builder::generate ()                    
#4  0x5664f888 in build_script_build::build_gecko::bindings::write_binding_file ()
#5  0x566587ba in build_script_build::build_gecko::bindings::generate_bindings ()
#6  0x5697eee3 in panic_unwind::__rust_maybe_catch_panic () at /checkout/src/libpanic_unwind/lib.rs:98
#7  0x56647b4b in <F as alloc::boxed::FnBox<A>>::call_box ()
#8  0x56976389 in alloc::boxed::{{impl}}::call_once<(),()> () at /checkout/src/liballoc/boxed.rs:658
#9  std::sys_common::thread::start_thread () at /checkout/src/libstd/sys_common/thread.rs:21
#10 std::sys::imp::thread::{{impl}}::new::thread_start () at /checkout/src/libstd/sys/unix/thread.rs:84
#11 0xf76c237c in start_thread (arg=0xf69fdb40) at pthread_create.c:465
#12 0xf75b1036 in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:108

(gdb) info registers                               
eax            0x8      8                                                                         
ecx            0xf69f2078       -157343624            
edx            0xf401e850       -201201584                               
ebx            0x9      9                                              
esp            0xf69f209c       0xf69f209c                 
ebp            0x24     0x24                              
esi            0x56662548       1449534792               
edi            0xf5c33d00       -171754240     
eip            0x56b7dde8       0x56b7dde8 <_GLOBAL_OFFSET_TABLE_>          
eflags         0x10282  [ SF IF RF ]
cs             0x23     35
ss             0x2b     43
ds             0x2b     43
es             0x2b     43
fs             0x0      0
gs             0x63     99

(gdb) p $_siginfo
$1 = {si_signo = 11, si_errno = 0, si_code = 2, _sifields = {_pad = {1454890472, 0 <repeats 28 times>}, _kill = {si_pid = 1454890472, si_uid = 0}, _timer = {si_tid = 1454890472, si_overrun = 0, si_sigval = {
        sival_int = 0, sival_ptr = 0x0}}, _rt = {si_pid = 1454890472, si_uid = 0, si_sigval = {sival_int = 0, sival_ptr = 0x0}}, _sigchld = {si_pid = 1454890472, si_uid = 0, si_status = 0, si_utime = 0,
      si_stime = 0}, _sigfault = {si_addr = 0x56b7dde8 <_GLOBAL_OFFSET_TABLE_>, _addr_lsb = 0, _addr_bnd = {_lower = 0x0, _upper = 0x0}}, _sigpoll = {si_band = 1454890472, si_fd = 0}}}

The crash occurs when using our own rust 1.19.0 binary, as well as the upstream one downloaded with rustup (1.19.0-i686-unknown-linux-gnu).

This doesn't appear to affect 64-bit builds.
Component: Build Config → Layout
OS: Unspecified → Linux
Hardware: Unspecified → x86
That method where it's crashing is just:

  let opts = clang_defaultDiagnosticDisplayOptions();
  cxstring_into_string(clang_formatDiagnostic(self.x, opts))

Not sure what can be going on there, but it may be either an ABI issue, or somehow libclang not having that symbol, etc...

It'd be nice to try to reproduce this in upstream bindgen (https://github.com/rust-lang-nursery/rust-bindgen) and file an issue there. We can fix there and update bindgen after that.
Looking more closely, looks like the underlying library bindgen uses to communicate with libclang treats the return value of clang_defaultDiagnosticDisplayOptions as a struct (using the bitflags crate):

  https://github.com/KyleMayes/clang-sys/blob/996ac6dfb07735a74e1542e5244382cade5e25a1/src/lib.rs#L934

If that happens to be the case, then this is similar to https://github.com/rust-lang-nursery/rust-bindgen/issues/439, and requires similar fixes in clang-sys.

The good part is that this should be trivial to fix, then upgrade bindgen, then release a patch version of bindgen and update it in all the versions stylo is enabled.
Opened https://github.com/KyleMayes/clang-sys/pull/66, will take care of updating it, and hopefully that should be everything needed to close this.
Assignee: nobody → emilio
Excellent, thank you!
Priority: -- → P2
Summary: Stylo build script SIGSEGV on Linux/x86 → stylo: build script SIGSEGV on Linux/x86
I assume this needs a Beta approval request for the sake of our downstream consumers.
Flags: needinfo?(emilio)
Target Milestone: --- → mozilla58
I don't know whether this would completely fix the build per other comments in bug 1401093. As I said in that bug, I'll try to get a suitable environment and compile there.

Chris, can you give current mozilla-central a try and see if it builds?
Flags: needinfo?(chrisccoulson)
Beta builds on x86 with the patches backported.
Thanks for testing Mike, let's uplift them then.
Flags: needinfo?(emilio)
Flags: needinfo?(chrisccoulson)
Attached file Patch
This request is for:

 * https://hg.mozilla.org/mozilla-central/rev/29de77bcb714
 * https://hg.mozilla.org/mozilla-central/rev/2e1d10cef145

Approval Request Comment
[Feature/Bug causing the regression]: Stylo
[User impact if declined]: Firefox doesn't build in x86.
[Is this code covered by automated tests?]: No
[Has the fix been verified in Nightly?]: N/A
[Needs manual test from QE? If yes, steps to reproduce]: No 
[List of other uplifts needed for the feature/fix]: None
[Is the change risky?]: No
[Why is the change risky/not risky?]: It only affects the build.
[String changes made/needed]: none
Attachment #8918630 - Flags: review+
Attachment #8918630 - Flags: approval-mozilla-beta?
Note that the patches don't apply as-is on beta without fuzz, because of context changes in the Cargo.lock files.
Comment on attachment 8918630 [details] [review]
Patch

safe, makes sense, Beta57+
Attachment #8918630 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Attached patch Beta patchSplinter Review
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: