Skip to content

Conversation

@JSmith2023
Copy link

@JSmith2023 JSmith2023 commented Dec 11, 2025

The Base.llvmcall intrinsic previously crashed (Segmentation Fault) or threw a parser error when given a zero-sized type (ZST), such as nothing, as an argument.

This patch addresses two issues in src/ccall.cpp:

Adds a null check (if (!v)) in llvm_type_rewrite to safely handle ghost arguments.

Skips void types when generating the LLVM function signature string in emit_llvmcall, ensuring valid syntax.

The result is that calling llvmcall with a ZST now correctly throws a user error if the user attempts to reference the ZST argument in the custom assembly.

Fixes #60063

I have also included a regression test in test/llvmcall.jl to prevent this issue from recurring.

@JSmith2023 JSmith2023 force-pushed the ZST-Handling branch 9 times, most recently from b9be8ef to 7da5806 Compare December 11, 2025 17:19
@JSmith2023
Copy link
Author

Update on CI Failures:

I've pushed an amendment to address the failures seen in the linux-gnuassertrr and aarch64 builds.

Fixed Segfault in sysimage build: The strict assertrr build was crashing because nullptr was being passed to llvm_type_rewrite for ZST arguments. I've updated the loop in emit_llvmcall to explicitly skip the rewrite for Void types and assign a safe placeholder (NULL), which avoids the crash without creating illegal UndefValues for void types.

Fixed LLVM IR Syntax Error: The previous logic for skipping ZSTs in the function signature could generate invalid commas (e.g., leading/trailing commas) in some edge cases, which caused failures on AArch64. I replaced the boolean flag logic with a counter to ensure commas are only emitted between valid arguments.

@JSmith2023 JSmith2023 force-pushed the ZST-Handling branch 3 times, most recently from 2e543e7 to ac02072 Compare December 11, 2025 17:39
Copy link
Member

@Zentrik Zentrik left a comment

Choose a reason for hiding this comment

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

You seem to have formatted the file which makes the diff rather large, I would suggest undoing the formatting changes.

@JSmith2023 JSmith2023 force-pushed the ZST-Handling branch 13 times, most recently from 29d3257 to d0535ec Compare December 12, 2025 03:25
@JSmith2023 JSmith2023 requested a review from giordano as a code owner December 12, 2025 03:25
@JSmith2023 JSmith2023 force-pushed the ZST-Handling branch 9 times, most recently from f05c6fa to 52cb36e Compare December 12, 2025 05:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

llvmcall segfaults if an argument has size 0

3 participants