Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught ReferenceError: upper is not defined, uuid_unparse #21056

Closed
taemincho opened this issue Jan 10, 2024 · 1 comment · Fixed by #21062
Closed

Uncaught ReferenceError: upper is not defined, uuid_unparse #21056

taemincho opened this issue Jan 10, 2024 · 1 comment · Fixed by #21062

Comments

@taemincho
Copy link

Please include the following in your bug report:

Version of emscripten/emsdk:

emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.51 (c0c2ca1314672a25699846b4663701bcb6f69cca)
clang version 18.0.0git (https://github.com/llvm/llvm-project f2464ca317bfeeedddb7cbdea3c2c8ec487890bb)
Target: wasm32-unknown-emscripten
Thread model: posix

Failing command line in full:
N/A

Full link command and output with -v appended:

--bind -sENVIRONMENT=shell,web -sSINGLE_FILE=1 -sWASM=1 -sMAXIMUM_MEMORY=4GB -sALLOW_MEMORY_GROWTH=1 -sWASM_ASYNC_COMPILATION=0 -sEXPORTED_FUNCTIONS="['_malloc', '_free']" -O0 --extern-post-js post.js 

I encountered an error: Uncaught ReferenceError: upper is not defined when attempting to load the compiled wasm module. This issue arises from the auto-generated uuid_unparse function, which is missing the upper argument. The problematic portion of the code looks like this:

/** @param {number|boolean=} upper */ function _uuid_unparse(uu, out) {
 uu >>>= 0;
 out >>>= 0;
 var i = 0;
 var uuid = "xxxx-xx-xx-xx-xxxxxx".replace(/[x]/g, function(c) {
  var r = upper ? (HEAPU8[(((uu) + (i)) >>> 0) >>> 0]).toString(16).toUpperCase() : (HEAPU8[(((uu) + (i)) >>> 0) >>> 0]).toString(16);
  r = (r.length === 1) ? "0" + r : r;
  i++;
  return r;
 });
 stringToUTF8(uuid, out, 37);
}

I noticed that when I compiled using version 3.1.37, the correct function signature includes the upper parameter:

function _uuid_unparse(uu, out, upper) {
 var i = 0;
 var uuid = "xxxx-xx-xx-xx-xxxxxx".replace(/[x]/g, function(c) {
  var r = upper ? HEAPU8[uu + i >>> 0].toString(16).toUpperCase() : HEAPU8[uu + i >>> 0].toString(16);
  r = r.length === 1 ? "0" + r : r;
  i++;
  return r;
 });
 stringToUTF8(uuid, out, 37);
}
@sbc100
Copy link
Collaborator

sbc100 commented Jan 10, 2024

Thanks for the report. That does looks like serious issue. I was able to reproduce and bistected the issue to #19740.

Working on a fix now.

sbc100 added a commit to sbc100/emscripten that referenced this issue Jan 10, 2024
When the `__sig` for a function is shorter than the actual number of
argument (i.e. when the native signature is shorter than the JS
signature) we were dropping the extra arguments in handleI64Signatures.

Specifically the `uuid_unparse` library function has a hidden third
argument that is not exposed to native code (doesn't appear in the
native signature).

Fixes: emscripten-core#21056
sbc100 added a commit to sbc100/emscripten that referenced this issue Jan 10, 2024
When the `__sig` for a function is shorter than the actual number of
argument (i.e. when the native signature is shorter than the JS
signature) we were dropping the extra arguments in handleI64Signatures.

Specifically the `uuid_unparse` library function has a hidden third
argument that is not exposed to native code (doesn't appear in the
native signature).

Fixes: emscripten-core#21056
sbc100 added a commit to sbc100/emscripten that referenced this issue Jan 10, 2024
When the `__sig` for a function is shorter than the actual number of
argument (i.e. when the native signature is shorter than the JS
signature) we were dropping the extra arguments in handleI64Signatures.

Specifically the `uuid_unparse` library function has a hidden third
argument that is not exposed to native code (doesn't appear in the
native signature).

Fixes: emscripten-core#21056
sbc100 added a commit to sbc100/emscripten that referenced this issue Jan 10, 2024
When the `__sig` for a function is shorter than the actual number of
argument (i.e. when the native signature is shorter than the JS
signature) we were dropping the extra arguments in handleI64Signatures.

Specifically the `uuid_unparse` library function has a hidden third
argument that is not exposed to native code (doesn't appear in the
native signature).

Fixes: emscripten-core#21056
sbc100 added a commit to sbc100/emscripten that referenced this issue Jan 11, 2024
When the `__sig` for a function is shorter than the actual number of
argument (i.e. when the native signature is shorter than the JS
signature) we were dropping the extra arguments in handleI64Signatures.

Specifically the `uuid_unparse` library function has a hidden third
argument that is not exposed to native code (doesn't appear in the
native signature).

Fixes: emscripten-core#21056
sbc100 added a commit that referenced this issue Jan 11, 2024
When the `__sig` for a function is shorter than the actual number of
argument (i.e. when the native signature is shorter than the JS
signature) we were dropping the extra arguments in handleI64Signatures.

Specifically the `uuid_unparse` library function has a hidden third
argument that is not exposed to native code (doesn't appear in the
native signature).

Fixes: #21056
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants