https://github.com/JuliaLang/julia
Revision 72d3abeb0e86ec3a8689bad199801720e2e05fb5 authored by Max Horn on 07 February 2024, 21:28:09 UTC, committed by GitHub on 07 February 2024, 21:28:09 UTC
While debugging some invalidations and instabilities in code in packages
I work on, one of the issues I stumbled over is this code in this
`dlpath` method:
```julia
function dlpath(libname::Union{AbstractString, Symbol})
    handle = dlopen(libname)
    path = dlpath(handle)
    dlclose(handle)
    return path
end
```
The `dlopen` modified in this PR can in principle return `nothing`. But
there is no `dlpath` method for this. If one loads just a plain Julia,
all is fine, but under certain conditions (deep in a call chain analyzed
with Cthulhu.jl) it ended up not being able to prove that `path` will be
a string, and only inferred it as `Any`.

But if `throw_error` is set to `true` (the default, and used in the
relevant code path) then `dlopen` cannot return `nothing`, it always
returns a `String`. But the Julia compiler can't know that, as the
exception is thrown by a C helper. So instead modify the Julia code a
bit to help Julia deduce this fact by itself.
1 parent 18df941
History
Tip revision: 72d3abeb0e86ec3a8689bad199801720e2e05fb5 authored by Max Horn on 07 February 2024, 21:28:09 UTC
Fix potential instability/invalidation in dlpath (#53232)
Tip revision: 72d3abe
File Mode Size
.devcontainer
.github
base
cli
contrib
deps
doc
etc
src
stdlib
test
.buildkite-external-version -rw-r--r-- 5 bytes
.clang-format -rw-r--r-- 3.3 KB
.clangd -rw-r--r-- 114 bytes
.codecov.yml -rw-r--r-- 52 bytes
.git-blame-ignore-revs -rw-r--r-- 371 bytes
.gitattributes -rw-r--r-- 65 bytes
.gitignore -rw-r--r-- 571 bytes
.mailmap -rw-r--r-- 12.7 KB
CITATION.bib -rw-r--r-- 513 bytes
CITATION.cff -rw-r--r-- 940 bytes
CONTRIBUTING.md -rw-r--r-- 23.4 KB
HISTORY.md -rw-r--r-- 372.8 KB
LICENSE.md -rw-r--r-- 1.3 KB
Make.inc -rw-r--r-- 55.9 KB
Makefile -rw-r--r-- 30.2 KB
NEWS.md -rw-r--r-- 11.5 KB
README.md -rw-r--r-- 7.4 KB
THIRDPARTY.md -rw-r--r-- 3.9 KB
VERSION -rw-r--r-- 11 bytes
julia.spdx.json -rw-r--r-- 37.8 KB
pkgimage.mk -rw-r--r-- 5.9 KB
sysimage.mk -rw-r--r-- 4.2 KB
typos.toml -rw-r--r-- 78 bytes

README.md

back to top