Repository navigation
fix: do not crash in headless mode before the package is loaded (#8392) - #170
Closed
nigelgutzmann wants to merge 1 commit into
Closed
nigelgutzmann wants to merge 1 commit into
nigelgutzmann wants to merge 1 commit into
Conversation
Since Chromium 151, headless startup on Linux and macOS calls chrome::GetDefaultUserDataDirectory() from ChromeMain(), when no --user-data-dir is given, to place its temporary profile. That runs before ChromeMainDelegate::BasicStartupComplete() calls nw::InitNWPackage(), so nw::package() is still null and the patched path functions crashed dereferencing it. Fall back to "nwjs", the default Package::GetName() name, when the package is not loaded yet, as the Windows version already does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks for your contribution! Unfortunately, we don't use GitHub pull requests to manage code contributions to this repository. Instead, please see README.md which provides full instructions on how to get involved. |
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.
Fixes nwjs/nw.js#8392.
Since NW.js 0.114.0 (Chromium 151), launching any app with
--headless/--headless=newsegfaults on startup on Linux and macOS unless--user-data-diris passed.Root cause
ChromeMain()callsheadless::InitHeadlessMode()beforecontent::ContentMain()(chrome/app/chrome_main.cc).CreateUniqueUserDataDir()inchrome/browser/headless/headless_mode_init.cccallschrome::GetDefaultUserDataDirectory()on non-Windows platforms when no--user-data-diris given, to place the temporary profile under<default>-headless/. Chromium 150 just calledCreateUniqueTempDir().GetDefaultUserDataDirectory()inchrome_paths_linux.ccandchrome_paths_mac.mmcallnw::package()->GetName().nw::package()is stillnullptrat that point. It's only created bynw::InitNWPackage()inChromeMainDelegate::BasicStartupComplete(), which runs insideContentMain(). The crash is the first read through it:SEGV_MAPERRat0x20, i.e.&Package::root_on a nullPackage.Fix
When the package isn't loaded yet, fall back to
"nwjs", the default namePackage::GetName()returns when the manifest has none. The Windows version (chrome_paths_win.cc) already guardsnw::package()for the same reason, from crashpad's early init. Before the package loads, only headless startup calls this function, and it only uses the result as the parent folder for a unique temporary profile, so normal apps keep their profile location.Testing
--headless=newexits with SIGSEGV (139). Adding--user-data-dir=<dir>, which skips step 2, makes both start normally. NW.js 0.113.0 and upstream Chrome for Testing 151 and 156 work on the same Linux machine.nw::Packageis visible throughcontent/nw/src/nw_base.h, which both files already include.