Skip to content

Compilation crash targetting wasm with -O2 and reference types #69894

Open
@hoodmane

Description

@hoodmane

Tested against:

Ubuntu clang version 17.0.3 (++20231017073226+888437e1b600-1exp120231017073338.54)
clang version 18.0.0 (https://github.com/llvm/llvm-project d1e685d)

cc @sbc100 @pmatos

testcase.c

__externref_t foo(void);
void bar(__externref_t);

void
test(int flag, __externref_t ref1, __externref_t ref2)
{
  if (flag) {
    ref1 = foo();
    ref2 = foo();
  }
  bar(ref1);
  bar(ref2);
}

Compilation command:

clang -c testcase.c -O2   -mreference-types -target wasm32-unknown-unknown

The files it asked me to upload:

testcase-ccc7e1.c

# 1 "<built-in>"
# 1 "testcase.c"
__externref_t foo(void);
void bar(__externref_t);

void
test(int flag, __externref_t ref1, __externref_t ref2)
{
  if (flag) {
    ref1 = foo();
    ref2 = foo();
  }
  bar(ref1);
  bar(ref2);
}

testcase-ccc7e1.sh

# Crash reproducer for Ubuntu clang version 17.0.3 (++20231017073226+888437e1b600-1~exp1~20231017073338.54)
# Driver args: "-c" "testcase.c" "-O2" "-mreference-types" "-target" "wasm32-unknown-unknown"
# Original command:  "/usr/lib/llvm-17/bin/clang" "-cc1" "-triple" "wasm32-unknown-unknown" "-emit-obj" "-disable-free" "-clear-ast-before-backend" "-disable-llvm-verifier" "-discard-value-names" "-main-file-name" "testcase.c" "-mrelocation-model" "static" "-mframe-pointer=none" "-ffp-contract=on" "-fno-rounding-math" "-mconstructor-aliases" "-target-cpu" "generic" "-target-feature" "+reference-types" "-fvisibility=hidden" "-debugger-tuning=gdb" "-fcoverage-compilation-dir=/home/hood/Documents/programming/pyodide" "-resource-dir" "/usr/lib/llvm-17/lib/clang/17" "-internal-isystem" "/usr/lib/llvm-17/lib/clang/17/include" "-O2" "-fdebug-compilation-dir=/home/hood/Documents/programming/pyodide" "-ferror-limit" "19" "-fgnuc-version=4.2.1" "-fcolor-diagnostics" "-vectorize-loops" "-vectorize-slp" "-o" "testcase.o" "-x" "c" "testcase.c"
 "/usr/lib/llvm-17/bin/clang" "-cc1" "-triple" "wasm32-unknown-unknown" "-emit-obj" "-disable-free" "-clear-ast-before-backend" "-disable-llvm-verifier" "-discard-value-names" "-main-file-name" "testcase.c" "-mrelocation-model" "static" "-mframe-pointer=none" "-ffp-contract=on" "-fno-rounding-math" "-mconstructor-aliases" "-target-cpu" "generic" "-target-feature" "+reference-types" "-fvisibility=hidden" "-debugger-tuning=gdb" "-fcoverage-compilation-dir=/home/hood/Documents/programming/pyodide" "-O2" "-fdebug-compilation-dir=/home/hood/Documents/programming/pyodide" "-ferror-limit" "19" "-fgnuc-version=4.2.1" "-fcolor-diagnostics" "-vectorize-loops" "-vectorize-slp" "-x" "c" "testcase-ccc7e1.c"

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions