alacritty: Dev profile segmentation fault on MacOS M1

System

OS: macOS Version: alacritty 0.11.0-dev (67371048) (master at the time of writing)

Logs

$ target/debug/alacritty -v
Created log file at "/tmp/Alacritty-35354.log"
[0.000061416s] [INFO ] [alacritty] Welcome to Alacritty
[0.000327875s] [INFO ] [alacritty] Version 0.11.0-dev (67371048)
[0.001401958s] [INFO ] [alacritty] Configuration files loaded from:
                                     "/Users/nils/.config/alacritty/alacritty.yml"
[0.077961291s] [INFO ] [alacritty] Running on Apple M1
[0.078008333s] [INFO ] [alacritty] Using OpenGL 3.3 renderer
[0.080505291s] [INFO ] [alacritty] Display scale factor: 2
Segmentation fault: 11

There are no issues when alacritty is built using the --release flag.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 18 (10 by maintainers)

Most upvoted comments

If someone is interested in looking into it deeper, feel free to check out issues/commits in the compiler to identify what actually caused/fixed this or ask upstream directly.

But I don’t think there’s anything actionable for Alacritty, considering that it does seem fixed.

Seems like a rustc/llvm bug that got fixed to me? Could probably bring it to them or so, but it looks like a compiler bug due to assembly you’ve posted?

I’d also assume that when you’ve moved glBindTexture call to another unsafe block it started to work again?

Also, 🚫 is for crashing, right?

I have been able to reproduce either the same or a similar issue. I don’t have gdb, but lldb reports the following:

Process 22070 launched: '/Users/blakerain/dev/foss/alacritty/target/debug/alacritty' (arm64)
Process 22070 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x80000000)
    frame #0: 0x00000001000c3a00 alacritty`alacritty::renderer::text::atlas::Atlas::insert_inner::h6ea854eda79f372a(self=0x000000011cb9bec0, glyph=0x000000016fdeee50, active_tex=0x000000016fdf0104) at atlas.rs:141:45
   138 	        let multicolor;
   139 	
   140 	        unsafe {
-> 141 	            gl::BindTexture(gl::TEXTURE_2D, self.id);
   142 	
   143 	            // Load data into OpenGL.
   144 	            let (format, buffer) = match &glyph.buffer {
Target 0: (alacritty) stopped.
(lldb) bt
error: need to add support for DW_TAG_base_type 'char' encoded with DW_ATE = 0x8, bit_size = 32
error: need to add support for DW_TAG_base_type 'char' encoded with DW_ATE = 0x8, bit_size = 32
error: need to add support for DW_TAG_base_type '()' encoded with DW_ATE = 0x7, bit_size = 0
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x80000000)
  * frame #0: 0x00000001000c3a00 alacritty`alacritty::renderer::text::atlas::Atlas::insert_inner::h6ea854eda79f372a(self=0x000000011cb9bec0, glyph=0x000000016fdeee50, active_tex=0x000000016fdf0104) at atlas.rs:141:45
    frame #1: 0x00000001000c3958 alacritty`alacritty::renderer::text::atlas::Atlas::insert::hefe6ce57653b6ffa(self=0x000000011cb9bec0, glyph=0x000000016fdeee50, active_tex=0x000000016fdf0104) at atlas.rs:125:12
    frame #2: 0x00000001000c3e6c alacritty`alacritty::renderer::text::atlas::Atlas::load_glyph::h90c28d42f3f40057(active_tex=0x000000016fdf0104, atlas=0x000000016fdf00a8, current_atlas=0x000000016fdf00c0, rasterized=0x000000016fdeee50) at atlas.rs:232:15
    frame #3: 0x00000001000ce68c alacritty`_$LT$alacritty..renderer..text..LoaderApi$u20$as$u20$alacritty..renderer..text..glyph_cache..LoadGlyph$GT$::load_glyph::h77eccc5fc9aa5a77(self=0x000000016fdef1a0, rasterized=0x000000016fdeee50) at mod.rs:172:9
    frame #4: 0x0000000100130200 alacritty`alacritty::renderer::text::glyph_cache::GlyphCache::load_glyph::h8ab0a9ccc08aa0c9(self=0x000000016fdef880, loader=0x000000016fdef1a0, glyph=RasterizedGlyph @ 0x000000016fdeee50) at glyph_cache.rs:264:9
    frame #5: 0x000000010012ee84 alacritty`alacritty::renderer::text::glyph_cache::GlyphCache::get::h1cca91a60ecb5683(self=0x000000016fdef880, glyph_key=GlyphKey @ 0x000000016fdeece0, loader=0x000000016fdef1a0, show_missing=true) at glyph_cache.rs:221:31
    frame #6: 0x000000010012ec30 alacritty`alacritty::renderer::text::glyph_cache::GlyphCache::load_glyphs_for_font::hbe8e5483e3abb933(self=0x000000016fdef880, font=(token = 0), loader=0x000000016fdef1a0) at glyph_cache.rs:113:13
    frame #7: 0x00000001001308d0 alacritty`alacritty::renderer::text::glyph_cache::GlyphCache::load_common_glyphs::h0296517e62d8c83d(self=0x000000016fdef880, loader=0x000000016fdef1a0) at glyph_cache.rs:318:9
    frame #8: 0x00000001000ae930 alacritty`alacritty::display::Display::new::_$u7b$$u7b$closure$u7d$$u7d$::h039926e6673eb65e(api=<unavailable>) at mod.rs:437:13
    frame #9: 0x00000001000592cc alacritty`alacritty::renderer::text::TextRenderer::with_loader::h53b996848e192e9d(self=0x000000016fdf00a8, func={closure#2} @ 0x000000016fdef1e8) at mod.rs:76:9
    frame #10: 0x000000010014c3ec alacritty`alacritty::renderer::Renderer::with_loader::hf419d255c80e4e80(self=0x000000016fdf00a0, func={closure#2} @ 0x000000016fdef228) at mod.rs:150:54
    frame #11: 0x00000001000ad8bc alacritty`alacritty::display::Display::new::h3bb2bb3af49182c4(config=0x000000016fdfdb58, event_loop=0x0000000101730d80, identity=0x000000016fdf1d10) at mod.rs:436:9
    frame #12: 0x00000001000c1a18 alacritty`alacritty::window_context::WindowContext::new::hab2dbcbf6e6f7504(config=0x000000016fdfdb58, options=0x000000016fdfe5b0, window_event_loop=0x0000000101730d80, proxy=EventLoopProxy<alacritty::event::Event> @ 0x000000016fdfa510) at window_context.rs:81:23
    frame #13: 0x00000001000eaf98 alacritty`alacritty::event::Processor::create_window::h5f8f5afc4c4399ab(self=0x000000016fdfd958, event_loop=0x0000000101730d80, proxy=<unavailable>, options=WindowOptions @ 0x000000016fdfe5b0) at event.rs:1233:30
    frame #14: 0x0000000100045854 alacritty`alacritty::alacritty::h468daec2a6695608(options=Options @ 0x000000016fdff120) at main.rs:194:5
    frame #15: 0x0000000100044d9c alacritty`alacritty::main::hb1322be2d9820ae4 at main.rs:81:17
    frame #16: 0x000000010009a8fc alacritty`core::ops::function::FnOnce::call_once::h8779a28795e24891((null)=(alacritty`alacritty::main::hb1322be2d9820ae4 at main.rs:63), (null)=<unavailable>) at function.rs:227:5
    frame #17: 0x000000010005b4c0 alacritty`std::sys_common::backtrace::__rust_begin_short_backtrace::hc8336eeab94724b4(f=(alacritty`alacritty::main::hb1322be2d9820ae4 at main.rs:63)) at backtrace.rs:123:18
    frame #18: 0x000000010002b5d8 alacritty`std::rt::lang_start::_$u7b$$u7b$closure$u7d$$u7d$::h64b154070ead87c2 at rt.rs:145:18
    frame #19: 0x00000001005c9614 alacritty`std::rt::lang_start_internal::h35c587f98e9244f6 [inlined] core::ops::function::impls::_$LT$impl$u20$core..ops..function..FnOnce$LT$A$GT$$u20$for$u20$$RF$F$GT$::call_once::h10f2582b16e2b13c at function.rs:259:13 [opt]
    frame #20: 0x00000001005c9608 alacritty`std::rt::lang_start_internal::h35c587f98e9244f6 [inlined] std::panicking::try::do_call::hd3dfc31f9ced2f42 at panicking.rs:406:40 [opt]
    frame #21: 0x00000001005c9608 alacritty`std::rt::lang_start_internal::h35c587f98e9244f6 [inlined] std::panicking::try::h584945b02ec0e15d at panicking.rs:370:19 [opt]
    frame #22: 0x00000001005c9608 alacritty`std::rt::lang_start_internal::h35c587f98e9244f6 [inlined] std::panic::catch_unwind::h1138cecd37279bb6 at panic.rs:133:14 [opt]
    frame #23: 0x00000001005c9608 alacritty`std::rt::lang_start_internal::h35c587f98e9244f6 [inlined] std::rt::lang_start_internal::_$u7b$$u7b$closure$u7d$$u7d$::hf94f7401539e24a6 at rt.rs:128:48 [opt]
    frame #24: 0x00000001005c9608 alacritty`std::rt::lang_start_internal::h35c587f98e9244f6 [inlined] std::panicking::try::do_call::ha8b5def05088e3d3 at panicking.rs:406:40 [opt]
    frame #25: 0x00000001005c9608 alacritty`std::rt::lang_start_internal::h35c587f98e9244f6 [inlined] std::panicking::try::h3ce579dae5f3a6fb at panicking.rs:370:19 [opt]
    frame #26: 0x00000001005c9608 alacritty`std::rt::lang_start_internal::h35c587f98e9244f6 [inlined] std::panic::catch_unwind::h29ecbe0d385e9017 at panic.rs:133:14 [opt]
    frame #27: 0x00000001005c9608 alacritty`std::rt::lang_start_internal::h35c587f98e9244f6 at rt.rs:128:20 [opt]
    frame #28: 0x000000010002b5a4 alacritty`std::rt::lang_start::hc482f86402131429(main=(alacritty`alacritty::main::hb1322be2d9820ae4 at main.rs:63), argc=1, argv=0x000000016fdff608) at rt.rs:144:17
    frame #29: 0x0000000100045ef4 alacritty`main + 32
    frame #30: 0x00000001013b1088 dyld`start + 516

The generated code up to this point is as follows:

alacritty`alacritty::renderer::text::atlas::Atlas::insert_inner::h6ea854eda79f372a:
    0x1000c3990 <+0>:   sub    sp, sp, #0xc0
    0x1000c3994 <+4>:   stp    x29, x30, [sp, #0xb0]
    0x1000c3998 <+8>:   add    x29, sp, #0xb0
    0x1000c399c <+12>:  str    x8, [sp, #0x18]
    0x1000c39a0 <+16>:  str    x0, [sp, #0x20]
    0x1000c39a4 <+20>:  str    x1, [sp, #0x28]
    0x1000c39a8 <+24>:  str    x2, [sp, #0x30]
    0x1000c39ac <+28>:  mov    x8, x0
    0x1000c39b0 <+32>:  str    x8, [sp, #0x58]
    0x1000c39b4 <+36>:  mov    x8, x1
    0x1000c39b8 <+40>:  stur   x8, [x29, #-0x50]
    0x1000c39bc <+44>:  stur   x2, [x29, #-0x48]
    0x1000c39c0 <+48>:  ldr    s0, [x0, #0x10]
    0x1000c39c4 <+52>:  str    s0, [sp, #0x38]
    0x1000c39c8 <+56>:  stur   s0, [x29, #-0x40]
    0x1000c39cc <+60>:  ldr    s0, [x0, #0xc]
    0x1000c39d0 <+64>:  str    s0, [sp, #0x3c]
    0x1000c39d4 <+68>:  stur   s0, [x29, #-0x3c]
    0x1000c39d8 <+72>:  ldr    s0, [x1, #0x28]
    0x1000c39dc <+76>:  mrs    x0, NZCV
    0x1000c39e0 <+80>:  str    h0, [sp, #0x42]
    0x1000c39e4 <+84>:  mrs    x0, NZCV
    0x1000c39e8 <+88>:  stur   s0, [x29, #-0x38]
    0x1000c39ec <+92>:  ldr    s0, [x1, #0x24]
    0x1000c39f0 <+96>:  mrs    x0, NZCV
    0x1000c39f4 <+100>: str    h0, [sp, #0x44]
    0x1000c39f8 <+104>: mrs    x0, NZCV
    0x1000c39fc <+108>: stur   s0, [x29, #-0x34]
->  0x1000c3a00 <+112>: ldr    w1, [x0]
    0x1000c3a04 <+116>: mov    w0, #0xde1
    0x1000c3a08 <+120>: bl     0x1000f3c3c               ; alacritty::gl::BindTexture::h940891e665198187 at gl_bindings.rs:997

Looking into the generated code, it seems that the value of self in x0 is being clobbered before the call to gl::BindTexture, although I don’t entirely follow what’s going on. Certainly x0 no longer contains self:

(lldb) print self
(alacritty::renderer::text::atlas::Atlas *) $0 = 0x0000000129f2a240
(lldb) register read
General Purpose Registers:
        x0 = 0x0000000080000000  <-- corresponds to the EXC_BAD_ACCESS (code=1, address=0x80000000)
        x1 = 0x000000016fdeed00
        x2 = 0x000000016fdeffb4
        x3 = 0x00000001006cf868  alacritty`alacritty::renderer::text::glsl3::TEXT_SHADER_V::h997145fbb963c315 + 2152
        x4 = 0x0000000000000090
        x5 = 0x0000000129f2ca70
        x6 = 0x0000000100000000  alacritty`_mh_execute_header
        x7 = 0x0000000000000000
        x8 = 0x000000016fdeed00
        x9 = 0x0000000000000400
       x10 = 0x0000000000000001
       x11 = 0x0000000000000400
       x12 = 0x0000000000002be4
       x13 = 0x0000000000000289
       x14 = 0x0000000002000000
       x15 = 0x0000000082000000
       x16 = 0x00000001bb2d50f0  libsystem_platform.dylib`_platform_memmove
       x17 = 0x0000000213a69c00  (void *)0x0000000213a69c28: __NSCFType
       x18 = 0x0000000000000000
       x19 = 0x000000016fdff308
       x20 = 0x00000001006c9b78
       x21 = 0x000000010140c070  dyld`dyld4::sConfigBuffer
       x22 = 0x0000000000000000
       x23 = 0x0000000000000000
       x24 = 0x0000000000000000
       x25 = 0x0000000000000000
       x26 = 0x0000000000000000
       x27 = 0x0000000000000000
       x28 = 0x0000000000000000
        fp = 0x000000016fdee8f0
        lr = 0x00000001000c3958  alacritty`alacritty::renderer::text::atlas::Atlas::insert::hefe6ce57653b6ffa + 304 at atlas.rs:125:12
        sp = 0x000000016fdee840
        pc = 0x00000001000c3a00  alacritty`alacritty::renderer::text::atlas::Atlas::insert_inner::h6ea854eda79f372a + 112 at atlas.rs:141:45
      cpsr = 0x80001000

If I move to gl::BindTexture out of the unsafe block and into it’s own block before the variables are declared, the clobbering goes away.

Try running attaching debug to target/debug/alacritty.