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

Reliable segfault in Bun - running some transformers.js code #6089

Closed
swyxio opened this issue Sep 27, 2023 · 5 comments
Closed

Reliable segfault in Bun - running some transformers.js code #6089

swyxio opened this issue Sep 27, 2023 · 5 comments
Labels
bug Something isn't working crash An issue that could cause a crash napi Compatibility with the native layer of Node.js

Comments

@swyxio
Copy link

swyxio commented Sep 27, 2023

What version of Bun is running?

1.0.0+822a00c4d508b54f650933a73ca5f4a3af9a7983

What platform is your computer?

Darwin 21.6.0 arm64 arm

What steps can reproduce the bug?

run bun segfault.js and the source of bun segfault.js contains:

import { pipeline } from "@xenova/transformers";
export class SmolVector {
  store = [];
  similarityFn = (a, b) => dot(a, b) / (norm(a) * norm(b));
  constructor(extractor) {
    (async () => {
      this.extractor =
        extractor ??
        (await pipeline("feature-extraction", "Xenova/all-MiniLM-L6-v2"));
      console.log("hiiii");
    })();
  }
  async add(objects) {
    // in parallel, check if item already has an embedding, and if not, run it through extractor
    await Promise.all(
      objects.map(async (object) => {
        if (typeof object === "string") object = { chunk: object }; // reformat it
        object.id = object.id ?? randID();
        object.embedding =
          object.embedding ?? (await this.extractor(object.chunk).data);
        this.store.push(object);
      })
    );
  }
}

const myDB = new SmolVector();
await myDB.add([
  "strawberry",
  "mango",
  "pineapple",
  "duck",
  "dog",
  "horse",
  "armadillo",
]);

What is the expected behavior?

code should just run

What do you see instead?

image

Additional information

No response

@swyxio swyxio added the bug Something isn't working label Sep 27, 2023
@Jarred-Sumner
Copy link
Collaborator

Can you try upgrading to v1.0.3 and see if it reproduces? We fixed crashes like this in-between

@swyxio
Copy link
Author

swyxio commented Sep 27, 2023

unfortunately yes
image

@Electroid Electroid added the crash An issue that could cause a crash label Sep 27, 2023
@Jarred-Sumner Jarred-Sumner added the napi Compatibility with the native layer of Node.js label Sep 27, 2023
@Jarred-Sumner
Copy link
Collaborator

Definitely a napi bug

@wzulfikar
Copy link

wzulfikar commented Sep 29, 2023

This should be duplicate of #4619 (and perhaps #3574)? Been keeping a tab on both because can't wait to try transformers with Bun ❤️

@Electroid
Copy link
Contributor

Duplicate of #4619

@Electroid Electroid marked this as a duplicate of #4619 Oct 27, 2023
@Electroid Electroid closed this as not planned Won't fix, can't repro, duplicate, stale Oct 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working crash An issue that could cause a crash napi Compatibility with the native layer of Node.js
Projects
None yet
Development

No branches or pull requests

4 participants