Skip to content

C binaries built with zig cc and -Os on macos and linux segfaults #15662

@cryi

Description

@cryi

Zig Version

zig-0.11.0-dev.3050+05ceac52c.tar.xz

Steps to Reproduce and Observed Behavior

  1. git clone --recurse-submodules https://github.com/cryi/eli-zig-os
  2. build build container podman build ./containers/build/ -t elibuild
  3. run build podman run -w "/root/luabuild" -v $(pwd):"/root/luabuild" -v "$(pwd)/toolchains:/opt/cross" -e TOOLCHAINS='zig:x86_64-linux-musl' -it elibuild

It produces binary release/eli-linux-x86_64. It complains about some dependencies missing during the build but ignore that. This is stripped version just for this issue.

Run produced binary:
4. release/eli-linux-x86_64
5. paste in: hash.sha256sum("aa",true) and hit enter to trigger segfault

Everything worked as expected with 0.11.0-dev.1928+3169f0529. I am not sure when was issue introduced but yesterday build (0.11.0-dev.3045+526065723) was affected too.

Notes:

  • if I remove -Os produced binary works as expected
  • to change used compiler edit containers/build/Dockerfile
  • to change compile flags edit CMakeLists.txt#11
  • the code we use to trigger segfault is in lua-mbed-hash module

Expected Behavior

Binaries compiled with -Os and -Oz should not segfault.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions