Skip to content

protect against PkgId and UUID being imported and losing Base prefix in create_expr_cache #53387

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions base/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2641,6 +2641,7 @@ function create_expr_cache(pkg::PkgId, input::String, output::String, output_o::
error("LOAD_PATH entries cannot contain $(repr(path_sep))")

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

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

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