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

Skip libraries consisting of the empty string #50899

Merged
merged 4 commits into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions src/jitlayers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1588,6 +1588,9 @@ struct JuliaOJIT::DLSymOptimizer {
assert(++++CI->use_begin() == CI->use_end());
void *addr;
if (auto GV = dyn_cast<GlobalVariable>(libarg)) {
// Can happen if the library is the empty string, just give up when that happens
if (isa<ConstantAggregateZero>(GV->getInitializer()))
continue;
auto libname = cast<ConstantDataArray>(GV->getInitializer())->getAsCString();
addr = lookup(libname.data(), fname.data());
} else {
Expand Down
14 changes: 14 additions & 0 deletions test/ccall.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1915,3 +1915,17 @@ end
ctest_total_const() = Val{ctest_total(1 + 2im)}()
Core.Compiler.return_type(ctest_total_const, Tuple{}) == Val{2 + 0im}
end

const libfrobozz = ""

function somefunction_not_found()
ccall((:somefunction, libfrobozz), Cvoid, ())
end

@testset "library not found" begin
if Sys.islinux()
@test_throws "could not load symbol \"somefunction\"" somefunction_not_found()
else
@test_throws "could not load library \"\"" somefunction_not_found()
end
end