Skip to content

Commit a1db8da

Browse files
protect against PkgId and UUID being imported and losing Base prefix in create_expr_cache (#53387)
Fixes #53381
1 parent 8425b0e commit a1db8da

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

base/loading.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2641,6 +2641,7 @@ function create_expr_cache(pkg::PkgId, input::String, output::String, output_o::
26412641
error("LOAD_PATH entries cannot contain $(repr(path_sep))")
26422642

26432643
deps_strs = String[]
2644+
# protects against PkgId and UUID being imported and losing Base prefix
26442645
function pkg_str(_pkg::PkgId)
26452646
if _pkg.uuid === nothing
26462647
"Base.PkgId($(repr(_pkg.name)))"
@@ -2651,6 +2652,9 @@ function create_expr_cache(pkg::PkgId, input::String, output::String, output_o::
26512652
for (pkg, build_id) in concrete_deps
26522653
push!(deps_strs, "$(pkg_str(pkg)) => $(repr(build_id))")
26532654
end
2655+
deps_eltype = sprint(show, eltype(concrete_deps); context = :module=>nothing)
2656+
deps = deps_eltype * "[" * join(deps_strs, ",") * "]"
2657+
precomp_stack = "Base.PkgId[$(join(map(pkg_str, vcat(Base.precompilation_stack, pkg)), ", "))]"
26542658

26552659
if output_o !== nothing
26562660
@debug "Generating object cache file for $(repr("text/plain", pkg))"
@@ -2662,8 +2666,6 @@ function create_expr_cache(pkg::PkgId, input::String, output::String, output_o::
26622666
opts = `-O0 --output-ji $(output) --output-incremental=yes`
26632667
end
26642668

2665-
deps_eltype = sprint(show, eltype(concrete_deps); context = :module=>nothing)
2666-
deps = deps_eltype * "[" * join(deps_strs, ",") * "]"
26672669
trace = isassigned(PRECOMPILE_TRACE_COMPILE) ? `--trace-compile=$(PRECOMPILE_TRACE_COMPILE[])` : ``
26682670
io = open(pipeline(addenv(`$(julia_cmd(;cpu_target)::Cmd)
26692671
$(flags)
@@ -2679,7 +2681,7 @@ function create_expr_cache(pkg::PkgId, input::String, output::String, output_o::
26792681
# write data over stdin to avoid the (unlikely) case of exceeding max command line size
26802682
write(io.in, """
26812683
empty!(Base.EXT_DORMITORY) # If we have a custom sysimage with `EXT_DORMITORY` prepopulated
2682-
Base.track_nested_precomp($(vcat(Base.precompilation_stack, pkg)))
2684+
Base.track_nested_precomp($precomp_stack)
26832685
Base.precompiling_extension = $(loading_extension)
26842686
Base.include_package_for_output($(pkg_str(pkg)), $(repr(abspath(input))), $(repr(depot_path)), $(repr(dl_load_path)),
26852687
$(repr(load_path)), $deps, $(repr(source_path(nothing))))

0 commit comments

Comments
 (0)