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

    <tr>
        <th>Summary</th>
        <td>
            Segmenation fault on bash if a specific script is executed only and compiled with clang
        </td>
    </tr>

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

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

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

<pre>
    Bash crashes with a segmentation fault if executed with this specific script (context below) and if compiled with clang.
I didn't use lto or -O3. This happens with "-march=native -O2 -pipe".

**Steps to reproduce:**
- Compile bash with clang
- Go to/Create a empty test directory
- create these directories "out/target/product/beyond2lte/obj/PACKAGING/apkcerts_intermediates/"
- copy the script to this location "out/target/product/beyond2lte/obj/PACKAGING/apkcerts_intermediates/lineage_beyond2lte-apkcerts.txt.sh"
- run the script using "bash out/target/product/beyond2lte/obj/PACKAGING/apkcerts_intermediates/lineage_beyond2lte-apkcerts.txt.rsp"

**What should happen:**
The bash script should generate the "out/target/product/beyond2lte/obj/PACKAGING/apkcerts_intermediates/lineage_beyond2lte-apkcerts.txt" file.

**What does happen:**
Bash crashes with a segmentation fault.

**Context:**
I don't know why this happens (I am not an expert). This bash script was created as part of the Android Open-Source Project build process (while I tried to compile android). It has been automatically created using Makefile files. I wasn't able to reproduce the issue with another bash script. There is something special about this one, maybe the size? (it just echos and appends data to a txt file, you can execute inside docker, a vm or whatever if you don't trust its content).

**It only crashes if bash is compiled with clang.**

The bash script: (the .txt extension only exists because github doesn't allow .sh or the .rsp extension)
[lineage_beyond2lte-apkcerts.txt.rsp.txt](https://github.com/user-attachments/files/17297549/lineage_beyond2lte-apkcerts.txt.rsp.txt)


</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzEVkFv2zgT_TX0ZWDDoqzEPuiQJlBhfOjXAi2wx2JEji02FCmQo9jeX78gJSfebrDo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