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

assert blows up in v1.3.0 #111

Open
mhmd-azeez opened this issue Dec 3, 2024 · 11 comments
Open

assert blows up in v1.3.0 #111

mhmd-azeez opened this issue Dec 3, 2024 · 11 comments

Comments

@mhmd-azeez
Copy link

index.ts:

import { Test } from "@dylibso/xtp-test";

export function test() {
  Test.assert("test", true, "because it's true");
  return 0;
}

extism-js v1.3.0

PS D:\dylibso\xtp\cli\app> go run . plugin test https://github.com/extism/plugins/releases/latest/download/count_vowels.wasm --with D:\x\extism\assertbug\dist\plugin.wasm
thread '<unnamed>' panicked at crates/core/src/globals.rs:486:26:
called `Option::unwrap()` on a `None` value
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Error: wasm error: unreachable
wasm stack trace:
        .$1260(i32,i32,i32,i32,i32)
        .$1406(i32,i32)
        .$1397(i32,i32,i32)
        .$1422(i32)
        .$68(i32,i32,i32)
        .$364(i32,i32)
        .$363(i32,i64,i64,i32,i32,i32) i64
        .$461(i32,i64,i64,i64,i32,i32,i32) i64
        .$454(i32,i64,i64,i32,i32,i32) i64
        .$461(i32,i64,i64,i64,i32,i32,i32) i64
        .$461(i32,i64,i64,i64,i32,i32,i32) i64
        .$461(i32,i64,i64,i64,i32,i32,i32) i64
        .$227(i32,i32,i32)
        .$1478(i32) i32
        .$1495() i32
Log file: C:\Users\muham\AppData\Local\cache\xtp\xtp-1733249505-27836.log
exit status 1

extism-js v1.2.0

PS D:\dylibso\xtp\cli\app> go run . plugin test https://github.com/extism/plugins/releases/latest/download/count_vowels.wasm --with D:\x\extism\assertbug\dist\plugin.wasm
assert called
🧪 Testing https://github.com/extism/plugins/releases/latest/download/count_vowels.wasm (D:\x\extism\assertbug\dist\plugin.wasm)

PASS ...... test

1/1 tests passed (completed in 42.5µs)

Full Repro: mhmd-azeez/assertbug

@nilslice
Copy link
Member

nilslice commented Dec 3, 2024

hmmm.. maybe the rquickjs runtime doesn't have whatever inner method we're wrapping in JS in the test library.

@mhmd-azeez
Copy link
Author

yeah, the host function in xtp plugin test never gets called, so the glue code breaks down somewhere

@nilslice
Copy link
Member

nilslice commented Dec 3, 2024

It's odd - I don't see anything calling any JS builtin functions that would imply the runtime is missing something:

https://github.com/dylibso/xtp-test-js/blob/main/index.ts#L220-L228

@mhmd-azeez
Copy link
Author

I think @bhelx had some idea what might be going wrong

@nilslice
Copy link
Member

nilslice commented Dec 3, 2024

Ok, the stack says the as_big_int() call fails us

let ptr2 = args
.get(2)
.unwrap()
.as_big_int()
.unwrap()

@mhmd-azeez
Copy link
Author

Ok, the stack says the as_big_int() call fails us

Nice! how did you get the stack? even setting RUST_BACKTRACE didn't give me anything useful!

@nilslice
Copy link
Member

nilslice commented Dec 3, 2024

It's in your initial pasted output 😆 - sorry, not the wasm stack, just Rust's when the code panics

@mhmd-azeez
Copy link
Author

It's in your initial pasted output 😆 - sorry, not the wasm stack, just Rust's when the code panics

I have been staring at this error almost all day, and didn't see that crates/core/src/globals.rs:486:26: line 🤦

@nilslice
Copy link
Member

nilslice commented Dec 3, 2024

Been there, done that! It happens 🙇

@zshipko
Copy link
Contributor

zshipko commented Dec 5, 2024

I think this is because rquickjs is a little more strict about types - we have to use BigInt values for Extism pointer parameters.

It seems like the option with the least friction might be to update the js-pdk to allow BigInt or number arguments for BigInt parameters.

We could also update xtp-test-js to pass arguments as BigInt, which might be a quicker fix.

@mhmd-azeez
Copy link
Author

image

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

No branches or pull requests

3 participants