Issue 97635
Summary [MC] SIGSEGV due to uninitialized AsmParser.Out.CurrFrag
Labels new issue
Assignees
Reporter sivan-shani
    Due to several recent changes, the function `AsmParser::checkForValidSection() `is now utilizing (among other functions) also `CurFrag->getParent()` instead of `getCurrentSection().first`

This seems to cause a SIGSEV in some cases when `AsmParser::Run()` is called via API. 

`AsmParser.Out.CurFrag` is not set, `AsmParser::Run()` -> call -> `AsmParser::parseStatement` -> `checkForValidSection` and this terminates in SIGSEV.

gdb output:
```
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
MC Feature String: +v8a,+crc,+fp-armv8,+neon,+crypto
Running slice:
arch: core_v8A_64+vfpneon_v8A_fp_neon+extension_cryptography
mode: feature_AArch64
slice range: 0x15000000 - 0x15ffffff (provided (val & 0xff000000) == 0x15000000)
operation: assemble

Program received signal SIGSEGV, Segmentation fault.
0x0000555555b587ee in llvm::MCFragment::getParent (this=0x0) at /llvm-project/llvm/include/llvm/MC/MCFragment.h:93
93	  MCSection *getParent() const { return Parent; } // (this=0x0)
(gdb) bt
#0 0x0000555555b587ee in llvm::MCFragment::getParent (this=0x0) at /llvm-project/llvm/include/llvm/MC/MCFragment.h:93
#1  0x000055555615d545 in llvm::MCStreamer::getCurrentFragment (this=0x555557af6a60) at /llvm-project/llvm/include/llvm/MC/MCStreamer.h:412
#2  0x0000555556137125 in (anonymous namespace)::AsmParser::checkForValidSection (this=0x555557af74b0) at /llvm-project/llvm/lib/MC/MCParser/AsmParser.cpp:1085
#3 0x000055555613c857 in (anonymous namespace)::AsmParser::parseStatement (this=0x555557af74b0, Info=..., SI=0x0) at /llvm-project/llvm/lib/MC/MCParser/AsmParser.cpp:2308
#4 0x0000555556136817 in (anonymous namespace)::AsmParser::Run (this=0x555557af74b0, NoInitialTextSection=false, NoFinalize=false)
    at /llvm-project/llvm/lib/MC/MCParser/AsmParser.cpp:999
```

   
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to