| Issue |
170339
|
| Summary |
Memory leak in SPIRV?
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
kwk
|
Sorry for this sensational title...
When compiling LLVM with libclc using [`-DLIBCLC_USE_SPIRV_BACKEND=ON`](github.com/llvm/llvm-project/pull/151347) I experience an out of memory error that I captured with valgrind + massif-visualizer in this picture:
<img width="2486" height="1562" alt="image" src="" />
Here are the `massif.out.XXX` files in case you want to take a look yourself: [massif.out.zip](https://github.com/user-attachments/files/23886104/massif.out.zip)
In order to reproduce the issue I've isolated the compile command and the bitcode file (`builtins.link.spirv-mesa3d-.bc`, see [builtins.link.spirv-mesa3d-.zip](https://github.com/user-attachments/files/23887020/builtins.link.spirv-mesa3d-.zip)).
# Reproduction
In order to reproduce the problem on an x86_64 host I use this approach:
## 1. Prepare container (name: ´oomspirv`)
Bring up a fresh Fedora rawhide podman container and install the pre-built clang snapshot from 2025/12/01
**NOTE:** If you try to reproduce the problem with an older version of clang you will get producer/consumer errors.
```console
$ podman pull registry.fedoraproject.org/fedora:rawhide
$ podman rm -f -t 0 oomspirv
$ podman run --name oomspirv -it --rm registry.fedoraproject.org/fedora:rawhide
$ dnf -y install --skip-broken 'dnf-command(copr)' 'dnf5-command(copr)'
$ dnf -y copr enable @fedora-llvm-team/llvm-snapshots-big-merge-20251201
$ dnf install -y clang
```
## 2. Copy bitcode to container
Head over to another terminal an copr the bitcode file into the container:
```console
$ curl -sL -O https://github.com/user-attachments/files/23887020/builtins.link.spirv-mesa3d-.zip
$ unzip builtins.link.spirv-mesa3d-.zip
$ podman cp builtins.link.spirv-mesa3d-.bc oomspirv:/
```
## 3. Let's reproduce the OOM problem
Now, inside the `oomspirv` container, let's run the call that consumes this massive amount of memory:
```console
$ TEMPDIR=$(mktemp -d)
$ clang-22 \
--target=spirv32-- \
-x ir \
-o $TEMPDIR \
./builtins.link.spirv-mesa3d-.bc
```
This results in a `clang-22: error: unable to execute command: posix_spawn failed: No such file or directory` error.
I really hope the SPIRV folks can take a look at this.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs