denoland / deno_bindgen

Write high-level Deno FFI libraries in Rust.
MIT License
275 stars 28 forks source link

Bug: Program crash after deno_bindgen rebuild #75

Closed kayac-chang closed 2 years ago

kayac-chang commented 2 years ago

Environment:

OS:

MacOS Monterey version 12.4

Hardware:

Model Name: MacBook Pro Chip: Apple M1 Memory: 16 GB

Steps To Reproduce

  1. first run deno_bindgen to build first ffi
  2. run deno run --allow-all --unstable main.ts, we can get Hello, world print out
  3. update src/lib.rs source code, like change Hello, world to Hello, kirby
  4. run deno_bindgen again
  5. run deno run --allow-all --unstable main.ts will crash without any error
$ deno run --allow-all --unstable main.ts                                                                                                                
[1]    11128 killed     deno run --allow-all --unstable main.ts

Link to code example: https://github.com/kayac-chang/test-deno-bindgen

Problem

I think because of this line, but I don't know the reason why need to use system cache, because there's no useful document to point out intention.

Temporary Solution

Currently, I fork plug and add the following code to skip the cache, this will solve the issue temporarily.

  ...

  if (options.policy === CachePolicy.NONE) {
    return new URL(url).pathname;
  }

  const file = await plug.cache(url, policy);

  return file.path;
}
skanehira commented 2 years ago

I'm facing this problem too. When cache policy is NONE, x/cache will always copy ./target/debug/*.lib to cache directory. So the lib in cache will always have a new but Deno.dlpopen didn't work.