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

Bun.plugin segfault #16672

Open
huseeiin opened this issue Jan 23, 2025 · 0 comments
Open

Bun.plugin segfault #16672

huseeiin opened this issue Jan 23, 2025 · 0 comments
Labels
crash An issue that could cause a crash linux An issue that occurs on Linux

Comments

@huseeiin
Copy link
Contributor

huseeiin commented Jan 23, 2025

How can we reproduce the crash?

plugin.ts

import { writeFileSync } from "fs";
import { dirname, resolve } from "path";

Bun.plugin({
  name: "toml",
  setup(build) {
    build.onResolve({ filter: /\.toml$/ }, (args) => {
      const path = resolve(dirname(args.importer), args.path);
      writeFileSync(
        `${path}.d.ts`,
        `export default ${JSON.stringify(require(path))}`
      );
      return { path };
    });
  },
});

then register it as a plugin with bunfig.toml:

preload = "./plugin.ts"

and run this code:

test.ts

import bunfig from "./bunfig.toml";
console.log(bunfig);

Relevant log output

i sometimes also got this:

1 | import bunfig from "./bunfig.toml";
2 | console.log(bunfig);
    ^
SyntaxError: Unexpected token ')'
      at <parse> (/home/hussein/project/test.ts:2:1)

Stack Trace (bun.report)

Bun v1.1.44-canary (8c04818) on linux x86_64 [AutoCommand]

Segmentation fault at address 0x00000000

Features: tsconfig_paths, bunfig, jsc, tsconfig, tsconfig

Sentry Issue: BUN-BR6

@huseeiin huseeiin added the crash An issue that could cause a crash label Jan 23, 2025
@github-actions github-actions bot added the linux An issue that occurs on Linux label Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crash An issue that could cause a crash linux An issue that occurs on Linux
Projects
None yet
Development

No branches or pull requests

1 participant