parse exception: popping from empty stack

Aperta
#27,525 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
45/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
c, cpp, shell, wasm
Ambito
compilers

Direzione di ricerca

Esegui lo script shell di riproduzione fornito con emcc ed em++; ispeziona il out.wasm generato intorno al passaggio wasm-opt --safe-heap e usa wasm-validate --enable-all quando disponibile. Il lavoro è completato quando la riproduzione non fa più sì che wasm-opt segnali “popping from empty stack” e il linking venga completato correttamente.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Please include the following in your bug report:

Version of emscripten/emsdk:

emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 6.0.5-git
clang version 24.0.0git
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /opt/homebrew/Cellar/emscripten/6.0.5/libexec/llvm/bin

Failing command line in full:

$ em++ -v $LINK_FLAGS -o out.js main.o functable.o
 /opt/homebrew/Cellar/emscripten/6.0.5/libexec/llvm/bin/clang --version
 /opt/homebrew/Cellar/emscripten/6.0.5/libexec/llvm/bin/wasm-ld -o out.wasm /var/folders/tn/r_t_4vv55572jny2jgw1082r0000gq/T/tmp3ne1o_u7libemscripten_js_symbols.so -Bstatic --import-undefined --strip-debug --export-if-defined=malloc --export-if-defined=sbrk --export-if-defined=emscripten_stack_get_end --export-if-defined=emscripten_stack_get_free --export-if-defined=emscripten_stack_get_base --export-if-defined=emscripten_stack_get_current --export-if-defined=emscripten_stack_init --export-if-defined=_emscripten_stack_alloc --export-if-defined=emscripten_get_sbrk_ptr --export-if-defined=__wasm_call_ctors --export-if-defined=_emscripten_stack_restore --export-if-defined=__start_em_asm --export-if-defined=__stop_em_asm --export-if-defined=__start_em_lib_deps --export-if-defined=__stop_em_lib_deps --export-if-defined=__start_em_js --export-if-defined=__stop_em_js --export-if-defined=main --export-if-defined=__main_argc_argv --export-if-defined=fflush --export-table -z stack-size=65536 --no-growable-memory --initial-heap=16777216 --no-entry --stack-first --table-base=1 main.o functable.o -L/opt/homebrew/Cellar/emscripten/6.0.5/libexec/cache/sysroot/lib/wasm32-emscripten -L/opt/homebrew/Cellar/emscripten/6.0.5/libexec/src/lib -lGL-getprocaddr -lal -lhtml5 -lstubs-debug -lnoexit -lc-debug -ldlmalloc-debug -lclang_rt.builtins -lc++-debug-noexcept -lc++abi-debug-noexcept -lsockets -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr
 /opt/homebrew/Cellar/emscripten/6.0.5/libexec/llvm/bin/llvm-objcopy out.wasm out.wasm '--remove-section=llvm.func_attr.annotate.*' --remove-section=producers --remove-section=name '--remove-section=.debug*'
em++: warning: warnings in JS library compilation [-Wjs-compiler]
 /opt/homebrew/Cellar/emscripten/6.0.5/libexec/binaryen/bin/wasm-opt --safe-heap out.wasm -oout.wasm --mvp-features --enable-bulk-memory --enable-bulk-memory-opt --enable-call-indirect-overlong --enable-multivalue --enable-mutable-globals --enable-nontrapping-float-to-int --enable-reference-types --enable-sign-ext
[parse exception: popping from empty stack (at 0:683)]
Fatal: error parsing wasm (try --debug for more info)
em++: error: '/opt/homebrew/Cellar/emscripten/6.0.5/libexec/binaryen/bin/wasm-opt --safe-heap out.wasm -o out.wasm --mvp-features --enable-bulk-memory --enable-bulk-memory-opt --enable-call-indirect-overlong --enable-multivalue --enable-mutable-globals --enable-nontrapping-float-to-int --enable-reference-types --enable-sign-ext' failed (returned 1)

Full link command and output with -v appended:

Here's a repro script you can modify or use as is:

#!/bin/bash
set -e

WORKDIR=$(mktemp -d)
cd "$WORKDIR"
echo "Working in $WORKDIR"

cat > functable.c << 'EOF'
void (*t)();
void x();
void o() {
  void (*local)() = x;
  __atomic_store(&t, &local, 5);
  __atomic_thread_fence(5);
  t();
}
EOF

cat > main.cxx << 'EOF'
#include <emscripten.h>
extern "C" void o();
extern "C" EMSCRIPTEN_KEEPALIVE void load() {
    o();
}
EOF

echo "--- compiling functable.c (-O1 -fPIC) ---"
emcc -O1 -fPIC -c -o functable.o functable.c

echo "--- compiling main.cxx ---"
em++ -c -o main.o main.cxx

echo "--- linking ---"
LINK_FLAGS="-sASSERTIONS -sERROR_ON_UNDEFINED_SYMBOLS=0 -sSAFE_HEAP=1 -sEXPORTED_FUNCTIONS=_malloc"

set +e
em++ $LINK_FLAGS -o out.js main.o functable.o
LINK_STATUS=$?
set -e

echo
echo "=== link exit status: $LINK_STATUS ==="
if [ -f out.wasm ]; then
  echo "=== wasm-validate output ==="
  if command -v wasm-validate >/dev/null 2>&1; then
    wasm-validate --enable-all out.wasm || true
  else
    echo "wasm-validate not found on PATH"
  fi
else
  echo "out.wasm was not produced"
fi

echo
if [ "$LINK_STATUS" -ne 0 ]; then
  echo "reproduces"
else
  echo "failed to reproduce"
fi
Lingua principale
C++
Stelle
27.8k
Fork
3.6k
Merge medio
1g 6h
PR unite (30g)
181

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di emscripten-core/emscripten

Tutte le issue di emscripten-core/emscripten

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.