llvm / llvm/llvm-project

clang-23-compiled executable segfaults, while llubi interprets the same IR successfully

Open
#207,582 0 comments 0 reactions 1 assignee Claimed by @dtcxzyw View on GitHub
tools:llubi
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

I found a case where llubi can interpret the IR successfully, but the executable generated by `clang-23` crashes with a segmentation fault.

IR program:

```llvm
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:64:64-i64:64:64"

define i32 @main() {
%alloca = alloca [2 x i32]
store <4 x i32> zeroinitializer, ptr %alloca, align 8
store [2 x i32] [i32 1, i32 1], ptr %alloca, align 8

%load1 = load <4 x i32>, ptr %alloca, align 8
%load2 = load <4 x i32>, ptr %alloca, align 8
%load3 = load <4 x i32>, ptr %alloca, align 8
%load_arr = load [2 x i32], ptr %alloca, align 8
ret i32 0
}
```

`llubi` interprets the program successfully:

```
Entering function: main
%alloca = alloca [2 x i32], align 8 => ptr 0x8 [alloca]
store <4 x i32> zeroinitializer, ptr %alloca, align 8
store [2 x i32] [i32 1, i32 1], ptr %alloca, align 8
%load1 = load <4 x i32>, ptr %alloca, align 8 => { i32 1, i32 -289830082, i32 1, i32 -399511892 }
%load2 = load <4 x i32>, ptr %alloca, align 8 => { i32 1, i32 -132966042, i32 1, i32 1094190734 }
%load3 = load <4 x i32>, ptr %alloca, align 8 => { i32 1, i32 -1670034957, i32 1, i32 -899485425 }
%load_arr = load [2 x i32], ptr %alloca, align 8 => { i32 1, i32 1 }
ret i32 0
Exiting function: main
```

However, after compiling the same IR with `clang-23` and running the generated executable, the program crashes with the log "Segmentation fault (core dumped)".

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.