Skip to content

Commit 0b190b3

Browse files
pchintalapudigbaraldivtjnash
authored
Skip libraries consisting of the empty string (#50899)
Co-authored-by: Gabriel Baraldi <baraldigabriel@gmail.com> Co-authored-by: Jameson Nash <vtjnash@gmail.com>
1 parent fd38d50 commit 0b190b3

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/jitlayers.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1588,6 +1588,9 @@ struct JuliaOJIT::DLSymOptimizer {
15881588
assert(++++CI->use_begin() == CI->use_end());
15891589
void *addr;
15901590
if (auto GV = dyn_cast<GlobalVariable>(libarg)) {
1591+
// Can happen if the library is the empty string, just give up when that happens
1592+
if (isa<ConstantAggregateZero>(GV->getInitializer()))
1593+
continue;
15911594
auto libname = cast<ConstantDataArray>(GV->getInitializer())->getAsCString();
15921595
addr = lookup(libname.data(), fname.data());
15931596
} else {

test/ccall.jl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1915,3 +1915,17 @@ end
19151915
ctest_total_const() = Val{ctest_total(1 + 2im)}()
19161916
Core.Compiler.return_type(ctest_total_const, Tuple{}) == Val{2 + 0im}
19171917
end
1918+
1919+
const libfrobozz = ""
1920+
1921+
function somefunction_not_found()
1922+
ccall((:somefunction, libfrobozz), Cvoid, ())
1923+
end
1924+
1925+
@testset "library not found" begin
1926+
if Sys.islinux()
1927+
@test_throws "could not load symbol \"somefunction\"" somefunction_not_found()
1928+
else
1929+
@test_throws "could not load library \"\"" somefunction_not_found()
1930+
end
1931+
end

0 commit comments

Comments
 (0)