llvm / llvm/llvm-project

lld-link (COFF): crash (STATUS_ACCESS_VIOLATION in AVX NT memset) with /FILEALIGN:1 /MERGE:.text=.data Regression in LLVM 21.1.0-rc1

Open
#198,126 8 comments 0 reactions 0 assignees View on GitHub
crash lld:COFF
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

## Summary
lld-link crashes with STATUS_ACCESS_VIOLATION when /FILEALIGN:1 and /MERGE:.text=.data are used together. ~~This is a regression introduced in 22.1.0; 21.1.8 (Previous version shipped with VS) links successfully with the same inputs.~~ **EDIT: it might have been 20.1.8, still checking which version works** EDIT2: 20.1.8 works 21.1.8 does not, crash happens in [**LLVM 21.1.0-rc1**](https://github.com/llvm/llvm-project/releases/tag/llvmorg-21.1.0-rc1)

Crash seems to happen after 160 bytes zeroed with vmovntdq

BT from 22.1.3:
```
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
Stack dump:
0. Program arguments: "C:\\Program Files\\Microsoft Visual Studio\\18\\Insiders\\VC\\Tools\\Llvm\\x64\\bin\\lld-link.exe" @D:\\DM40RE_native\\bisect\\build\\link_ltoobj.rsp
Exception Code: 0xC0000005
#0 0x00007ff6a28db7cb (C:\Program Files\Microsoft Visual Studio\18\Insiders\VC\Tools\Llvm\x64\bin\lld-link.exe+0x1b3b7cb)
#1 0x00007ff6a16068a5 (C:\Program Files\Microsoft Visual Studio\18\Insiders\VC\Tools\Llvm\x64\bin\lld-link.exe+0x8668a5)
#2 0x00007ff6a15fa590 (C:\Program Files\Microsoft Visual Studio\18\Insiders\VC\Tools\Llvm\x64\bin\lld-link.exe+0x85a590)
#3 0x00007ff6a143e5eb (C:\Program Files\Microsoft Visual Studio\18\Insiders\VC\Tools\Llvm\x64\bin\lld-link.exe+0x69e5eb)
#4 0x00007ff6a1431ddb (C:\Program Files\Microsoft Visual Studio\18\Insiders\VC\Tools\Llvm\x64\bin\lld-link.exe+0x691ddb)
#5 0x00007ff6a1431335 (C:\Program Files\Microsoft Visual Studio\18\Insiders\VC\Tools\Llvm\x64\bin\lld-link.exe+0x691335)
#6 0x00007ff6a0dccbc0 (C:\Program Files\Microsoft Visual Studio\18\Insiders\VC\Tools\Llvm\x64\bin\lld-link.exe+0x2cbc0)
#7 0x00007ff6a0dcc1c3 (C:\Program Files\Microsoft Visual Studio\18\Insiders\VC\Tools\Llvm\x64\bin\lld-link.exe+0x2c1c3)
#8 0x00007ff6a28a282c (C:\Program Files\Microsoft Visual Studio\18\Insiders\VC\Tools\Llvm\x64\bin\lld-link.exe+0x1b0282c)
#9 0x00007ffa38b117b3 (C:\WINDOWS\System32\KERNEL32.DLL+0x317b3)
#10 0x00007ffa3977fd00 (C:\WINDOWS\SYSTEM32\ntdll.dll+0x5fd00)
```

Repro:

```c
unsigned int startmain() { return 0; }
```
FLAGS:
```
clang-cl /c repro.c
lld-link repro.obj /SUBSYSTEM:WINDOWS /MACHINE:X64 /ENTRY:startmain /NODEFAULTLIB /FILEALIGN:1 /MERGE:.text=.data
```
Only with the combination of `/FILEALIGN:1` `/MERGE:.text=.data` the crash occurs, separately the crash doesn't occur and it gets linked sucessfully

Contributor guide

Open the contributing guide

Research direction

Start with the minimal repro in repro.c and run the listed clang-cl and lld-link commands, comparing the combined /FILEALIGN:1 and /MERGE:.text=.data flags with each flag separately. Investigate the lld-link crash around the reported AVX NT memset path; done means the combination links successfully without STATUS_ACCESS_VIOLATION and the regression is covered by an appropriate test.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.