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

Segmentation fault when using FileSystemRouter as callable function #13670

Closed
userCasWeb opened this issue Sep 1, 2024 · 0 comments
Closed
Labels
crash An issue that could cause a crash macOS An issue that occurs on macOS runtime

Comments

@userCasWeb
Copy link

userCasWeb commented Sep 1, 2024

How can we reproduce the crash?

Make a dir with name 'frontend' and paste some html, css and js files in it. In the cwd make a file 'fileSystemRouter.js'. Then run the 'fileSystemRouter.js' in watch mode.

bun --watch 'fileSystemRouter.js'
// -> fileSystemRouter.js

const router = () => new Bun.FileSystemRouter({
  style: "nextjs",
  dir: process.cwd() + "/frontend",
  assetPrefix: "/",
  fileExtensions: ['.html', '.css', '.js'],
});

console.log(
  router().routes,
  Object.keys(router().routes),
);

const server = Bun.serve({
  port: 8000,
  hostname: '127.0.0.1',
  development: false,
  fetch: async req => {
    const url = new URL(req.url);
    const match = router().match(url.pathname)
    return match
      ? new Response(Bun.file(match.filePath))
      : new Response("404!", { status: '404' });
  }
});

Without console.log it works. No crash. The same goes with commenting one of the log statements or the assetPrefix in the router.

console.log(
  // router().routes,
  Object.keys(router().routes),
);

OR:

console.log(
  router().routes,
  // Object.keys(router().routes),
);

OR:

const router = () => new Bun.FileSystemRouter({
  style: "nextjs",
  dir: process.cwd() + "/frontend",
  // assetPrefix: "/",
  fileExtensions: ['.html', '.css', '.js'],
});

Relevant log output

Bun v1.1.26 (0a37423b) macOS Silicon
macOS v14.6.1
Args: "bun" "--watch" "fileSystemRouter.js"
Features: jsc http_server tsconfig(3) 
Builtins: "bun:main" "node:path" 
Elapsed: 9ms | User: 1242ms | Sys: 2472ms
RSS: 38.70MB | Peak: 38.70MB | Commit: 1.07GB | Faults: 9077

panic(main thread): Segmentation fault at address 0x0

Stack Trace (bun.report)

Bun v1.1.26 (0a37423) on macos aarch64 [AutoCommand]

Segmentation fault at address 0x00000000

  • 2 unknown/js code
  • WTF::StringImpl::destroy
  • FileSystemRouterClass__finalize
  • JSC::PreciseAllocation::sweep
  • JSC::MarkedSpace::sweepPreciseAllocations
  • JSC::Heap::finalize
  • JSC::Heap::handleNeedFinalize
  • JSC::Heap::finishChangingPhase
  • JSC::Heap::runEndPhase
@userCasWeb userCasWeb added the crash An issue that could cause a crash label Sep 1, 2024
@github-actions github-actions bot added macOS An issue that occurs on macOS runtime labels Sep 1, 2024
@userCasWeb userCasWeb changed the title Segmentation fault at address 0x0 Segmentation fault when using FileSystemRouter as callable function Sep 1, 2024
@userCasWeb userCasWeb closed this as not planned Won't fix, can't repro, duplicate, stale Nov 17, 2024
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 macOS An issue that occurs on macOS runtime
Projects
None yet
Development

No branches or pull requests

1 participant