Skip to content

Commit

Permalink
Skip libraries consisting of the empty string (#50899)
Browse files Browse the repository at this point in the history
Co-authored-by: Gabriel Baraldi <[email protected]>
Co-authored-by: Jameson Nash <[email protected]>
  • Loading branch information
3 people authored Aug 15, 2023
1 parent fd38d50 commit 0b190b3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
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

2 comments on commit 0b190b3

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Executing the daily package evaluation, I will reply here when finished:

@nanosoldier runtests(isdaily = true)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The package evaluation job you requested has completed - possible new issues were detected.
The full report is available.

Please sign in to comment.