Skip to content

Commit f722886

Browse files
linesightclaude
andcommitted
refactor(linux): drop child-process switch stripping (fixed upstream in CEF 147)
BrowserProcessHandler_OnBeforeChildProcessLaunch stripped --pseudonymization-salt-handle and --change-stack-guard-on-fork from every child command line to avoid CEF 146 subprocess crashes ("Failed global descriptor lookup: 7" on non-zygote utilities; "stack smashing detected" on zygote-forked children). Re-verified on CEF 147: both switches are still added by Chrome to child command lines, but their presence no longer crashes the subprocesses. Tested with the strip disabled across every relevant path — sandbox on (zygote), the unit-test no-zygote/in-process config, and the exact target scenario (--no-zygote with a directly-launched utility subprocess carrying --pseudonymization-salt-handle): no descriptor-lookup failure, no stack-smash, hello_world and the 85 unit tests all pass. Upstream evidently fixed the non-zygote GlobalDescriptors init and the fork-canary handling between 146 and 147. Removes the Linux-only CefCommandLine rewriting from the .pyx binding layer. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent b12cbbc commit f722886

1 file changed

Lines changed: 0 additions & 70 deletions

File tree

src/handlers/browser_process_handler.pyx

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -27,76 +27,6 @@ cdef public void BrowserProcessHandler_OnBeforeChildProcessLaunch(
2727
) noexcept with gil:
2828
try:
2929
AppendSwitchesToCommandLine(cefCommandLine, g_commandLineSwitches)
30-
IF UNAME_SYSNAME == "Linux":
31-
_StripPseudonymizationSaltHandle(cefCommandLine) # strips crash-inducing switches
3230
except:
3331
(exc_type, exc_value, exc_trace) = sys.exc_info()
3432
sys.excepthook(exc_type, exc_value, exc_trace)
35-
36-
37-
IF UNAME_SYSNAME == "Linux":
38-
# Switches that must be stripped from every child-process command line on
39-
# Linux to prevent crashes in CEF 146 subprocesses.
40-
#
41-
# --pseudonymization-salt-handle (Chrome 130+):
42-
# Passed to directly-launched (non-zygote) utility subprocesses,
43-
# expecting GlobalDescriptors[key=7] to already be populated.
44-
# CEF 146 does not perform this GlobalDescriptors initialization for
45-
# the non-zygote path, so the subprocess crashes:
46-
# "Failed global descriptor lookup: 7"
47-
# Removing the switch causes Chrome to use a per-process random salt.
48-
#
49-
# --change-stack-guard-on-fork (Chrome / Linux zygote):
50-
# Tells a Zygote-forked child to randomize its stack canary after fork.
51-
# ChangeStackGuard() is called from inside the Zygote event-loop stack
52-
# frames that the fork() inherited. Those frames have the pre-fork
53-
# canary saved; when they return the canary check fails:
54-
# "*** stack smashing detected ***: terminated"
55-
# The subprocess exits before Chrome's initialization completes, so
56-
# OnContextInitialized never fires. Removing the switch prevents
57-
# ChangeStackGuard() from being called at all; the child keeps the
58-
# Zygote's canary (which is still randomized at Zygote startup).
59-
_STRIP_CHILD_SWITCHES = frozenset([
60-
"pseudonymization-salt-handle",
61-
"change-stack-guard-on-fork",
62-
])
63-
64-
cdef void _StripPseudonymizationSaltHandle(
65-
CefRefPtr[CefCommandLine] cefCommandLine) except * with gil:
66-
cdef CefString cefSwitchName
67-
cdef bint needs_strip = False
68-
for sw in _STRIP_CHILD_SWITCHES:
69-
cefSwitchName = PyToCefStringValue(sw)
70-
if cefCommandLine.get().HasSwitch(cefSwitchName):
71-
needs_strip = True
72-
break
73-
if not needs_strip:
74-
return
75-
76-
# Capture current state before resetting.
77-
cdef CefString program
78-
program = cefCommandLine.get().GetProgram()
79-
80-
cdef cpp_map[CefString, CefString] switches
81-
cefCommandLine.get().GetSwitches(switches)
82-
83-
cdef cpp_vector[CefString] arguments
84-
cefCommandLine.get().GetArguments(arguments)
85-
86-
# Rebuild command line omitting the problem switches.
87-
cefCommandLine.get().Reset()
88-
cefCommandLine.get().SetProgram(program)
89-
90-
cdef cpp_map[CefString, CefString].iterator it = switches.begin()
91-
while it != switches.end():
92-
if CefToPyString(deref(it).first) not in _STRIP_CHILD_SWITCHES:
93-
if deref(it).second.empty():
94-
cefCommandLine.get().AppendSwitch(deref(it).first)
95-
else:
96-
cefCommandLine.get().AppendSwitchWithValue(
97-
deref(it).first, deref(it).second)
98-
preinc(it)
99-
100-
cdef size_t i
101-
for i in range(arguments.size()):
102-
cefCommandLine.get().AppendArgument(arguments[i])

0 commit comments

Comments
 (0)