Skip to content

Segmenation fault on bash if a specific script is executed only and compiled with clang #111574

@0xIO32

Description

@0xIO32

Bash crashes with a segmentation fault if executed with this specific script (context below) and if compiled with clang. The issue does not exist, if compiled with gcc.
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

It has been tested using clang-19 and "GNU bash, version 5.2.37(1)-release"

Metadata

Metadata

Assignees

No one assigned

    Labels

    clangClang issues not falling into any other categoryneeds-reductionLarge reproducer that should be reduced into a simpler form

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions