<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/151636>151636</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            BPF Clang crashes when reading badly formatted .byte data in inline
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          Ezlanding1
      </td>
    </tr>
</table>

<pre>
    Badly formatted inline assembly .byte data causes a crash when compiling for BPF. When compiling normally, however, it compiles successfully and just ignores the bytes. Note that in the program below, if the bytes were formatted correctly (`".byte 0xDE, 0xAD, 0xBE, 0xEF"`) it would sucessfully compile
## Program
```C
int main() {
        asm(".byte DE, AD, BE, EF");
        return 0;
}
```
## Stack Dump
```
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: clang -target bpf -c bug.bpf.c -o bug.bpf.o
1.      <eof> parser at end of file
2.      Code generation
 #0 0x0000785d90a3fd01 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0xe3fd01)
 #1 0x0000785d90a3da3e llvm::sys::RunSignalHandlers() (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0xe3da3e)
 #2 0x0000785d90a3f0ab llvm::sys::CleanupOnSignal(unsigned long) (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0xe3f0ab)
 #3 0x0000785d9096bdff (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0xd6bdff)
 #4 0x0000785d8f442520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #5 0x0000785d92b8e816 (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0x2f8e816)
 #6 0x0000785d91f7fe64 (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0x237fe64)
 #7 0x0000785d91f97164 llvm::MCAssembler::layout(llvm::MCAsmLayout&) (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0x2397164)
 #8 0x0000785d91f97997 llvm::MCAssembler::Finish() (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0x2397997)
 #9 0x0000785d91fb4f6b llvm::MCELFStreamer::finishImpl() (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0x23b4f6b)
#10 0x0000785d91fd91f7 llvm::MCStreamer::Finish(llvm::SMLoc) (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0x23d91f7)
#11 0x0000785d912c0194 llvm::AsmPrinter::doFinalization(llvm::Module&) (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0x16c0194)
#12 0x0000785d90b81a41 llvm::FPPassManager::doFinalization(llvm::Module&) (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0xf81a41)
#13 0x0000785d90b7ba81 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0xf7ba81)
#14 0x0000785d97e57201 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x1857201)
#15 0x0000785d9817c855 (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x1b7c855)
#16 0x0000785d97004824 clang::ParseAST(clang::Sema&, bool, bool) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0xa04824)
#17 0x0000785d98178b71 clang::CodeGenAction::ExecuteAction() (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x1b78b71)
#18 0x0000785d98b14b57 clang::FrontendAction::Execute() (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x2514b57)
#19 0x0000785d98a6c3a6 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x246c3a6)
#20 0x0000785d98b8e45b clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x258e45b)
#21 0x000000000041328b cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/lib/llvm-14/bin/clang+0x41328b)
#22 0x00000000004114bc (/usr/lib/llvm-14/bin/clang+0x4114bc)
#23 0x0000785d986eaed2 (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x20eaed2)
#24 0x0000785d9096bb6d llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0xd6bb6d)
#25 0x0000785d986ea9c0 clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x20ea9c0)
#26 0x0000785d986b5183 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&) const (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x20b5183)
#27 0x0000785d986b540a clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) const (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x20b540a)
#28 0x0000785d986cf507 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x20cf507)
#29 0x0000000000410f26 main (/usr/lib/llvm-14/bin/clang+0x410f26)
#30 0x0000785d8f429d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#31 0x0000785d8f429e40 call_init ./csu/../csu/libc-start.c:128:20
#32 0x0000785d8f429e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#33 0x000000000040e3b5 _start (/usr/lib/llvm-14/bin/clang+0x40e3b5)
clang: error: clang frontend command failed with exit code 139 (use -v to see invocation)
Ubuntu clang version 14.0.0-1ubuntu1.1
Target: bpf
Thread model: posix
InstalledDir: /usr/bin
clang: note: diagnostic msg: 
```

[bug-5cae21.c.txt](https://github.com/user-attachments/files/21541339/bug-5cae21.c.txt)
[bug-5cae21.sh.txt](https://github.com/user-attachments/files/21541340/bug-5cae21.sh.txt)
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJy8mV9z4ygSwD-N8kLZhdAfSw9-UJz4drcyt6nN3t6jC6GWzC4GHaDE3k9_BZIjyZPMZDxTm0qVbQTdv26abkDUGN5IgHWQ3AbJ3Q3t7F7p9f3fgsqKyya8KVV1Wt_SSpxQrfSBWgsV4lJwCYgaA4dSnNCyPFlAFbUUMdoZMIgipqnZo5c9SMTUoeWCy8aJQLeP2yX677xdOtFCnAKyQXv1As-g3Vduhz5gkOkYA2PqTogTorJCf3bGIt5IpcEguwfkIMwS_VtZQHZPLeLSt7daNZoeUAlCvXix9dgfvYCGiWlMaQ3MihMKSBakOCCktw4f7-7dYHws7vrP2-H3_TYgxHfNHfGL6kTlcF9pBxsCXAQkCkiEHnsi15Di_n8T4IJLiw6US6eZ5ChY3boeOKfm4JsGkp6jp-gZegKSB9EwQoPttER4aFjdTVWNHE-Wsr_QXXdoL54_PtwXT_fIdOWBW0RR2TVIQ6u0RVahvbWtCaIiINuAbBtu9125ZOoQkK0Qz-ePRavVn8BsQLbcmA5MQLZ-4rhkoqvAz0EfJSVlf1lNGThjWg2tVs57UCGjOt03u5HUGMU4dfOkO4kM07y1ywAXvSGVMyQqAlzgZYDzwcuI6qY7gLQOGTFBZYMWluoGLCrbGi2YM29ZtvWSoYV6_aECXIROThBtQNVBdI9aqg1oRC0CWSFVo7qfVuK6bVQFqAEJmlquZIALFJAII3zEGONVllQ5plFd4RB5L0VFEBXmZPovj5pL6834vXdENnbS9GWnjNVADwFJfQRL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