Repository navigation
Conversation
The pooled V8 engines were disposed by an unawaited FreeMemory task on a thread pool thread while Main was returning. Even after engine disposal, ClearScript runs V8 background tasks (pooled page release) on the .NET thread pool, and exit() runs ClearScriptV8 native static destructors under them. - Await FreeMemory before RunBuild/RunTest return - Always release the type checker, so waiting for FreeMemory cannot hang - Dispose the CssProcessor created by NjsastBundleBundler - On Unix, end bb with _exit from the last ProcessExit handler Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
BbCliE2ETests.BuildCommandsWorkForProjectUsingBobrilG11nfailed now and then withCommand failed with exit code 139(for example in run 43428941512, attempt 1, on both ubuntu and macos). Each time the bb output ended with "Build done ... with no errors".Cause
I reproduced it locally on macOS arm64 by looping
bb build -f 1/bb buildon the fixture with all CPUs busy: 1 crash in 120 runs. The macOS crash report shows the main thread inexit()and a.NET TP Workerfaulting insideClearScriptV8.osx-arm64.dylib, in V8 heap code (pooled pages)._compilerPool.FreeMemory().GetAwaiter()starts FreeMemory and never waits for it. FreeMemory resumes on a thread-pool thread as soon as the background type check returns its compiler, then disposes the V8 engines whileMainis returning.exit()runs the native C++ static destructors underneath them.Fix
RunBuildandRunTestwait for FreeMemory before they return.finally), so waiting for FreeMemory cannot hang.CssProcessorthatNjsastBundleBundlercreates is now disposed.bbregisters a finalProcessExithandler that flushes the console and calls libc_exit(Environment.ExitCode). The otherProcessExithandlers (browser and watch process cleanup) were registered earlier, so they still run.Verification
dotnet test bbcore.slnpasses locally.Bbcore.Libbuilds.🤖 Generated with Claude Code