https://github.com/JuliaLang/julia
Revision 9e8fe688c5e32bde3ab48bb71f9d4ab45ef272ee authored by Valentin Churavy on 24 November 2023, 22:35:51 UTC, committed by GitHub on 24 November 2023, 22:35:51 UTC
Fixes #52213

Overwritting methods during cache creation is currently not something
that the system
can support and can lead to surprising, counter-intuitive and fatal
errors.

In 1.10 we turned it from a warning to a strong error, with this PR it
remains
a strong error, but the precompilation system recognizes it and
essentially sets `__precompile__(false)`
for this module and all modules that depend on it.

Before:
```
julia> using OverwriteMethodError
[ Info: Precompiling OverwriteMethodError [top-level]
WARNING: Method definition +(Bool, Bool) in module Base at bool.jl:166 overwritten in module OverwriteMethodError at /home/vchuravy/src/julia2/OverwriteMethodError.jl:2.
ERROR: LoadError: Method overwriting is not permitted during Module precompile.
Stacktrace:
 [1] top-level scope
   @ ~/src/julia2/OverwriteMethodError.jl:2
 [2] include
   @ Base ./Base.jl:489 [inlined]
 [3] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt128}}, source::Nothing)
   @ Base ./loading.jl:2216
 [4] top-level scope
   @ stdin:3
in expression starting at /home/vchuravy/src/julia2/OverwriteMethodError.jl:1
in expression starting at stdin:3
ERROR: Failed to precompile OverwriteMethodError [top-level] to "/home/vchuravy/.julia/compiled/v1.10/jl_guiuCQ".
Stacktrace:
  [1] error(s::String)
    @ Base ./error.jl:35
  [2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IO, internal_stdout::IO, keep_loaded_modules::Bool)
    @ Base ./loading.jl:2462
  [3] compilecache
    @ Base ./loading.jl:2334 [inlined]
  [4] (::Base.var"#968#969"{Base.PkgId})()
    @ Base ./loading.jl:1968
  [5] mkpidlock(f::Base.var"#968#969"{Base.PkgId}, at::String, pid::Int32; kwopts::@Kwargs{stale_age::Int64, wait::Bool})
    @ FileWatching.Pidfile ~/.julia/juliaup/julia-1.10.0-rc1+0.x64.linux.gnu/share/julia/stdlib/v1.10/FileWatching/src/pidfile.jl:93
  [6] #mkpidlock#6
    @ FileWatching.Pidfile ~/.julia/juliaup/julia-1.10.0-rc1+0.x64.linux.gnu/share/julia/stdlib/v1.10/FileWatching/src/pidfile.jl:88 [inlined]
  [7] trymkpidlock(::Function, ::Vararg{Any}; kwargs::@Kwargs{stale_age::Int64})
    @ FileWatching.Pidfile ~/.julia/juliaup/julia-1.10.0-rc1+0.x64.linux.gnu/share/julia/stdlib/v1.10/FileWatching/src/pidfile.jl:111
  [8] #invokelatest#2
    @ Base ./essentials.jl:889 [inlined]
  [9] invokelatest
    @ Base ./essentials.jl:884 [inlined]
 [10] maybe_cachefile_lock(f::Base.var"#968#969"{Base.PkgId}, pkg::Base.PkgId, srcpath::String; stale_age::Int64)
    @ Base ./loading.jl:2977
 [11] maybe_cachefile_lock
    @ Base ./loading.jl:2974 [inlined]
 [12] _require(pkg::Base.PkgId, env::String)
    @ Base ./loading.jl:1964
 [13] __require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base ./loading.jl:1806
 [14] #invoke_in_world#3
    @ Base ./essentials.jl:921 [inlined]
 [15] invoke_in_world
    @ Base ./essentials.jl:918 [inlined]
 [16] _require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base ./loading.jl:1797
 [17] macro expansion
    @ Base ./loading.jl:1784 [inlined]
 [18] macro expansion
    @ Base ./lock.jl:267 [inlined]
 [19] __require(into::Module, mod::Symbol)
    @ Base ./loading.jl:1747
 [20] #invoke_in_world#3
    @ Base ./essentials.jl:921 [inlined]
 [21] invoke_in_world
    @ Base ./essentials.jl:918 [inlined]
 [22] require(into::Module, mod::Symbol)
    @ Base ./loading.jl:1740
```

After:
```
julia> using OverwriteMethodError
┌ Info: Precompiling OverwriteMethodError [top-level]
└ @ Base loading.jl:2486
WARNING: Method definition +(Bool, Bool) in module Base at bool.jl:166 overwritten in module OverwriteMethodError at /home/vchuravy/src/julia2/OverwriteMethodError.jl:2.
ERROR: Method overwriting is not permitted during Module precompile.
┌ Info: Skipping precompilation since __precompile__(false). Importing OverwriteMethodError [top-level].
└ @ Base loading.jl:2084
```

---------

Co-authored-by: Kristoffer Carlsson <kcarlsson89@gmail.com>
1 parent 6e23543
History
Tip revision: 9e8fe688c5e32bde3ab48bb71f9d4ab45ef272ee authored by Valentin Churavy on 24 November 2023, 22:35:51 UTC
Turn Method Overwritten Error into a PrecompileError -- turning off caching (#52214)
Tip revision: 9e8fe68
File Mode Size
clangsa
flisp
jsvm-emscripten
support
.gitignore -rw-r--r-- 376 bytes
APInt-C.cpp -rw-r--r-- 15.8 KB
APInt-C.h -rw-r--r-- 5.2 KB
Makefile -rw-r--r-- 31.4 KB
abi_aarch64.cpp -rw-r--r-- 15.6 KB
abi_arm.cpp -rw-r--r-- 9.2 KB
abi_llvm.cpp -rw-r--r-- 2.4 KB
abi_ppc64le.cpp -rw-r--r-- 6.2 KB
abi_win32.cpp -rw-r--r-- 3.0 KB
abi_win64.cpp -rw-r--r-- 3.0 KB
abi_x86.cpp -rw-r--r-- 3.3 KB
abi_x86_64.cpp -rw-r--r-- 8.7 KB
aotcompile.cpp -rw-r--r-- 81.5 KB
array.c -rw-r--r-- 12.3 KB
ast.c -rw-r--r-- 54.5 KB
ast.scm -rw-r--r-- 21.9 KB
bin2hex.scm -rw-r--r-- 388 bytes
builtin_proto.h -rw-r--r-- 2.1 KB
builtins.c -rw-r--r-- 83.4 KB
ccall.cpp -rw-r--r-- 93.5 KB
ccalllazybar.c -rw-r--r-- 234 bytes
ccalllazyfoo.c -rw-r--r-- 156 bytes
ccalltest.c -rw-r--r-- 24.1 KB
ccalltest_common.h -rw-r--r-- 779 bytes
cgmemmgr.cpp -rw-r--r-- 30.5 KB
cgutils.cpp -rw-r--r-- 191.1 KB
codegen-stubs.c -rw-r--r-- 6.0 KB
codegen.cpp -rw-r--r-- 426.6 KB
common_symbols1.inc -rw-r--r-- 2.0 KB
common_symbols2.inc -rw-r--r-- 5.6 KB
coverage.cpp -rw-r--r-- 7.2 KB
crc32c-tables.c -rw-r--r-- 43.4 KB
crc32c.c -rw-r--r-- 19.9 KB
datatype.c -rw-r--r-- 76.3 KB
debug-registry.h -rw-r--r-- 4.7 KB
debuginfo.cpp -rw-r--r-- 60.9 KB
debuginfo.h -rw-r--r-- 697 bytes
disasm.cpp -rw-r--r-- 48.4 KB
dlload.c -rw-r--r-- 17.0 KB
features_aarch32.h -rw-r--r-- 1.1 KB
features_aarch64.h -rw-r--r-- 4.6 KB
features_x86.h -rw-r--r-- 4.1 KB
file_constants.h -rw-r--r-- 2.1 KB
gc-alloc-profiler.cpp -rw-r--r-- 4.7 KB
gc-alloc-profiler.h -rw-r--r-- 1.7 KB
gc-debug.c -rw-r--r-- 41.0 KB
gc-heap-snapshot.cpp -rw-r--r-- 18.9 KB
gc-heap-snapshot.h -rw-r--r-- 4.5 KB
gc-pages.c -rw-r--r-- 6.3 KB
gc-stacks.c -rw-r--r-- 9.6 KB
gc.c -rw-r--r-- 157.8 KB
gc.h -rw-r--r-- 21.3 KB
gen_sysimg_symtab.jl -rw-r--r-- 1.8 KB
genericmemory.c -rw-r--r-- 25.4 KB
gf.c -rw-r--r-- 171.2 KB
iddict.c -rw-r--r-- 6.3 KB
init.c -rw-r--r-- 31.1 KB
interpreter.c -rw-r--r-- 33.1 KB
intrinsics.cpp -rw-r--r-- 71.5 KB
intrinsics.h -rw-r--r-- 3.1 KB
ircode.c -rw-r--r-- 42.9 KB
jitlayers.cpp -rw-r--r-- 96.7 KB
jitlayers.h -rw-r--r-- 22.1 KB
jl_exported_data.inc -rw-r--r-- 4.5 KB
jl_exported_funcs.inc -rw-r--r-- 16.4 KB
jl_uv.c -rw-r--r-- 30.8 KB
jlapi.c -rw-r--r-- 20.4 KB
jlfrontend.scm -rw-r--r-- 9.6 KB
jloptions.c -rw-r--r-- 38.9 KB
jloptions.h -rw-r--r-- 1.6 KB
jltypes.c -rw-r--r-- 139.3 KB
julia-parser.scm -rw-r--r-- 112.8 KB
julia-syntax.scm -rw-r--r-- 236.6 KB
julia.expmap.in -rw-r--r-- 933 bytes
julia.h -rw-r--r-- 109.3 KB
julia_assert.h -rw-r--r-- 1.1 KB
julia_atomics.h -rw-r--r-- 12.6 KB
julia_fasttls.h -rw-r--r-- 1.8 KB
julia_gcext.h -rw-r--r-- 6.8 KB
julia_internal.h -rw-r--r-- 78.2 KB
julia_locks.h -rw-r--r-- 3.5 KB
julia_threads.h -rw-r--r-- 13.6 KB
llvm-alloc-helpers.cpp -rw-r--r-- 15.8 KB
llvm-alloc-helpers.h -rw-r--r-- 5.5 KB
llvm-alloc-opt.cpp -rw-r--r-- 49.3 KB
llvm-codegen-shared.h -rw-r--r-- 19.7 KB
llvm-cpufeatures.cpp -rw-r--r-- 3.9 KB
llvm-demote-float16.cpp -rw-r--r-- 7.8 KB
llvm-final-gc-lowering.cpp -rw-r--r-- 10.7 KB
llvm-gc-invariant-verifier.cpp -rw-r--r-- 6.9 KB
llvm-julia-licm.cpp -rw-r--r-- 17.0 KB
llvm-julia-passes.inc -rw-r--r-- 1.3 KB
llvm-late-gc-lowering.cpp -rw-r--r-- 123.4 KB
llvm-lower-handlers.cpp -rw-r--r-- 8.9 KB
llvm-muladd.cpp -rw-r--r-- 3.4 KB
llvm-multiversioning.cpp -rw-r--r-- 41.8 KB
llvm-pass-helpers.cpp -rw-r--r-- 12.4 KB
llvm-pass-helpers.h -rw-r--r-- 5.5 KB
llvm-propagate-addrspaces.cpp -rw-r--r-- 11.7 KB
llvm-ptls.cpp -rw-r--r-- 15.8 KB
llvm-remove-addrspaces.cpp -rw-r--r-- 15.2 KB
llvm-remove-ni.cpp -rw-r--r-- 980 bytes
llvm-simdloop.cpp -rw-r--r-- 9.4 KB
llvm-version.h -rw-r--r-- 837 bytes
llvm_api.cpp -rw-r--r-- 5.1 KB
llvmcalltest.cpp -rw-r--r-- 2.0 KB
mach_excServer.c -rw-r--r-- 30.5 KB
macroexpand.scm -rw-r--r-- 27.1 KB
match.scm -rw-r--r-- 9.8 KB
method.c -rw-r--r-- 52.6 KB
mk_julia_flisp_boot.scm -rw-r--r-- 137 bytes
module.c -rw-r--r-- 36.5 KB
mtarraylist.c -rw-r--r-- 2.5 KB
opaque_closure.c -rw-r--r-- 8.3 KB
options.h -rw-r--r-- 5.8 KB
partr.c -rw-r--r-- 20.0 KB
passes.h -rw-r--r-- 5.9 KB
pipeline.cpp -rw-r--r-- 41.6 KB
precompile.c -rw-r--r-- 6.8 KB
precompile_utils.c -rw-r--r-- 11.7 KB
processor.cpp -rw-r--r-- 32.9 KB
processor.h -rw-r--r-- 12.3 KB
processor_arm.cpp -rw-r--r-- 68.8 KB
processor_fallback.cpp -rw-r--r-- 6.1 KB
processor_x86.cpp -rw-r--r-- 42.6 KB
rtutils.c -rw-r--r-- 52.5 KB
runtime_ccall.cpp -rw-r--r-- 11.2 KB
runtime_intrinsics.c -rw-r--r-- 62.9 KB
safepoint.c -rw-r--r-- 13.2 KB
serialize.h -rw-r--r-- 3.7 KB
signal-handling.c -rw-r--r-- 16.2 KB
signals-mach.c -rw-r--r-- 29.4 KB
signals-unix.c -rw-r--r-- 39.1 KB
signals-win.c -rw-r--r-- 18.9 KB
simplevector.c -rw-r--r-- 3.0 KB
smallintset.c -rw-r--r-- 6.9 KB
stackwalk.c -rw-r--r-- 46.1 KB
staticdata.c -rw-r--r-- 159.8 KB
staticdata_utils.c -rw-r--r-- 52.8 KB
subtype.c -rw-r--r-- 184.4 KB
symbol.c -rw-r--r-- 5.1 KB
sys.c -rw-r--r-- 21.5 KB
task.c -rw-r--r-- 68.6 KB
threading.c -rw-r--r-- 30.8 KB
threading.h -rw-r--r-- 795 bytes
timing.c -rw-r--r-- 22.7 KB
timing.h -rw-r--r-- 14.0 KB
toplevel.c -rw-r--r-- 41.1 KB
typemap.c -rw-r--r-- 66.7 KB
uprobes.d -rw-r--r-- 1.5 KB
utils.scm -rw-r--r-- 3.3 KB
uv_constants.h -rw-r--r-- 783 bytes
win32_ucontext.c -rw-r--r-- 2.9 KB
win32_ucontext.h -rw-r--r-- 639 bytes
work-stealing-queue.h -rw-r--r-- 3.0 KB

back to top