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

bug: Got segfaults when using treesitter to load tree-sitter-zig.wasm #2732

Closed
CGQAQ opened this issue Apr 25, 2023 · 17 comments · Fixed by #3741
Closed

bug: Got segfaults when using treesitter to load tree-sitter-zig.wasm #2732

CGQAQ opened this issue Apr 25, 2023 · 17 comments · Fixed by #3741
Labels
bug Something isn't working

Comments

@CGQAQ
Copy link
Contributor

CGQAQ commented Apr 25, 2023

What version of Bun is running?

0.5.9

What platform is your computer?

Linux 5.15.0-70-generic x86_64 x86_64

What steps can reproduce the bug?

see:
https://github.com/CGQAQ/bun-bug-2732-reproduce

What is the expected behavior?

don't segmentation fault

What do you see instead?

segmentation fault

Additional information

No response

@CGQAQ CGQAQ added the bug Something isn't working label Apr 25, 2023
@CGQAQ
Copy link
Contributor Author

CGQAQ commented Apr 25, 2023

image

I think it's because the parsers object is two big??? when I comment out zig: await loadLanguageParser("node_modules/@unit-mesh/treesitter-artifacts/wasm/tree-sitter-zig.wasm"),, it works again

@CGQAQ
Copy link
Contributor Author

CGQAQ commented Apr 25, 2023

On deno:
image

I guess it's the limitation in wasm??

@CGQAQ
Copy link
Contributor Author

CGQAQ commented Apr 25, 2023

On node:
image

@Jarred-Sumner
Copy link
Collaborator

Sounds like this is an exception which Bun isn't handling correctly

@CGQAQ
Copy link
Contributor Author

CGQAQ commented Apr 26, 2023

image

Process 111699 resuming
Process 111699 stopped
* thread #1, name = 'bun-debug', stop reason = signal SIGSEGV: invalid address (fault address: 0x0)
    frame #0: 0x0000555558bda973 bun-debug`mi_malloc_aligned + 243
bun-debug`mi_malloc_aligned:
->  0x555558bda973 <+243>: movq   (%rax), %rcx
    0x555558bda976 <+246>: movq   %rcx, 0x10(%r8)
    0x555558bda97a <+250>: retq
    0x555558bda97b <+251>: xorl   %edx, %edx

@CGQAQ
Copy link
Contributor Author

CGQAQ commented Apr 26, 2023

backtrace
Process 111699 resuming
Process 111699 stopped
* thread #1, name = 'bun-debug', stop reason = signal SIGUSR1
    frame #0: 0x00007ffff7ce780a libc.so.6`__sigsuspend + 74
libc.so.6`__sigsuspend:
->  0x7ffff7ce780a <+74>: cmpq   $-0x1000, %rax            ; imm = 0xF000
    0x7ffff7ce7810 <+80>: ja     0x7ffff7ce7848            ; <+136>
    0x7ffff7ce7812 <+82>: movl   %r8d, %edi
    0x7ffff7ce7815 <+85>: movl   %eax, 0x8(%rsp)
(lldb) c
Process 111699 resuming
Process 111699 stopped
* thread #1, name = 'bun-debug', stop reason = signal SIGSEGV: invalid address (fault address: 0x0)
    frame #0: 0x0000555558bda973 bun-debug`mi_malloc_aligned + 243
bun-debug`mi_malloc_aligned:
->  0x555558bda973 <+243>: movq   (%rax), %rcx
    0x555558bda976 <+246>: movq   %rcx, 0x10(%r8)
    0x555558bda97a <+250>: retq
    0x555558bda97b <+251>: xorl   %edx, %edx
(lldb) frame info
frame #0: 0x0000555558bda973 bun-debug`mi_malloc_aligned + 243
(lldb)  thread backtrace
* thread #1, name = 'bun-debug', stop reason = signal SIGSEGV: invalid address (fault address: 0x0)
  * frame #0: 0x0000555558bda973 bun-debug`mi_malloc_aligned + 243
    frame #1: 0x000055555a6a0c5d bun-debug`src.memory_allocator.CAllocator.alignedAlloc(len=82, alignment=1) at memory_allocator.zig:63:39
    frame #2: 0x000055555a6a0c0e bun-debug`src.memory_allocator.CAllocator.alloc((null)=0x0000000000000000, len=82, ptr_align='\x01', (null)=93825089348094) at memory_allocator.zig:82:28
    frame #3: 0x000055555b9a1982 bun-debug`mem.Allocator.allocAdvancedWithRetAddr__anon_266100 at Allocator.zig:86:34
    frame #4: 0x000055555b9a1960 bun-debug`mem.Allocator.allocAdvancedWithRetAddr__anon_266100 [inlined] mem.Allocator.log2a at Allocator.zig:330:25
    frame #5: 0x000055555b9a194b bun-debug`mem.Allocator.allocAdvancedWithRetAddr__anon_266100(self=mem.Allocator @ 0x00007fffffff0dd0, n=41, return_address=93825089348094) at Allocator.zig:216:53
    frame #6: 0x000055555b960735 bun-debug`mem.Allocator.alignedAlloc__anon_260699(self=<unavailable>, n=41) at Allocator.zig:192:41
    frame #7: 0x000055555b1f21fe bun-debug`array_list.ArrayListAligned(self=0x00007fffffff15b0, new_capacity=41).ensureTotalCapacityPrecise at array_list.zig:401:67
    frame #8: 0x000055555ab8aca2 bun-debug`array_list.ArrayListAligned(self=0x00007fffffff15b0, new_capacity=23).ensureTotalCapacity at array_list.zig:377:51
    frame #9: 0x000055555ab8ada5 bun-debug`array_list.ArrayListAligned(self=0x00007fffffff15b0).addOne at array_list.zig:424:57
    frame #10: 0x000055555a6af08f bun-debug`array_list.ArrayListAligned(self=0x00007fffffff15b0, item=65533).append at array_list.zig:207:49
    frame #11: 0x000055555b257e95 bun-debug`src.string_immutable.toUTF16Alloc__anon_166307(allocator=mem.Allocator @ 0x000055555de6fe40, bytes=(ptr = "\xa9\r\xa9\r\xfa\r\xcd\U0000000e\x97\v\x97\v\x97\v\x97\v\x97\v\xcd\U0000000e\xcd\U0000000e\xcd\U0000000e\xcd\U0000000e\xcd\U0000000e", len = 28)) at string_immutable.zig:1293:39
    frame #12: 0x000055555bc4973d bun-debug`src.bun.js.webcore.encoding.TextDecoder.decodeSlice(this=0x00000361b4020100, globalThis=0x00007fffac4a4068, buffer_slice=(ptr = "\xa9\r\xa9\r\xfa\r\xcd\U0000000e\x97\v\x97\v\x97\v\x97\v\x97\v\xcd\U0000000e\xcd\U0000000e\xcd\U0000000e\xcd\U0000000e\xcd\U0000000e", len = 28)) at encoding.zig:643:45
    frame #13: 0x000055555bc493ce bun-debug`TextDecoderPrototype__decodeWithoutTypeChecks(this=0x00000361b4020100, globalThis=0x00007fffac4a4068, uint8array=0x00007fffacf5af20) at encoding.zig:601:61
    frame #14: 0x00007fffad4b3de5
    frame #15: 0x00007fffad4b03c5
    frame #16: 0x0000555559a9867a bun-debug`llint_op_construct + 151
    frame #17: 0x00007fffad4a713c
    frame #18: 0x0000555559a7a8de bun-debug`vmEntryToJavaScript + 213
    frame #19: 0x00005555590c20eb bun-debug`JSC::Interpreter::executeCall(JSC::JSObject*, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) + 667
    frame #20: 0x000055555946400e bun-debug`JSC::profiledCall(JSC::JSGlobalObject*, JSC::ProfilingReason, JSC::JSValue, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) + 174
    frame #21: 0x0000555559006db0 bun-debug`JSC::runJSMicrotask(JSC::JSGlobalObject*, WTF::ObjectIdentifierGeneric<JSC::MicrotaskIdentifierType, WTF::ObjectIdentifierThreadSafeAccessTraits>, JSC::JSValue, JSC::JSValue, JSC::JSValue, JSC::JSValue, JSC::JSValue) + 320
    frame #22: 0x0000555559170dd7 bun-debug`JSC::VM::drainMicrotasks() + 551
    frame #23: 0x0000555559c42259 bun-debug`JSC::DeferredWorkTimer::doWork(JSC::VM&) + 1433
    frame #24: 0x000055555b939911 bun-debug`src.bun.js.bindings.bindings.VM.doWork at shimmer.zig:186:41
    frame #25: 0x000055555b939903 bun-debug`src.bun.js.bindings.bindings.VM.doWork(vm=0x00007fffac000000) at bindings.zig:4649:21
    frame #26: 0x000055555b187905 bun-debug`src.bun.js.event_loop.EventLoop.tick(this=0x00000361b4100100) at event_loop.zig:614:32
    frame #27: 0x000055555b94da70 bun-debug`src.bun.js.event_loop.EventLoop.waitForPromise(this=0x00000361b4100100, promise=src.bun.js.bindings.bindings.AnyPromise @ 0x00007fffffff26d8) at event_loop.zig:647:30
    frame #28: 0x000055555b1b10bc bun-debug`src.bun.js.javascript.VirtualMachine.waitForPromise(this=0x00000361b4100000, promise=<unavailable>) at javascript.zig:632:40
    frame #29: 0x000055555b1b1539 bun-debug`src.bun.js.javascript.VirtualMachine.loadEntryPoint(this=0x00000361b4100000, entry_path=(ptr = "/root/code/p/unit-assistant/index.ts", len = 36)) at javascript.zig:1582:32
    frame #30: 0x000055555b1b17f1 bun-debug`src.bun_js.Run.start(this=0x000055555e8d38b8) at bun_js.zig:136:35
    frame #31: 0x000055555b1b3289 bun-debug`src.bun.js.javascript.OpaqueWrap__anon_83600__struct_149344.callback(ctx=0x000055555e8d38b8) at javascript.zig:121:13
    frame #32: 0x000055555a5978c5 bun-debug`::JSC__VM__holdAPILock(arg0=<unavailable>, ctx=0x000055555e8d38b8, callback=(bun-debug`src.bun.js.javascript.OpaqueWrap__anon_83600__struct_149344.callback at javascript.zig:119))(void *)) at bindings.cpp:3491:5
    frame #33: 0x000055555ab63999 bun-debug`src.bun.js.bindings.bindings.VM.holdAPILock at shimmer.zig:186:41
    frame #34: 0x000055555ab63983 bun-debug`src.bun.js.bindings.bindings.VM.holdAPILock(this=0x00007fffac000000, ctx=0x000055555e8d38b8, callback=0x000055555b1b3210) at bindings.zig:4528:14
    frame #35: 0x000055555ab63896 bun-debug`src.bun_js.Run.boot(ctx_=<unavailable>, file=(handle = 3), entry_path=(ptr = "/root/code/p/unit-assistant/index.ts", len = 36)) at bun_js.zig:122:35
    frame #36: 0x000055555ab7f6de bun-debug`src.cli.Command.maybeOpenWithBunJS(ctx=0x00007fffffff95d0) at cli.zig:1482:23
    frame #37: 0x000055555ab7aab5 bun-debug`src.cli.Command.start(allocator=mem.Allocator @ 0x000055555dddcc98, log=0x000055555e8dad28) at cli.zig:1385:47
    frame #38: 0x000055555a69e3d6 bun-debug`src.cli.Cli.start__anon_3677(allocator=mem.Allocator @ 0x000055555dddcc98, (null)=<unavailable>, (null)=<unavailable>) at cli.zig:58:22
    frame #39: 0x000055555a69dc2f bun-debug`src.main.main at main.zig:38:26
    frame #40: 0x000055555a69ea5c bun-debug`main [inlined] start.callMain at start.zig:599:22
    frame #41: 0x000055555a69ea57 bun-debug`main [inlined] start.initEventLoopAndCallMain at start.zig:543:5
    frame #42: 0x000055555a69ea57 bun-debug`main at start.zig:493:36
    frame #43: 0x000055555a69e9a1 bun-debug`main(c_argc=2, c_argv=0x00007fffffffe398, c_envp=0x00007fffffffe3b0) at start.zig:508:80
    frame #44: 0x00007ffff7cced90 libc.so.6`___lldb_unnamed_symbol3139 + 128
    frame #45: 0x00007ffff7ccee40 libc.so.6`__libc_start_main + 128
    frame #46: 0x0000555558bd8225 bun-debug`_start + 37

@Jarred-Sumner
Copy link
Collaborator

@CGQAQ thanks for these stack traces

What's the memory usage? It looks like it failed to allocate memory in mimalloc

You can find out with time -v bun-debug run index.ts (if using fish, command time -v)

@CGQAQ
Copy link
Contributor Author

CGQAQ commented Apr 26, 2023

image

detail
unit-assistant git:(main) command time -v /root/code/repos/bun/packages/debug-bun-linux-x64/bun-debug index.ts
[SYS] close(10)
[SYS] close(22)
[SYS] close(28)
[SYS] open(/root/code/p/unit-assistant/node_modules/.deno/web-tree-sitter@0.20.8/node_modules/web-tree-sitter/tree-sitter.wasm): 32
[SYS] fstat(32) = 0
[SYS] read(32, 186542) = 186526 (0.099ms)
[SYS] read(32, 16) = 0 (0.004ms)
[SYS] close(32)
[SYS] open(node_modules/@unit-mesh/treesitter-artifacts/wasm/tree-sitter-c.wasm): 32
[SYS] fstat(32) = 0
[SYS] read(32, 370091) = 370075 (0.150ms)
[SYS] read(32, 16) = 0 (0.002ms)
[SYS] close(32)
[SYS] open(node_modules/@unit-mesh/treesitter-artifacts/wasm/tree-sitter-c_sharp.wasm): 32
[SYS] fstat(32) = 0
[SYS] read(32, 3982250) = 3982234 (1.365ms)
[SYS] read(32, 16) = 0 (0.003ms)
[SYS] close(32)
[SYS] open(node_modules/@unit-mesh/treesitter-artifacts/wasm/tree-sitter-cpp.wasm): 32
[SYS] fstat(32) = 0
[SYS] read(32, 1556689) = 1556673 (0.679ms)
[SYS] read(32, 16) = 0 (0.003ms)
[SYS] close(32)
[SYS] open(node_modules/@unit-mesh/treesitter-artifacts/wasm/tree-sitter-go.wasm): 32
[SYS] fstat(32) = 0
[SYS] read(32, 179818) = 179802 (0.066ms)
[SYS] read(32, 16) = 0 (0.002ms)
[SYS] close(32)
[SYS] open(node_modules/@unit-mesh/treesitter-artifacts/wasm/tree-sitter-java.wasm): 32
[SYS] fstat(32) = 0
[SYS] read(32, 232257) = 232241 (0.069ms)
[SYS] read(32, 16) = 0 (0.002ms)
[SYS] close(32)
[SYS] open(node_modules/@unit-mesh/treesitter-artifacts/wasm/tree-sitter-javascript.wasm): 32
[SYS] fstat(32) = 0
[SYS] read(32, 233318) = 233302 (0.101ms)
[SYS] read(32, 16) = 0 (0.005ms)
[SYS] close(32)
[SYS] open(node_modules/@unit-mesh/treesitter-artifacts/wasm/tree-sitter-typescript.wasm): 32
[SYS] fstat(32) = 0
[SYS] read(32, 994024) = 994008 (0.337ms)
[SYS] read(32, 16) = 0 (0.003ms)
[SYS] close(32)
[SYS] open(node_modules/@unit-mesh/treesitter-artifacts/wasm/tree-sitter-tsx.wasm): 32
[SYS] fstat(32) = 0
[SYS] read(32, 1041354) = 1041338 (0.327ms)
[SYS] read(32, 16) = 0 (0.003ms)
[SYS] close(32)
[SYS] open(node_modules/@unit-mesh/treesitter-artifacts/wasm/tree-sitter-kotlin.wasm): 32
[SYS] fstat(32) = 0
[SYS] read(32, 1272419) = 1272403 (0.475ms)
[SYS] read(32, 16) = 0 (0.006ms)
[SYS] close(32)
[SYS] open(node_modules/@unit-mesh/treesitter-artifacts/wasm/tree-sitter-lua.wasm): 32
[SYS] fstat(32) = 0
[SYS] read(32, 43748) = 43732 (0.026ms)
[SYS] read(32, 16) = 0 (0.002ms)
[SYS] close(32)
[SYS] open(node_modules/@unit-mesh/treesitter-artifacts/wasm/tree-sitter-python.wasm): 32
[SYS] fstat(32) = 0
[SYS] read(32, 261761) = 261745 (0.120ms)
[SYS] read(32, 16) = 0 (0.003ms)
[SYS] close(32)
[SYS] open(node_modules/@unit-mesh/treesitter-artifacts/wasm/tree-sitter-rust.wasm): 32
[SYS] fstat(32) = 0
[SYS] read(32, 751870) = 751854 (0.290ms)
[SYS] read(32, 16) = 0 (0.002ms)
[SYS] close(32)
[SYS] open(node_modules/@unit-mesh/treesitter-artifacts/wasm/tree-sitter-swift.wasm): 32
[SYS] fstat(32) = 0
[SYS] read(32, 2519736) = 2519720 (0.803ms)
[SYS] read(32, 16) = 0 (0.003ms)
[SYS] close(32)
[SYS] open(node_modules/@unit-mesh/treesitter-artifacts/wasm/tree-sitter-zig.wasm): 32
[SYS] fstat(32) = 0
[SYS] read(32, 3915807) = 3915791 (1.460ms)
[SYS] read(32, 16) = 0 (0.003ms)
[SYS] close(32)
Command terminated by signal 11
        Command being timed: "/root/code/repos/bun/packages/debug-bun-linux-x64/bun-debug index.ts"
        User time (seconds): 0.42
        System time (seconds): 0.21
        Percent of CPU this job got: 103%
        Elapsed (wall clock) time (h:mm:ss or m:ss): 0:00.61
        Average shared text size (kbytes): 0
        Average unshared data size (kbytes): 0
        Average stack size (kbytes): 0
        Average total size (kbytes): 0
        Maximum resident set size (kbytes): 297364
        Average resident set size (kbytes): 0
        Major (requiring I/O) page faults: 0
        Minor (reclaiming a frame) page faults: 60572
        Voluntary context switches: 978
        Involuntary context switches: 240
        Swaps: 0
        File system inputs: 0
        File system outputs: 224
        Socket messages sent: 0
        Socket messages received: 0
        Signals delivered: 0
        Page size (bytes): 4096
        Exit status: 0

@CGQAQ
Copy link
Contributor Author

CGQAQ commented Apr 26, 2023

image

strange

@Jarred-Sumner
Copy link
Collaborator

You'll need a very recent version of Valgrind due to DWARF v5 (the latest), have a look at https://bun.sh/docs/project/development#valgrind

@CGQAQ
Copy link
Contributor Author

CGQAQ commented Apr 26, 2023

added -gdwarf-4 still don't work
image

but with ASan, I got some additional info, hope this will help
image

Jarred-Sumner added a commit that referenced this issue Apr 26, 2023
@Jarred-Sumner
Copy link
Collaborator

@CGQAQ can you try building 2795f0b? I suspect it's an alignment issue

@CGQAQ
Copy link
Contributor Author

CGQAQ commented Apr 26, 2023

I have made a debug build of mimalloc by make mimalloc-debug, and run make dev, here is what I found, seems like a buffer overflow, don't know if it's the same bug, I am building 2795f0b now

image

detail
(lldb) c                                                                                                                                                                                                         Process 153037 resuming                                                                                                                                                                                          mimalloc: error: buffer overflow in heap block 0x20000360230 of size 96: write after 96 bytes                                                                                                                    Process 153037 stopped                                                                                                                                                                                           * thread #1, name = 'bun-debug', stop reason = signal SIGABRT                                                                                                                                                        frame #0: 0x00007ffff7d3ba7c libc.so.6`__GI___pthread_kill at pthread_kill.c:44:76                                                                                                                           (lldb) bt                                                                                                                                                                                                        * thread #1, name = 'bun-debug', stop reason = signal SIGABRT                                                                                                                                                      * frame #0: 0x00007ffff7d3ba7c libc.so.6`__GI___pthread_kill at pthread_kill.c:44:76                                                                                                                               frame #1: 0x00007ffff7d3ba30 libc.so.6`__GI___pthread_kill [inlined] __pthread_kill_internal(signo=6, threadid=140737350610368) at pthread_kill.c:78:10                                                          frame #2: 0x00007ffff7d3ba30 libc.so.6`__GI___pthread_kill(threadid=140737350610368, signo=6) at pthread_kill.c:89:10                                                                                            frame #3: 0x00007ffff7ce7476 libc.so.6`__GI_raise(sig=6) at raise.c:26:13                                                                                                                                        frame #4: 0x00007ffff7ccd7f3 libc.so.6`__GI_abort at abort.c:79:7                                                                                                                                                frame #5: 0x000055555a4f0934 bun-debug`_mi_error_message(err=<unavailable>, fmt=<unavailable>) at options.c:0                                                                                                    frame #6: 0x000055555a504d0f bun-debug`mi_check_padding(page=0x0000020000001548, block=0x0000020000360230) at alloc.c:312:5                                                                                      frame #7: 0x000055555a504712 bun-debug`::mi_free(p=0x0000020000360230) at alloc.c:552:7                                                                                                                          frame #8: 0x000055555a6ac87a bun-debug`src.memory_allocator.mimalloc_free((null)=0x0000000000000000, buf=(ptr = "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\U00000001", len = 96), buf_align='\x01', (null)=93825089396041) at memory_allocator.zig:21:55                                    frame #9: 0x000055555b96c456 bun-debug`mem.Allocator.free__anon_260700 at Allocator.zig:98:33                                                                                                                    frame #10: 0x000055555b96c439 bun-debug`mem.Allocator.free__anon_260700 [inlined] mem.Allocator.log2a at Allocator.zig:330:25
    frame #11: 0x000055555b96c403 bun-debug`mem.Allocator.free__anon_260700(self=mem.Allocator @ 0x00007fffffff14d8, memory=[]u16 @ 0x00007fffffff0cc8) at Allocator.zig:303:58
    frame #12: 0x000055555b1fdd49 bun-debug`array_list.ArrayListAligned(self=0x00007fffffff14c0, new_capacity=80).ensureTotalCapacityPrecise at array_list.zig:403:36
    frame #13: 0x000055555ab96742 bun-debug`array_list.ArrayListAligned(self=0x00007fffffff14c0, new_capacity=51).ensureTotalCapacity at array_list.zig:377:51
    frame #14: 0x000055555a6bac2a bun-debug`array_list.ArrayListAligned(self=0x00007fffffff14c0, additional_count=42).ensureUnusedCapacity at array_list.zig:412:60
    frame #15: 0x000055555b262dbe bun-debug`src.string_immutable.toUTF16Alloc__anon_166307(allocator=mem.Allocator @ 0x000055555de7c740, bytes=(ptr = "VV\x80\x81\x81\x81\x819\xbb*++++++++++++++++++++++++++++++++++++++++\U00000001\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81ɬ\xac\xac\xac\xac\xac\xac\xac\xac\xac\xac\xac\xac\xac\xac\xd0\r", len = 84)) at string_immutable.zig:1268:44
    frame #16: 0x000055555bc551dd bun-debug`src.bun.js.webcore.encoding.TextDecoder.decodeSlice(this=0x0000020000330140, globalThis=0x00007fffac4a4068, buffer_slice=(ptr = "VV\x80\x81\x81\x81\x819\xbb*++++++++++++++++++++++++++++++++++++++++\U00000001\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81ɬ\xac\xac\xac\xac\xac\xac\xac\xac\xac\xac\xac\xac\xac\xac\xd0\r", len = 84)) at encoding.zig:643:45
    frame #17: 0x000055555bc54e6e bun-debug`TextDecoderPrototype__decodeWithoutTypeChecks(this=0x0000020000330140, globalThis=0x00007fffac4a4068, uint8array=0x00007fffacd2fcd0) at encoding.zig:601:61
    frame #18: 0x00007fffad4b42e5
    frame #19: 0x00007fffad4b03c5
    frame #20: 0x0000555559a8823a bun-debug`llint_op_construct + 151
    frame #21: 0x00007fffad4a713d
    frame #22: 0x0000555559a6a49e bun-debug`vmEntryToJavaScript + 213
    frame #23: 0x00005555590b1cab bun-debug`JSC::Interpreter::executeCall(JSC::JSObject*, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) + 667
    frame #24: 0x0000555559453bce bun-debug`JSC::profiledCall(JSC::JSGlobalObject*, JSC::ProfilingReason, JSC::JSValue, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) + 174
    frame #25: 0x0000555558ff6970 bun-debug`JSC::runJSMicrotask(JSC::JSGlobalObject*, WTF::ObjectIdentifierGeneric<JSC::MicrotaskIdentifierType, WTF::ObjectIdentifierThreadSafeAccessTraits>, JSC::JSValue, JSC::JSValue, JSC::JSValue, JSC::JSValue, JSC::JSValue) + 320
    frame #26: 0x0000555559160997 bun-debug`JSC::VM::drainMicrotasks() + 551
    frame #27: 0x0000555559c31e19 bun-debug`JSC::DeferredWorkTimer::doWork(JSC::VM&) + 1433
    frame #28: 0x000055555b9453b1 bun-debug`src.bun.js.bindings.bindings.VM.doWork at shimmer.zig:186:41
    frame #29: 0x000055555b9453a3 bun-debug`src.bun.js.bindings.bindings.VM.doWork(vm=0x00007fffac000000) at bindings.zig:4649:21
    frame #30: 0x000055555b1933a5 bun-debug`src.bun.js.event_loop.EventLoop.tick(this=0x0000020000100100) at event_loop.zig:614:32
    frame #31: 0x000055555b959510 bun-debug`src.bun.js.event_loop.EventLoop.waitForPromise(this=0x0000020000100100, promise=src.bun.js.bindings.bindings.AnyPromise @ 0x00007fffffff25e8) at event_loop.zig:647:30
    frame #32: 0x000055555b1bcb5c bun-debug`src.bun.js.javascript.VirtualMachine.waitForPromise(this=0x0000020000100000, promise=<unavailable>) at javascript.zig:632:40
    frame #33: 0x000055555b1bcfd9 bun-debug`src.bun.js.javascript.VirtualMachine.loadEntryPoint(this=0x0000020000100000, entry_path=(ptr = "/root/code/p/unit-assistant/index.ts", len = 36)) at javascript.zig:1582:32
    frame #34: 0x000055555b1bd291 bun-debug`src.bun_js.Run.start(this=0x000055555e8e09f8) at bun_js.zig:136:35
    frame #35: 0x000055555b1bed29 bun-debug`src.bun.js.javascript.OpaqueWrap__anon_83600__struct_149344.callback(ctx=0x000055555e8e09f8) at javascript.zig:121:13
    frame #36: 0x000055555a5a3365 bun-debug`::JSC__VM__holdAPILock(arg0=<unavailable>, ctx=0x000055555e8e09f8, callback=(bun-debug`src.bun.js.javascript.OpaqueWrap__anon_83600__struct_149344.callback at javascript.zig:119))(void *)) at bindings.cpp:3491:5
    frame #37: 0x000055555ab6f439 bun-debug`src.bun.js.bindings.bindings.VM.holdAPILock at shimmer.zig:186:41
    frame #38: 0x000055555ab6f423 bun-debug`src.bun.js.bindings.bindings.VM.holdAPILock(this=0x00007fffac000000, ctx=0x000055555e8e09f8, callback=0x000055555b1becb0) at bindings.zig:4528:14
    frame #39: 0x000055555ab6f336 bun-debug`src.bun_js.Run.boot(ctx_=<unavailable>, file=(handle = 3), entry_path=(ptr = "/root/code/p/unit-assistant/index.ts", len = 36)) at bun_js.zig:122:35
    frame #40: 0x000055555ab8b17e bun-debug`src.cli.Command.maybeOpenWithBunJS(ctx=0x00007fffffff94e0) at cli.zig:1482:23
    frame #41: 0x000055555ab86555 bun-debug`src.cli.Command.start(allocator=mem.Allocator @ 0x000055555dde9598, log=0x000055555e8e7e68) at cli.zig:1385:47
    frame #42: 0x000055555a6a9e76 bun-debug`src.cli.Cli.start__anon_3677(allocator=mem.Allocator @ 0x000055555dde9598, (null)=<unavailable>, (null)=<unavailable>) at cli.zig:58:22
    frame #43: 0x000055555a6a96cf bun-debug`src.main.main at main.zig:38:26
    frame #44: 0x000055555a6aa4fc bun-debug`main [inlined] start.callMain at start.zig:599:22
    frame #45: 0x000055555a6aa4f7 bun-debug`main [inlined] start.initEventLoopAndCallMain at start.zig:543:5
    frame #46: 0x000055555a6aa4f7 bun-debug`main at start.zig:493:36
    frame #47: 0x000055555a6aa441 bun-debug`main(c_argc=2, c_argv=0x00007fffffffe2a8, c_envp=0x00007fffffffe2c0) at start.zig:508:80
    frame #48: 0x00007ffff7cced90 libc.so.6`__libc_start_call_main(main=(bun-debug`main at start.zig:496), argc=2, argv=0x00007fffffffe2a8) at libc_start_call_main.h:58:16
    frame #49: 0x00007ffff7ccee40 libc.so.6`__libc_start_main_impl(main=(bun-debug`main at start.zig:496), argc=2, argv=0x00007fffffffe2a8, init=<unavailable>, fini=<unavailable>, rtld_fini=<unavailable>, stack_end=0x00007fffffffe298) at libc-start.c:392:3
    frame #50: 0x0000555558bde865 bun-debug`_start + 37
(lldb)

@CGQAQ
Copy link
Contributor Author

CGQAQ commented Apr 26, 2023

@CGQAQ can you try building 2795f0b? I suspect it's an alignment issue

image

Sadly, it didn't work

@CGQAQ
Copy link
Contributor Author

CGQAQ commented Apr 26, 2023

@Jarred-Sumner I have created a repo for this bug, https://github.com/CGQAQ/bun-bug-2732-reproduce

@CGQAQ CGQAQ changed the title 65969 segmentation fault (core dumped) bun run index.ts bug: Get segfaults when using treesitter to load tree-sitter-zig.wasm Apr 26, 2023
@CGQAQ CGQAQ changed the title bug: Get segfaults when using treesitter to load tree-sitter-zig.wasm bug: Got segfaults when using treesitter to load tree-sitter-zig.wasm Apr 26, 2023
@Jarred-Sumner
Copy link
Collaborator

#2763 this might fix it

@CGQAQ
Copy link
Contributor Author

CGQAQ commented Apr 28, 2023

#2763 this might fix it

No, just tried, still segfault
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants