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

u64 result type is not working as expected in ffi/dlopen #12212

Closed
cztomsik opened this issue Sep 24, 2021 · 3 comments
Closed

u64 result type is not working as expected in ffi/dlopen #12212

cztomsik opened this issue Sep 24, 2021 · 3 comments
Labels
bug Something isn't working correctly FFI Related to Foreign Function Interface APIs

Comments

@cztomsik
Copy link

cztomsik commented Sep 24, 2021

if you return u64::MAX from rust and then use dlopen() with { ..., result: u64 } you will get a different value in JS.

It does exactly the same thing if you input it to a deno console but that's probably unrelated:

Deno 1.14.0
exit using ctrl+d or close()
> 18446744073709551615
18446744073709552000
> 

Maybe this is expected behavior but it should be at least documented and I would say it's not terribly useful then for native plugins. Maybe it should return BigInt instead?

rust example:

#[no_mangle]
pub extern "C" fn test_u64() -> u64 {
    u64::MAX
}

deno

const lib = Deno.dlopen(libFile, {
    test_u64: { parameters: [], result: 'u64' }
}
lib.symbols.test_u64() // should return u64::MAX, probably as BigInt but it doesnt
@bartlomieju bartlomieju added the bug Something isn't working correctly label Sep 24, 2021
@kevinkassimo
Copy link
Contributor

The internal serdes library serde_v8 forwards all f32/f64/u64 to f64 (normal JS numbers). Opened an issue there: https://github.com/denoland/serde_v8/issues/43

@irbull
Copy link
Contributor

irbull commented Nov 2, 2021

The internal serdes library serde_v8 forwards all f32/f64/u64 to f64 (normal JS numbers). Opened an issue there: denoland/serde_v8#43

It looks like that repository has been archived. There is some good discussion on that thread about opaque pointers. Should that discussion be moved here?

@crowlKats crowlKats added the FFI Related to Foreign Function Interface APIs label Nov 30, 2023
@lucacasonato
Copy link
Member

This is now fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly FFI Related to Foreign Function Interface APIs
Projects
None yet
Development

No branches or pull requests

7 participants