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

Workaround for #9041 #9580

Merged
merged 10 commits into from
Mar 29, 2024
Merged

Workaround for #9041 #9580

merged 10 commits into from
Mar 29, 2024

Conversation

Jarred-Sumner
Copy link
Collaborator

What does this PR do?

Fixes #9041 mostly

However, this uncovers a shell bug @zackradisic

Console is in 'commands' mode, prefix expressions with '?'.
Launching: /Users/jarred/Code/bun/build/bun-debug test /Users/jarred/Code/bun/test/regression/issue/09041.test.ts
Launched process 66738
bun test v1.0.35 (940448d6)

regression/issue/09041.test.ts:
bun test v1.0.35 (940448d6)

09041-fixture.test.js:

Panic: index out of bounds: index 262144, len 196608

bun has crashed :'(

----- bun meta -----
Bun v1.0.35 (940448d6) macOS Silicon 23.4.0
TestCommand: 
Elapsed: 140ms | User: 48ms | Sys: 16ms
RSS: 81.46MB | Peak: 81.46MB | Commit: 34.23MB | Faults: 91
----- bun meta -----

0   0x102fd2220 WTFGetBacktrace
1   ??? Bun__crashReportDumpStackTrace
2   ??? src.report.fatal
3   ??? src.main.panic
4   ??? debug.panicExtra__anon_2532
5   ??? builtin.default_panic
6   ??? src.shell.interpreter.Interpreter.IOWriter.getBufferImpl
7   ??? src.shell.interpreter.Interpreter.IOWriter.getBuffer
8   ??? src.io.PipeWriter.PosixBufferedWriter(src.shell.interpreter.Interpreter.IOWriter,(function 'onWrite'),(function 'onError'),(function 'onClose'),(function 'getBuffer'),null).getBufferInternal
9   ??? src.io.PipeWriter.PosixPipeWriter(src.io.PipeWriter.PosixBufferedWriter(src.shell.interpreter.Interpreter.IOWriter,(function 'onWrite'),(function 'onError'),(function 'onClose'),(function 'getBuffer'),null),(function 'getFd'),(function 'getBufferInternal'),(function '_onWrite'),(function 'registerPoll'),(function '_onError'),(function '_onWritable'),(function 'getFileType')).onPoll
10  ??? src.io.PipeWriter.PosixBufferedWriter(src.shell.interpreter.Interpreter.IOWriter,(function 'onWrite'),(function 'onError'),(function 'onClose'),(function 'getBuffer'),null).write
11  ??? src.shell.interpreter.Interpreter.IOWriter.write
12  ??? src.shell.interpreter.Interpreter.IOWriter.enqueue__anon_392314
13  ??? src.shell.subproc.PipeReader.CapturedWriter.doWrite
14  ??? src.shell.subproc.PipeReader.onReadChunk
15  ??? src.io.PipeReader.BufferedReaderVTable.onReadChunk
16  ??? src.io.PipeReader.PosixPipeReader(src.io.PipeReader.PosixBufferedReader,.{.getFd = (function 'getFd'), .getBuffer = (function 'buffer'), .getFileType = (function 'getFileType'), .onReadChunk = (function '_onReadChunk'), .registerPoll = (function 'registerPoll'), .done = (function 'done'), .close = (function 'closeWithoutReporting'), .onError = (function 'onError')}).readWithFn__anon_301858
17  ??? src.io.PipeReader.PosixPipeReader(src.io.PipeReader.PosixBufferedReader,.{.getFd = (function 'getFd'), .getBuffer = (function 'buffer'), .getFileType = (function 'getFileType'), .onReadChunk = (function '_onReadChunk'), .registerPoll = (function 'registerPoll'), .done = (function 'done'), .close = (function 'closeWithoutReporting'), .onError = (function 'onError')}).readSocket
18  ??? src.io.PipeReader.PosixPipeReader(src.io.PipeReader.PosixBufferedReader,.{.getFd = (function 'getFd'), .getBuffer = (function 'buffer'), .getFileType = (function 'getFileType'), .onReadChunk = (function '_onReadChunk'), .registerPoll = (function 'registerPoll'), .done = (function 'done'), .close = (function 'closeWithoutReporting'), .onError = (function 'onError')}).onPoll
19  ??? posix_event_loop.FilePoll.onUpdate
20  ??? posix_event_loop.FilePoll.onKQueueEvent
21  ??? Bun__internal_dispatch_ready_poll
22  ??? us_loop_run_bun_tick
23  ??? src.deps.uws.PosixLoop.tick
24  ??? src.bun.js.event_loop.EventLoop.autoTick
25  ??? src.cli.test_command.TestCommand.run
26  ??? src.cli.test_command.TestCommand.runAllTests.Context.begin
27  ??? src.bun.js.javascript.OpaqueWrap__anon_111514__struct_143460.callback
28  ??? JSC__VM__holdAPILock
29  ??? src.bun.js.bindings.bindings.VM.holdAPILock
30  ??? src.cli.test_command.TestCommand.runAllTests
31  ??? src.cli.test_command.TestCommand.exec

Crash report saved to:
  ~/.bun/.bun-crash/v1.0.35-debug-1711173119582.crash

Search GitHub issues https://bun.sh/issues or ask for #help in https://bun.sh/discord

thread 39597743 panic: index out of bounds: index 262144, len 196608
/Users/jarred/Code/bun/src/shell/interpreter.zig:9112:34: 0x10044aad7 in getBufferImpl (bun-zig)
            return this.buf.items[this.total_bytes_written .. this.total_bytes_written + remaining];
                                 ^
/Users/jarred/Code/bun/src/shell/interpreter.zig:9085:46: 0x10044a163 in getBuffer (bun-zig)
            const result = this.getBufferImpl();
                                             ^
/Users/jarred/Code/bun/src/io/PipeWriter.zig:293:29: 0x100e20c33 in getBufferInternal (bun-zig)
            return getBuffer(this.parent);
                            ^
/Users/jarred/Code/bun/src/io/PipeWriter.zig:97:37: 0x1008e55eb in onPoll (bun-zig)
            const buffer = getBuffer(parent);
                                    ^
/Users/jarred/Code/bun/src/io/PipeWriter.zig:337:24: 0x100447ffb in write (bun-zig)
            this.onPoll(0, false);
                       ^
/Users/jarred/Code/bun/src/shell/interpreter.zig:8948:38: 0x1017ae51b in write (bun-zig)
                    this.writer.write();
                                     ^
/Users/jarred/Code/bun/src/shell/interpreter.zig:9172:23: 0x1025d150b in enqueue__anon_392314 (bun-zig)
            this.write();
                      ^
/Users/jarred/Code/bun/src/shell/subproc.zig:1045:32: 0x1025cb753 in doWrite (bun-zig)
            this.writer.enqueue(this, null, chunk);
                               ^
/Users/jarred/Code/bun/src/shell/subproc.zig:1188:37: 0x1025b790b in onReadChunk (bun-zig)
        this.captured_writer.doWrite(chunk);
                                    ^
/Users/jarred/Code/bun/src/io/PipeReader.zig:615:38: 0x10060e85f in onReadChunk (bun-zig)
        return this.fns.onReadChunk.?(this.parent, chunk, hasMore);
                                     ^
/Users/jarred/Code/bun/src/io/PipeReader.zig:176:71: 0x101c04a47 in readWithFn__anon_301858 (bun-zig)
                                        if (!parent.vtable.onReadChunk(stack_buffer[0 .. stack_buffer.len - stack_buffer_head.len], if (received_hup) .eof else .progress)) {
                                                                      ^
/Users/jarred/Code/bun/src/io/PipeReader.zig:97:30: 0x10178fc3b in readSocket (bun-zig)
            return readWithFn(parent, resizable_buffer, fd, size_hint, received_hup, .socket, bun.sys.recvNonBlock);
                             ^
/Users/jarred/Code/bun/src/io/PipeReader.zig:72:31: 0x1012cdbfb in onPoll (bun-zig)
                    readSocket(parent, resizable_buffer, fd, size_hint, received_hup);
                              ^
/Users/jarred/Code/bun/src/async/posix_event_loop.zig:389:31: 0x100e19693 in onUpdate (bun-zig)
                handler.onPoll(size_or_offset, poll.flags.contains(.hup));
                              ^
/Users/jarred/Code/bun/src/async/posix_event_loop.zig:237:22: 0x1008dd4a3 in onKQueueEvent (bun-zig)
        poll.onUpdate(kqueue_event.data);
                     ^
/Users/jarred/Code/bun/src/async/posix_event_loop.zig:765:26: 0x1008dd3b3 in onTick (bun-zig)
            onKQueueEvent(file_poll, loop, &loop.ready_polls[@as(usize, @intCast(loop.current_ready_poll))])
                         ^
/Users/jarred/Code/bun/packages/bun-usockets/src/eventing/epoll_kqueue.c:223:17: 0x102c4fc83 in us_loop_run_bun_tick (/Users/jarred/Code/bun/packages/bun-usockets/src/eventing/epoll_kqueue.c)
                Bun__internal_dispatch_ready_poll(loop, poll);
                ^
/Users/jarred/Code/bun/src/deps/uws.zig:1041:29: 0x10069c0c3 in tick (bun-zig)
        us_loop_run_bun_tick(this, 0);
                            ^
/Users/jarred/Code/bun/src/bun.js/event_loop.zig:1286:22: 0x1009b1d8f in autoTick (bun-zig)
            loop.tick();
                     ^
/Users/jarred/Code/bun/src/cli/test_command.zig:1089:48: 0x10142cb27 in run (bun-zig)
                        vm.eventLoop().autoTick();
                                               ^
/Users/jarred/Code/bun/src/cli/test_command.zig:981:32: 0x100f8351b in begin (bun-zig)
                TestCommand.run(reporter, vm, files[files.len - 1].slice(), allocator, true) catch {};
                               ^
/Users/jarred/Code/bun/src/bun.js/javascript.zig:105:21: 0x100abb74b in callback (bun-zig)
            Function(context);
                    ^
/Users/jarred/Code/bun/src/bun.js/bindings/bindings.cpp:4639:5: 0x10288e6e3 in JSC__VM__holdAPILock (/Users/jarred/Code/bun/src/bun.js/bindings/bindings.cpp)
    callback(ctx);
    ^
/Users/jarred/Code/bun/src/bun.js/bindings/shimmer.zig:186:41: 0x1000bf583 in holdAPILock (bun-zig)
                    return matchNullable(
                                        ^
/Users/jarred/Code/bun/src/bun.js/javascript.zig:2409:37: 0x1003c810b in runAllTests (bun-zig)
        this.global.vm().holdAPILock(ctx, OpaqueWrap(Context, function));
                                    ^
/Users/jarred/Code/bun/src/cli/test_command.zig:771:24: 0x1003c4aa3 in exec (bun-zig)
            runAllTests(reporter, vm, test_files, ctx.allocator);
                       ^
/Users/jarred/Code/bun/src/cli.zig:1477:37: 0x100413927 in start (bun-zig)
                try TestCommand.exec(ctx);
                                    ^
/Users/jarred/Code/bun/src/cli.zig:57:22: 0x1000057a3 in start__anon_4173 (bun-zig)
        Command.start(allocator, log) catch |err| {
                     ^
/Users/jarred/Code/bun/src/main.zig:121:22: 0x10000252b in main (bun-zig)
    bun.CLI.Cli.start(bun.default_allocator, MainPanicHandler);
                     ^
/Users/jarred/Code/bun/.cache/zig/lib/std/start.zig:575:22: 0x10000222f in main (bun-zig)
            root.main();
                     ^
???:?:?: 0x18e3e20df in ??? (???)
???:?:?: 0x8d3a7fffffffffff in ??? (???)
15 |     cwd: out,
16 |     env: bunEnv,
17 |     stdio: ["ignore", "pipe", "inherit"],
18 |   });
19 | 
20 |   expect(await exited).toBe(0);
       ^
error expect(received).toBe(expected)

Expected: 0
Received: 134

      at /Users/jarred/Code/bun/test/regression/issue/09041.test.ts203
      at asyncFunctionResume (121)
      at promiseReactionJobWithoutPromiseUnwrapAsyncContext (121)
      at promiseReactionJob (121)
 09041 [5959.49ms]

 0 pass
 1 fail
 1 expect() calls
Ran 1 tests across 1 files. [6.02s]
Process exited with code 1.

How did you verify your code works?

There is a test

Copy link
Contributor

github-actions bot commented Mar 23, 2024

❌🪟 @Jarred-Sumner, there are 9 test regressions on Windows x86_64

  • test\cli\install\bun-run-bunfig.test.ts
  • test\cli\install\bunx.test.ts
  • test\cli\install\registry\bun-install-registry.test.ts
  • test\js\bun\console\console-iterator.test.ts
  • test\js\node\dns\node-dns.test.js
  • test\js\node\stream\node-stream.test.js
  • test\js\web\fetch\body-stream.test.ts
  • test\regression\issue\09041.test.ts
  • test\js\third_party\postgres\postgres.test.ts

Full Test Output

Copy link
Contributor

github-actions bot commented Mar 23, 2024

Copy link
Contributor

@jdalton jdalton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very cool regression test (the running in node/bun) bit.

@Jarred-Sumner Jarred-Sumner merged commit 31befad into main Mar 29, 2024
26 of 31 checks passed
@Jarred-Sumner Jarred-Sumner deleted the jarred/spawn-oob branch March 29, 2024 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[stdio] Bun hangs reading from stdin pipeline at >= 16384 Bytes (16KiB)
2 participants