fix(apple): classify empty dyld settings by consumer semantics (#1110)
This commit is contained in:
@@ -17,7 +17,7 @@ export const embeddedDyldOverrides = (
|
||||
if (delimiter <= 0) continue;
|
||||
const variable = setting.slice(0, delimiter);
|
||||
const value = setting.slice(delimiter + 1);
|
||||
const effect = overrideEffect(variable);
|
||||
const effect = overrideEffect(variable, value);
|
||||
if (effect === undefined) continue;
|
||||
// ROOT_PATH is accepted only for simulator processes. Missing or unknown
|
||||
// platform metadata cannot establish that dyld ignores it.
|
||||
@@ -28,13 +28,6 @@ export const embeddedDyldOverrides = (
|
||||
!platforms.some((platform) => [7, 8, 9, 12].includes(platform))
|
||||
)
|
||||
continue;
|
||||
if (
|
||||
(variable === "DYLD_INSERT_LIBRARIES" ||
|
||||
variable === "DYLD_IMAGE_SUFFIX" ||
|
||||
effect.scope === "prefix") &&
|
||||
value === ""
|
||||
)
|
||||
continue;
|
||||
overrides.push({ variable, value, ...effect });
|
||||
}
|
||||
return overrides;
|
||||
@@ -42,8 +35,11 @@ export const embeddedDyldOverrides = (
|
||||
|
||||
const overrideEffect = (
|
||||
variable: string,
|
||||
value: string,
|
||||
): Pick<DyldSearchOverride, "phase" | "scope"> | undefined => {
|
||||
switch (variable) {
|
||||
// Empty directory components still produce /leaf candidates in dyld.
|
||||
// In particular, an empty fallback value is not a no-op.
|
||||
case "DYLD_LIBRARY_PATH":
|
||||
return { phase: "override", scope: "library" };
|
||||
case "DYLD_FRAMEWORK_PATH":
|
||||
@@ -56,12 +52,17 @@ const overrideEffect = (
|
||||
// so the directory's kind does not establish the replaced image's kind.
|
||||
case "DYLD_VERSIONED_LIBRARY_PATH":
|
||||
case "DYLD_VERSIONED_FRAMEWORK_PATH":
|
||||
case "DYLD_INSERT_LIBRARIES":
|
||||
case "DYLD_IMAGE_SUFFIX":
|
||||
return { phase: "override", scope: "all" };
|
||||
// Versioned paths scan directories; suffixes create path variants.
|
||||
// Empty directories cannot be scanned and empty suffixes repeat a path.
|
||||
return /[^:]/u.test(value)
|
||||
? { phase: "override", scope: "all" }
|
||||
: undefined;
|
||||
case "DYLD_INSERT_LIBRARIES":
|
||||
return value === "" ? undefined : { phase: "override", scope: "all" };
|
||||
case "DYLD_ROOT_PATH":
|
||||
case "DYLD_OVERLAY_PATH":
|
||||
return { phase: "override", scope: "prefix" };
|
||||
return value === "" ? undefined : { phase: "override", scope: "prefix" };
|
||||
default:
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -1105,3 +1105,130 @@ it("keeps inserted-library uncertainty scoped to the executable's process", asyn
|
||||
expect(limitation).toContain(MAIN);
|
||||
expect(limitation).not.toContain(library);
|
||||
});
|
||||
|
||||
it.each([
|
||||
[
|
||||
"DYLD_LIBRARY_PATH=",
|
||||
"@loader_path/child.dylib",
|
||||
"conditional",
|
||||
"undetermined",
|
||||
],
|
||||
[
|
||||
"DYLD_LIBRARY_PATH=: ",
|
||||
"@loader_path/child.dylib",
|
||||
"conditional",
|
||||
"undetermined",
|
||||
],
|
||||
[
|
||||
"DYLD_FRAMEWORK_PATH=",
|
||||
"@loader_path/Foo.framework/Foo",
|
||||
"conditional",
|
||||
"undetermined",
|
||||
],
|
||||
[
|
||||
"DYLD_FALLBACK_LIBRARY_PATH=",
|
||||
"@loader_path/child.dylib",
|
||||
"resolved",
|
||||
"undetermined",
|
||||
],
|
||||
[
|
||||
"DYLD_FALLBACK_LIBRARY_PATH=:",
|
||||
"@loader_path/child.dylib",
|
||||
"resolved",
|
||||
"undetermined",
|
||||
],
|
||||
[
|
||||
"DYLD_FALLBACK_FRAMEWORK_PATH=",
|
||||
"@loader_path/Foo.framework/Foo",
|
||||
"resolved",
|
||||
"undetermined",
|
||||
],
|
||||
[
|
||||
"DYLD_VERSIONED_LIBRARY_PATH=",
|
||||
"@loader_path/child.dylib",
|
||||
"resolved",
|
||||
"unresolved",
|
||||
],
|
||||
[
|
||||
"DYLD_VERSIONED_LIBRARY_PATH=:",
|
||||
"@loader_path/child.dylib",
|
||||
"resolved",
|
||||
"unresolved",
|
||||
],
|
||||
[
|
||||
"DYLD_VERSIONED_FRAMEWORK_PATH=",
|
||||
"@loader_path/Foo.framework/Foo",
|
||||
"resolved",
|
||||
"unresolved",
|
||||
],
|
||||
[
|
||||
"DYLD_VERSIONED_FRAMEWORK_PATH=::",
|
||||
"@loader_path/Foo.framework/Foo",
|
||||
"resolved",
|
||||
"unresolved",
|
||||
],
|
||||
[
|
||||
"DYLD_VERSIONED_LIBRARY_PATH= ",
|
||||
"@loader_path/child.dylib",
|
||||
"conditional",
|
||||
"undetermined",
|
||||
],
|
||||
["DYLD_IMAGE_SUFFIX=:", "@loader_path/child.dylib", "resolved", "unresolved"],
|
||||
[
|
||||
"DYLD_IMAGE_SUFFIX=::",
|
||||
"@loader_path/Foo.framework/Foo",
|
||||
"resolved",
|
||||
"unresolved",
|
||||
],
|
||||
[
|
||||
"DYLD_IMAGE_SUFFIX=:_debug:",
|
||||
"@loader_path/child.dylib",
|
||||
"conditional",
|
||||
"undetermined",
|
||||
],
|
||||
[
|
||||
"DYLD_INSERT_LIBRARIES=",
|
||||
"@loader_path/child.dylib",
|
||||
"resolved",
|
||||
"unresolved",
|
||||
],
|
||||
[
|
||||
"DYLD_INSERT_LIBRARIES=:",
|
||||
"@loader_path/child.dylib",
|
||||
"conditional",
|
||||
"undetermined",
|
||||
],
|
||||
] as const)(
|
||||
"interprets the empty components of %s according to their consumer for %s",
|
||||
async (setting, installName, foundStatus, missingStatus) => {
|
||||
const child = installName.replace("@loader_path", "Contents/MacOS");
|
||||
for (const [exists, status] of [
|
||||
[true, foundStatus],
|
||||
[false, missingStatus],
|
||||
] as const) {
|
||||
const trace = await traceDylibLoading(
|
||||
memoryView({
|
||||
[MAIN]: executable({
|
||||
dyld_environment: [setting],
|
||||
dependencies: [dependency(installName)],
|
||||
}),
|
||||
...(exists ? { [child]: parsed(slice()) } : {}),
|
||||
}),
|
||||
{ roots: [MAIN] },
|
||||
);
|
||||
expect(trace.edges[0]?.resolution.status).toBe(status);
|
||||
expect(trace.coverage.status).toBe(
|
||||
status === "conditional" || status === "undetermined"
|
||||
? "partial"
|
||||
: "complete",
|
||||
);
|
||||
expect(
|
||||
trace.images.find(({ path }) => path === MAIN)?.slices[0]
|
||||
?.dyld_environment,
|
||||
).toEqual([setting]);
|
||||
expect(
|
||||
trace.findings.some(({ kind }) => kind === "required-load-unresolved"),
|
||||
).toBe(status === "unresolved");
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user