Skip to content

Commit

Permalink
Avoid stat-ing stdlib path if it's unreadable (#55992)
Browse files Browse the repository at this point in the history
  • Loading branch information
giordano authored Oct 5, 2024
1 parent 096c1d2 commit 5d12c6d
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions base/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3864,10 +3864,17 @@ end

# now check if this file's content hash has changed relative to its source files
if stalecheck
if !samefile(includes[1].filename, modpath) && !samefile(fixup_stdlib_path(includes[1].filename), modpath)
@debug "Rejecting cache file $cachefile because it is for file $(includes[1].filename) not file $modpath"
record_reason(reasons, "wrong source")
return true # cache file was compiled from a different path
if !samefile(includes[1].filename, modpath)
# In certain cases the path rewritten by `fixup_stdlib_path` may
# point to an unreadable directory, make sure we can `stat` the
# file before comparing it with `modpath`.
stdlib_path = fixup_stdlib_path(includes[1].filename)
if !(isreadable(stdlib_path) && samefile(stdlib_path, modpath))
!samefile(fixup_stdlib_path(includes[1].filename), modpath)
@debug "Rejecting cache file $cachefile because it is for file $(includes[1].filename) not file $modpath"
record_reason(reasons, "wrong source")
return true # cache file was compiled from a different path
end
end
for (modkey, req_modkey) in requires
# verify that `require(modkey, name(req_modkey))` ==> `req_modkey`
Expand Down

0 comments on commit 5d12c6d

Please sign in to comment.