chung-leong / zigar

Enable the use of Zig code in JavaScript project
https://chung-leong.github.io/zigar/
MIT License
177 stars 2 forks source link

Regression: All sorts of detached ArrayBuffer error on WebAssembly side #404

Closed chung-leong closed 2 months ago

chung-leong commented 2 months ago
  1) Integration tests (rollup-plugin-zigar, Debug)
       should make use of WASI object from Node:
     TypeError: Cannot perform DataView.prototype.getInt32 on a detached ArrayBuffer
      at DataView.getInt32 (<anonymous>)
      at copy8x (file:///tmp/rollup-integration-test/Debug/6c8f41affd97f68c632a5e113f54e2de.mjs:608:26)
      at Object.<anonymous> (file:///tmp/rollup-integration-test/Debug/6c8f41affd97f68c632a5e113f54e2de.mjs:553:5)
      at WebAssemblyEnvironment.updateShadowTargets (file:///tmp/rollup-integration-test/Debug/6c8f41affd97f68c632a5e113f54e2de.mjs:3884:21)
      at WebAssemblyEnvironment.endCall (file:///tmp/rollup-integration-test/Debug/6c8f41affd97f68c632a5e113f54e2de.mjs:4316:10)
      at file:///tmp/rollup-integration-test/Debug/6c8f41affd97f68c632a5e113f54e2de.mjs:4205:25
      at read-file.wasm.host-wasm.runThunk (wasm://wasm/read-file.wasm-00308102:wasm-function[44]:0x2306)
      at read-file.wasm.runThunk (wasm://wasm/read-file.wasm-00308102:wasm-function[43]:0x2211)
      at WebAssemblyEnvironment.runThunk (file:///tmp/rollup-integration-test/Debug/6c8f41affd97f68c632a5e113f54e2de.mjs:4221:25)
      at WebAssemblyEnvironment.invokeThunk (file:///tmp/rollup-integration-test/Debug/6c8f41affd97f68c632a5e113f54e2de.mjs:4354:14)
      at readFile (file:///tmp/rollup-integration-test/Debug/6c8f41affd97f68c632a5e113f54e2de.mjs:3494:21)
      at Context.<anonymous> (file:///home/cleong/zigar/rollup-plugin-zigar/test/integration.test.js:29:26)
  2) Integration tests (rollup-plugin-zigar, Debug)
       Zig Benchmarks Game
         should produce the right results for the k-nucleotide example:
     TypeError: Cannot perform DataView.prototype.getInt32 on a detached ArrayBuffer
      at DataView.getInt32 (<anonymous>)
      at copy8x (file:///tmp/rollup-integration-test/Debug/8ec2c7ff8a9fe2771cd34b2a0f0edd95.mjs:608:26)
      at Object.<anonymous> (file:///tmp/rollup-integration-test/Debug/8ec2c7ff8a9fe2771cd34b2a0f0edd95.mjs:553:5)
      at WebAssemblyEnvironment.updateShadowTargets (file:///tmp/rollup-integration-test/Debug/8ec2c7ff8a9fe2771cd34b2a0f0edd95.mjs:3884:21)
      at WebAssemblyEnvironment.endCall (file:///tmp/rollup-integration-test/Debug/8ec2c7ff8a9fe2771cd34b2a0f0edd95.mjs:4316:10)
      at file:///tmp/rollup-integration-test/Debug/8ec2c7ff8a9fe2771cd34b2a0f0edd95.mjs:4205:25
      at k-nucleotide.wasm.host-wasm.runThunk (wasm://wasm/k-nucleotide.wasm-004b66f2:wasm-function[45]:0x2564)
      at k-nucleotide.wasm.runThunk (wasm://wasm/k-nucleotide.wasm-004b66f2:wasm-function[44]:0x246f)
      at WebAssemblyEnvironment.runThunk (file:///tmp/rollup-integration-test/Debug/8ec2c7ff8a9fe2771cd34b2a0f0edd95.mjs:4221:25)
      at WebAssemblyEnvironment.invokeThunk (file:///tmp/rollup-integration-test/Debug/8ec2c7ff8a9fe2771cd34b2a0f0edd95.mjs:4354:14)
      at kNucleotide (file:///tmp/rollup-integration-test/Debug/8ec2c7ff8a9fe2771cd34b2a0f0edd95.mjs:3494:21)
      at Context.<anonymous> (file:///home/cleong/zigar/zigar-compiler/test/integration/benchmarks-game/tests.js:63:22)
  3) Integration tests (rollup-plugin-zigar, Debug)
       Function calling
         should be able to call a function marked inline:
     TypeError: Cannot perform DataView.prototype.byteLength on a detached ArrayBuffer
      at get byteLength [as byteLength] (<anonymous>)
      at WebAssemblyEnvironment.unlinkObject (file:///tmp/rollup-integration-test/Debug/65167fd3606db948e758edcbe115ee5c.mjs:2819:44)
      at WebAssemblyEnvironment.unlinkVariables (file:///tmp/rollup-integration-test/Debug/65167fd3606db948e758edcbe115ee5c.mjs:2810:12)
      at WebAssemblyEnvironment.abandon (file:///tmp/rollup-integration-test/Debug/65167fd3606db948e758edcbe115ee5c.mjs:2854:12)
      at Object.abandon (file:///tmp/rollup-integration-test/Debug/65167fd3606db948e758edcbe115ee5c.mjs:2842:27)
      at importModule (file:///home/cleong/zigar/rollup-plugin-zigar/test/integration.test.js:51:34)
      at addTests.littleEndian (file:///home/cleong/zigar/rollup-plugin-zigar/test/integration.test.js:32:32)
      at importTest (file:///home/cleong/zigar/zigar-compiler/test/integration/function-calling/tests.js:12:14)
      at Context.<anonymous> (file:///home/cleong/zigar/zigar-compiler/test/integration/function-calling/tests.js:424:38)
      at process.processImmediate (node:internal/timers:478:21)