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

Process freezed after upgrade from 1.1.33 to 1.1.34 #14982

Closed
esciullo opened this issue Nov 4, 2024 · 6 comments
Closed

Process freezed after upgrade from 1.1.33 to 1.1.34 #14982

esciullo opened this issue Nov 4, 2024 · 6 comments
Labels
bug Something isn't working confirmed bug We can reproduce this issue linux An issue that occurs on Linux

Comments

@esciullo
Copy link

esciullo commented Nov 4, 2024

What version of Bun is running?

1.1.34+5e5e7c60f

What platform is your computer?

Linux 5.15.153.1-microsoft-standard-WSL2 x86_64 x86_64

What steps can reproduce the bug?

Use the following index.ts and test-test.ts files and run bun index.ts test

index.ts

import { program } from "commander";

program.name("test").command("test", "Test command").parse();

test-test.ts

import { Command } from "commander";

new Command("test")
  .action(() => {
    console.log("Test command");
    process.exit(0);
  })
  .parse();

What is the expected behavior?

The process exit successfully.

What do you see instead?

The process remains freezed.

Additional information

The same code works fine with bun 1.1.33

@esciullo esciullo added bug Something isn't working needs triage labels Nov 4, 2024
@190n 190n added linux An issue that occurs on Linux confirmed bug We can reproduce this issue and removed needs triage labels Nov 4, 2024
@Jarred-Sumner
Copy link
Collaborator

Reproduces on Linux. Does not reproduce on macOS.

@Jarred-Sumner
Copy link
Collaborator

It is a tick without idle infinite loop.

Leaving a systrace open for more than a minute produces 350 MB of sched_yield() logs.

@Jarred-Sumner
Copy link
Collaborator

main thread:

___lldb_unnamed_symbol3635 (@___lldb_unnamed_symbol3635:56)
pthread_cond_wait (@pthread_cond_wait:150)
WTF::ThreadCondition::wait(WTF::Mutex&) (@WTF::ThreadCondition::wait(WTF::Mutex&):15)
WTF::ThreadCondition::timedWait(WTF::Mutex&, WTF::WallTime) (@WTF::ThreadCondition::timedWait(WTF::Mutex&, WTF::WallTime):36)
WTF::ParkingLot::parkConditionallyImpl(void const*, WTF::ScopedLambda<bool ()> const&, WTF::ScopedLambda<void ()> const&, WTF::TimeWithDynamicClockType const&) (@WTF::ParkingLot::parkConditionallyImpl(void const*, WTF::ScopedLambda<bool ()> const&, WTF::ScopedLambda<void ()> const&, WTF::TimeWithDynamicClockType const&):95)
WTF::ParkingLot::ParkResult WTF::ParkingLot::parkConditionally<WTF::ParkingLot::ParkResult WTF::ParkingLot::compareAndPark<unsigned int, unsigned int>(WTF::Atomic<unsigned int> const*, unsigned int)::'lambda'(), WTF::ParkingLot::ParkResult WTF::ParkingLot::compareAndPark<unsigned int, unsigned int>(WTF::Atomic<unsigned int> const*, unsigned int)::'lambda0'()>(void const*, unsigned int const&, unsigned int const&, WTF::TimeWithDynamicClockType const&) (@WTF::ParkingLot::ParkResult WTF::ParkingLot::parkConditionally<WTF::ParkingLot::ParkResult WTF::ParkingLot::compareAndPark<unsigned int, unsigned int>(WTF::Atomic<unsigned int> const*, unsigned int)::'lambda'(), WTF::ParkingLot::ParkResult WTF::ParkingLot::compareAndPark<unsigned int, unsigned int>(WTF::Atomic<unsigned int> const*, unsigned int)::'lambda0'()>(void const*, unsigned int const&, unsigned int const&, WTF::TimeWithDynamicClockType const&):25)
WTF::ParkingLot::ParkResult WTF::ParkingLot::compareAndPark<unsigned int, unsigned int>(WTF::Atomic<unsigned int> const*, unsigned int) (@WTF::ParkingLot::ParkResult WTF::ParkingLot::compareAndPark<unsigned int, unsigned int>(WTF::Atomic<unsigned int> const*, unsigned int):24)
JSC::Heap::acquireAccessSlow() (@JSC::Heap::acquireAccessSlow():48)
JSC::Heap::acquireAccess() (/root/bun/build/debug/cache/webkit-9b84f43643eff64ab46daec9b860de262c80f5e2/include/JavaScriptCore/HeapInlines.h:238)
::Bun__JSC_onAfterWait(JSC::VM *) (/root/bun/src/bun.js/bindings/BunJSCEventLoop.cpp:17)
us_loop_run_bun_tick (/root/bun/packages/bun-usockets/src/eventing/epoll_kqueue.c:272)
src.deps.uws.PosixLoop.tickWithTimeout (/root/bun/src/deps/uws.zig:2452)
src.bun.js.event_loop.EventLoop.autoTickActive (/root/bun/src/bun.js/event_loop.zig:1466)
src.bun_js.Run.start (/root/bun/src/bun_js.zig:409)
src.bun.js.javascript.OpaqueWrap__anon_65451__struct_99884.callback (/root/bun/src/bun.js/javascript.zig:107)
::JSC__VM__holdAPILock(JSC__VM *, void *, void (*)(void *)) (/root/bun/src/bun.js/bindings/bindings.cpp:4858)
src.bun.js.bindings.shimmer.Shimmer("JSC"[0..3],"VM"[0..2],src.bun.js.bindings.bindings.VM).cppFn (/root/bun/src/bun.js/bindings/shimmer.zig:197)
src.bun.js.bindings.bindings.VM.holdAPILock (/root/bun/src/bun.js/bindings/bindings.zig:6198)
src.bun_js.Run.boot (/root/bun/src/bun_js.zig:276)
src.cli.Command.maybeOpenWithBunJS (/root/bun/src/cli.zig:2274)

Collector thread:

___lldb_unnamed_symbol3635 (@___lldb_unnamed_symbol3635:56)
___lldb_unnamed_symbol3698 (@___lldb_unnamed_symbol3698:46)
WTF::Semaphore::wait() (@WTF::Semaphore::wait():9)
WTF::Thread::suspend(WTF::ThreadSuspendLocker const&) (@WTF::Thread::suspend(WTF::ThreadSuspendLocker const&):65)
JSC::MachineThreads::tryCopyOtherThreadStacks(WTF::AbstractLocker const&, void*, unsigned long, unsigned long*, WTF::Thread&) (@JSC::MachineThreads::tryCopyOtherThreadStacks(WTF::AbstractLocker const&, void*, unsigned long, unsigned long*, WTF::Thread&):72)
JSC::MachineThreads::gatherConservativeRoots(JSC::ConservativeRoots&, JSC::JITStubRoutineSet&, JSC::CodeBlockSet&, JSC::CurrentThreadState*, WTF::Thread*) (@JSC::MachineThreads::gatherConservativeRoots(JSC::ConservativeRoots&, JSC::JITStubRoutineSet&, JSC::CodeBlockSet&, JSC::CurrentThreadState*, WTF::Thread*):38)
JSC::Heap::gatherStackRoots(JSC::ConservativeRoots&) (@JSC::Heap::gatherStackRoots(JSC::ConservativeRoots&):30)
_ZZN3JSC4Heap18addCoreConstraintsEvEN3$_1clINS_11SlotVisitorEEEDaRT_ (@_ZZN3JSC4Heap18addCoreConstraintsEvEN3$_1clINS_11SlotVisitorEEEDaRT_:76)
WTF::Detail::CallableWrapper<JSC::Heap::addCoreConstraints()::$_1, void, JSC::SlotVisitor&>::call(JSC::SlotVisitor&) (@WTF::Detail::CallableWrapper<JSC::Heap::addCoreConstraints()::$_1, void, JSC::SlotVisitor&>::call(JSC::SlotVisitor&):12)
WTF::Function<void (JSC::SlotVisitor&)>::operator()(JSC::SlotVisitor&) const (@WTF::Function<void (JSC::SlotVisitor&)>::operator()(JSC::SlotVisitor&) const:39)
JSC::MarkingConstraintExecutorPair::execute(JSC::SlotVisitor&) (@JSC::MarkingConstraintExecutorPair::execute(JSC::SlotVisitor&):12)
void JSC::SimpleMarkingConstraint::executeImplImpl<JSC::SlotVisitor>(JSC::SlotVisitor&) (@void JSC::SimpleMarkingConstraint::executeImplImpl<JSC::SlotVisitor>(JSC::SlotVisitor&):12)
JSC::SimpleMarkingConstraint::executeImpl(JSC::SlotVisitor&) (@JSC::SimpleMarkingConstraint::executeImpl(JSC::SlotVisitor&):11)
JSC::MarkingConstraint::execute(JSC::SlotVisitor&) (@JSC::MarkingConstraint::execute(JSC::SlotVisitor&):43)
JSC::MarkingConstraintSolver::runExecutionThread(JSC::SlotVisitor&, JSC::MarkingConstraintSolver::SchedulerPreference, WTF::ScopedLambda<std::optional<unsigned int> ()>) (@JSC::MarkingConstraintSolver::runExecutionThread(JSC::SlotVisitor&, JSC::MarkingConstraintSolver::SchedulerPreference, WTF::ScopedLambda<std::optional<unsigned int> ()>):110)
JSC::MarkingConstraintSolver::execute(JSC::MarkingConstraintSolver::SchedulerPreference, WTF::ScopedLambda<std::optional<unsigned int> ()>)::$_0::operator()(JSC::SlotVisitor&) const (@JSC::MarkingConstraintSolver::execute(JSC::MarkingConstraintSolver::SchedulerPreference, WTF::ScopedLambda<std::optional<unsigned int> ()>)::$_0::operator()(JSC::SlotVisitor&) const:21)
WTF::SharedTaskFunctor<void (JSC::SlotVisitor&), JSC::MarkingConstraintSolver::execute(JSC::MarkingConstraintSolver::SchedulerPreference, WTF::ScopedLambda<std::optional<unsigned int> ()>)::$_0>::run(JSC::SlotVisitor&) (@WTF::SharedTaskFunctor<void (JSC::SlotVisitor&), JSC::MarkingConstraintSolver::execute(JSC::MarkingConstraintSolver::SchedulerPreference, WTF::ScopedLambda<std::optional<unsigned int> ()>)::$_0>::run(JSC::SlotVisitor&):12)
JSC::Heap::runTaskInParallel(WTF::RefPtr<WTF::SharedTask<void (JSC::SlotVisitor&)>, WTF::RawPtrTraits<WTF::SharedTask<void (JSC::SlotVisitor&)>>, WTF::DefaultRefDerefTraits<WTF::SharedTask<void (JSC::SlotVisitor&)>>>) (@JSC::Heap::runTaskInParallel(WTF::RefPtr<WTF::SharedTask<void (JSC::SlotVisitor&)>, WTF::RawPtrTraits<WTF::SharedTask<void (JSC::SlotVisitor&)>>, WTF::DefaultRefDerefTraits<WTF::SharedTask<void (JSC::SlotVisitor&)>>>):36)
void JSC::Heap::runFunctionInParallel<JSC::MarkingConstraintSolver::execute(JSC::MarkingConstraintSolver::SchedulerPreference, WTF::ScopedLambda<std::optional<unsigned int> ()>)::$_0>(JSC::MarkingConstraintSolver::execute(JSC::MarkingConstraintSolver::SchedulerPreference, WTF::ScopedLambda<std::optional<unsigned int> ()>)::$_0 const&) (@void JSC::Heap::runFunctionInParallel<JSC::MarkingConstraintSolver::execute(JSC::MarkingConstraintSolver::SchedulerPreference, WTF::ScopedLambda<std::optional<unsigned int> ()>)::$_0>(JSC::MarkingConstraintSolver::execute(JSC::MarkingConstraintSolver::SchedulerPreference, WTF::ScopedLambda<std::optional<unsigned int> ()>)::$_0 const&):19)
JSC::MarkingConstraintSolver::execute(JSC::MarkingConstraintSolver::SchedulerPreference, WTF::ScopedLambda<std::optional<unsigned int> ()>) (@JSC::MarkingConstraintSolver::execute(JSC::MarkingConstraintSolver::SchedulerPreference, WTF::ScopedLambda<std::optional<unsigned int> ()>):71)

Several HeapHelper threads that look like this:

___lldb_unnamed_symbol3635 (@___lldb_unnamed_symbol3635:56)
pthread_cond_wait (@pthread_cond_wait:150)
WTF::ThreadCondition::wait(WTF::Mutex&) (@WTF::ThreadCondition::wait(WTF::Mutex&):15)
WTF::ThreadCondition::timedWait(WTF::Mutex&, WTF::WallTime) (@WTF::ThreadCondition::timedWait(WTF::Mutex&, WTF::WallTime):36)
WTF::ParkingLot::parkConditionallyImpl(void const*, WTF::ScopedLambda<bool ()> const&, WTF::ScopedLambda<void ()> const&, WTF::TimeWithDynamicClockType const&) (@WTF::ParkingLot::parkConditionallyImpl(void const*, WTF::ScopedLambda<bool ()> const&, WTF::ScopedLambda<void ()> const&, WTF::TimeWithDynamicClockType const&):95)
WTF::ParkingLot::ParkResult WTF::ParkingLot::parkConditionally<bool WTF::Condition::waitUntilUnchecked<WTF::Lock>(WTF::Lock&, WTF::TimeWithDynamicClockType const&)::'lambda'(), bool WTF::Condition::waitUntilUnchecked<WTF::Lock>(WTF::Lock&, WTF::TimeWithDynamicClockType const&)::'lambda0'()>(void const*, WTF::Lock const&, bool WTF::Condition::waitUntilUnchecked<WTF::Lock>(WTF::Lock&, WTF::TimeWithDynamicClockType const&)::'lambda0'() const&, WTF::TimeWithDynamicClockType const&) (@WTF::ParkingLot::ParkResult WTF::ParkingLot::parkConditionally<bool WTF::Condition::waitUntilUnchecked<WTF::Lock>(WTF::Lock&, WTF::TimeWithDynamicClockType const&)::'lambda'(), bool WTF::Condition::waitUntilUnchecked<WTF::Lock>(WTF::Lock&, WTF::TimeWithDynamicClockType const&)::'lambda0'()>(void const*, WTF::Lock const&, bool WTF::Condition::waitUntilUnchecked<WTF::Lock>(WTF::Lock&, WTF::TimeWithDynamicClockType const&)::'lambda0'() const&, WTF::TimeWithDynamicClockType const&):25)
bool WTF::Condition::waitUntilUnchecked<WTF::Lock>(WTF::Lock&, WTF::TimeWithDynamicClockType const&) (@bool WTF::Condition::waitUntilUnchecked<WTF::Lock>(WTF::Lock&, WTF::TimeWithDynamicClockType const&):35)
WTF::Condition::waitUntil(WTF::Lock&, WTF::TimeWithDynamicClockType const&) (@WTF::Condition::waitUntil(WTF::Lock&, WTF::TimeWithDynamicClockType const&):13)
bool WTF::Condition::waitUntilUnchecked<WTF::Lock, JSC::SlotVisitor::drainFromShared(JSC::SlotVisitor::SharedDrainMode, WTF::MonotonicTime)::$_0>(WTF::Lock&, WTF::TimeWithDynamicClockType const&, JSC::SlotVisitor::drainFromShared(JSC::SlotVisitor::SharedDrainMode, WTF::MonotonicTime)::$_0 const&) (@bool WTF::Condition::waitUntilUnchecked<WTF::Lock, JSC::SlotVisitor::drainFromShared(JSC::SlotVisitor::SharedDrainMode, WTF::MonotonicTime)::$_0>(WTF::Lock&, WTF::TimeWithDynamicClockType const&, JSC::SlotVisitor::drainFromShared(JSC::SlotVisitor::SharedDrainMode, WTF::MonotonicTime)::$_0 const&):22)
bool WTF::Condition::waitUntil<JSC::SlotVisitor::drainFromShared(JSC::SlotVisitor::SharedDrainMode, WTF::MonotonicTime)::$_0>(WTF::Lock&, WTF::TimeWithDynamicClockType const&, JSC::SlotVisitor::drainFromShared(JSC::SlotVisitor::SharedDrainMode, WTF::MonotonicTime)::$_0 const&) (@bool WTF::Condition::waitUntil<JSC::SlotVisitor::drainFromShared(JSC::SlotVisitor::SharedDrainMode, WTF::MonotonicTime)::$_0>(WTF::Lock&, WTF::TimeWithDynamicClockType const&, JSC::SlotVisitor::drainFromShared(JSC::SlotVisitor::SharedDrainMode, WTF::MonotonicTime)::$_0 const&):15)
JSC::SlotVisitor::drainFromShared(JSC::SlotVisitor::SharedDrainMode, WTF::MonotonicTime) (@JSC::SlotVisitor::drainFromShared(JSC::SlotVisitor::SharedDrainMode, WTF::MonotonicTime):209)
JSC::Heap::runBeginPhase(JSC::GCConductor)::$_1::operator()() const (@JSC::Heap::runBeginPhase(JSC::GCConductor)::$_1::operator()() const:54)
WTF::SharedTaskFunctor<void (), JSC::Heap::runBeginPhase(JSC::GCConductor)::$_1>::run() (@WTF::SharedTaskFunctor<void (), JSC::Heap::runBeginPhase(JSC::GCConductor)::$_1>::run():10)
WTF::ParallelHelperClient::runTask(WTF::RefPtr<WTF::SharedTask<void ()>, WTF::RawPtrTraits<WTF::SharedTask<void ()>>, WTF::DefaultRefDerefTraits<WTF::SharedTask<void ()>>> const&) (@WTF::ParallelHelperClient::runTask(WTF::RefPtr<WTF::SharedTask<void ()>, WTF::RawPtrTraits<WTF::SharedTask<void ()>>, WTF::DefaultRefDerefTraits<WTF::SharedTask<void ()>>> const&):62)
WTF::ParallelHelperPool::Thread::work() (@WTF::ParallelHelperPool::Thread::work():12)
WTF::AutomaticThread::start(WTF::AbstractLocker const&)::$_0::operator()() const (@WTF::AutomaticThread::start(WTF::AbstractLocker const&)::$_0::operator()() const:156)
WTF::Detail::CallableWrapper<WTF::AutomaticThread::start(WTF::AbstractLocker const&)::$_0, void>::call() (@WTF::Detail::CallableWrapper<WTF::AutomaticThread::start(WTF::AbstractLocker const&)::$_0, void>::call():10)
WTF::Function<void ()>::operator()() const (/root/bun/build/debug/cache/webkit-9b84f43643eff64ab46daec9b860de262c80f5e2/include/wtf/Function.h:82)
WTF::Thread::entryPoint(WTF::Thread::NewThreadContext*) (@WTF::Thread::entryPoint(WTF::Thread::NewThreadContext*):105)
WTF::wtfThreadEntryPoint(void*) (@WTF::wtfThreadEntryPoint(void*):9)

Scavenger thread:

__sched_yield (@__sched_yield:6)
pas_lock_lock_slow (@pas_lock_lock_slow:48)
pas_lock_lock (@pas_lock_lock:17)
pas_thread_suspend_lock_lock (@pas_thread_suspend_lock_lock:7)
pas_thread_local_cache_for_all (@pas_thread_local_cache_for_all:15)
scavenger_thread_main (@scavenger_thread_main:69)
___lldb_unnamed_symbol3666 (@___lldb_unnamed_symbol3666:202)
___lldb_unnamed_symbol4097 (@___lldb_unnamed_symbol4097:6)

@Jarred-Sumner
Copy link
Collaborator

Commenting out the code that calls vm.heap.collectAsync() seems to work around the issue, though that is very likely to increase memory usage much more than we want.

Jarred-Sumner added a commit that referenced this issue Nov 5, 2024
@Jarred-Sumner
Copy link
Collaborator

The fix for this will be included in Bun v1.1.35

We reverted the memory reduction, which caused this issue. There is a better fix that will further reduce memory usage, and stop this from happening but it will take more work to implement it correctly.

@domenkozar
Copy link

@Jarred-Sumner any chance to get release out? This is blocking all macOS users in nixpkgs. cachix/devenv-nixpkgs#9

190n added a commit that referenced this issue Nov 22, 2024
190n added a commit that referenced this issue Nov 22, 2024
190n added a commit that referenced this issue Dec 2, 2024
190n added a commit that referenced this issue Dec 2, 2024
190n added a commit that referenced this issue Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working confirmed bug We can reproduce this issue linux An issue that occurs on Linux
Projects
None yet
Development

No branches or pull requests

4 participants