llvmcall segfaults if an argument has size 0 #60063 fix #60437
Closed
+35
−9
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This code change used AI (Gemini Pro 3) to aid in the bug fixing process.
The primary issue, #60063, llvmcall would segfault if a zero-sized type (like Nothing or an empty struct) was passed as an argument.
The fix in src/cgutils.cpp (_julia_struct_to_llvm) now correctly detects 0-size types and returns LLVM::VoidTy immediately, preventing the creation of invalid LLVM structures.
While working on this, I also discovered that the jl_temporary_root call in the same function was unsafe and caused build failures on strict GC backends (like MMTk).
I replaced it with JL_GC_PUSH1, which explicitly roots the value on the C stack. This means this PR also fixes a build-blocking garbage collection safety bug during sysimage generation.
Thank you for helping me improve the quality of my first contribution! Sorry if I caused any hassle earlier.