Skip to content
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

Precompile errors should attach the underlying exception #41109

Closed
BioTurboNick opened this issue Jun 6, 2021 · 4 comments
Closed

Precompile errors should attach the underlying exception #41109

BioTurboNick opened this issue Jun 6, 2021 · 4 comments
Labels
error handling Handling of exceptions by Julia or the user error messages Better, more actionable error messages

Comments

@BioTurboNick
Copy link
Contributor

Currently, failed precompile just uses error when it encounters an exception. Probably better for it to attach the underlying exception that caused it to fail?

julia/base/loading.jl

Lines 1430 to 1467 in 66c3375

try
close(tmpio)
p = create_expr_cache(pkg, path, tmppath, concrete_deps, internal_stderr, internal_stdout)
if success(p)
# append checksum to the end of the .ji file:
open(tmppath, "a+") do f
write(f, _crc32c(seekstart(f)))
end
# inherit permission from the source file
chmod(tmppath, filemode(path) & 0o777)
# Read preferences hash back from .ji file (we can't precompute because
# we don't actually know what the list of compile-time preferences are without compiling)
prefs_hash = preferences_hash(tmppath)
cachefile = compilecache_path(pkg, prefs_hash)
# prune the directory with cache files
if pkg.uuid !== nothing
entrypath, entryfile = cache_file_entry(pkg)
cachefiles = filter!(x -> startswith(x, entryfile * "_"), readdir(cachepath))
if length(cachefiles) >= MAX_NUM_PRECOMPILE_FILES[]
idx = findmin(mtime.(joinpath.(cachepath, cachefiles)))[2]
rm(joinpath(cachepath, cachefiles[idx]))
end
end
# this is atomic according to POSIX:
rename(tmppath, cachefile; force=true)
return cachefile
end
finally
rm(tmppath, force=true)
end
if p.exitcode == 125
return PrecompilableError()
else
error("Failed to precompile $pkg to $tmppath.")
end

@DilumAluthge
Copy link
Member

I believe you can just get the exception directly by doing e.g. import Foo, right?

@BioTurboNick
Copy link
Contributor Author

Possibly, though I believe it's proper exception handling to propagate originating errors. Once #40642 is merged, which allows the previous error to be re-displayed, this will become more apparent as only the stack trace from compilecache would be accessible, and not the trace from the actual problem.

@KristofferC
Copy link
Member

I believe you can just get the exception directly by doing e.g. import Foo, right?

I think this issue is in fact about normal precompilation that occurs during import Foo and not Pkg parallel precompilation.

@brenhinkeller brenhinkeller added error handling Handling of exceptions by Julia or the user error messages Better, more actionable error messages labels Nov 19, 2022
@vtjnash
Copy link
Member

vtjnash commented Feb 3, 2024

There is no distinct error there though, since it is just a failed precompile process, and that is all it knows. Also that outer packages should not be trying to delve into recursively generated errors, and just treat is as: using failed.

@vtjnash vtjnash closed this as not planned Won't fix, can't repro, duplicate, stale Feb 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
error handling Handling of exceptions by Julia or the user error messages Better, more actionable error messages
Projects
None yet
Development

No branches or pull requests

5 participants