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

Crash when FFi involves variables for nested structures #17482

Closed
AntoninRousset opened this issue Jan 20, 2023 · 1 comment · Fixed by #18531
Closed

Crash when FFi involves variables for nested structures #17482

AntoninRousset opened this issue Jan 20, 2023 · 1 comment · Fixed by #18531
Labels
bug Something isn't working correctly FFI Related to Foreign Function Interface APIs

Comments

@AntoninRousset
Copy link

I like to use variables to define types in my symbols definition, but it makes Deno crash when used in nested structures:

const a_t = {
  struct: ["i32"]
}

const lib = Deno.dlopen(
  "./lib.so",
  {
    f: {
      parameters: [],
      result: {struct: [a_t, a_t]}
    }
  }
)

lib.symbols.f()

However, it does not crash for these result definitions:

{struct: [a_t]}
{struct: [{...a_t}, {...a_t}]}
{struct: [{struct: ["i32"]}, {struct: ["i32"]}]}

The lib source is irrelevant, but I past it here for reference:

typedef struct {
  int value;
} a_t;

typedef struct {
  a_t a1;
  a_t a2;
} b_t;

b_t f() {
  b_t s = {{},{}};
  return s;
}

backtrace.txt

@aapoalas
Copy link
Collaborator

Hmm. Good find. I know from personal experience that nested structs do work but I'm guessing that having the same struct in two positions causes some unforeseen issue to emerge.

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

Successfully merging a pull request may close this issue.

3 participants