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

FileSystemRouter causes crash on Windows when handling URL pathnames containing spaces (%20) #12187

Open
qhariN opened this issue Jun 27, 2024 · 1 comment
Labels
crash An issue that could cause a crash windows An issue that only occurs on Windows

Comments

@qhariN
Copy link
Contributor

qhariN commented Jun 27, 2024

How can we reproduce the crash?

When using Bun.FileSystemRouter on Windows, the server crashes if the pathname of the URL contains spaces (encoded as %20). The issue seems to occur during the router.match(url.pathname) call.

const router = new Bun.FileSystemRouter({
  style: 'nextjs',
  dir: './'
})

const server = Bun.serve({
  fetch(req) {
    const url = new URL(req.url)
    const matchedRoute = router.match(url.pathname)
    return new Response(matchedRoute)
  }
})

Relevant log output

panic(main thread): @memcpy arguments alias
oh no: Bun has crashed. This indicates a bug in Bun, not your code.

To send a redacted crash report to Bun's team,
please file a GitHub issue using the link below:

 https://bun.report/1.1.17/wa1bb66bbaAiggBm/ylPs84lP2wr22C_A0eNpzyE3NTS6oVEgsSi/NTc0rKVZIzMlMLAYAae8I7A

Stack Trace (bun.report)

Bun v1.1.17 (bb66bba) on windows x86_64 [AutoCommand]

panic: @memcpy arguments alias

@qhariN qhariN added the crash An issue that could cause a crash label Jun 27, 2024
@github-actions github-actions bot added the windows An issue that only occurs on Windows label Jun 27, 2024
@Jarred-Sumner
Copy link
Collaborator

Jarred-Sumner commented Jun 27, 2024

Debug build stack trace:

panic(main thread): @memcpy arguments alias
/Users/jarred/Code/bun/src/deps/zig/lib/std/io/fixed_buffer_stream.zig:66:57: 0x10335da6f in write (bun-debug)
            @memcpy(self.buffer[self.pos..][0..n], bytes[0..n]);
                                                        ^
/Users/jarred/Code/bun/src/deps/zig/lib/std/io.zig:360:27: 0x10335d6c3 in typeErasedWriteFn (bun-debug)
            return writeFn(ptr.*, bytes);
                          ^
/Users/jarred/Code/bun/src/deps/zig/lib/std/io/Writer.zig:13:24: 0x10335d4bf in write (bun-debug)
    return self.writeFn(self.context, bytes);
                       ^
/Users/jarred/Code/bun/src/deps/zig/lib/std/io/Writer.zig:19:32: 0x102e9bd2f in writeAll (bun-debug)
        index += try self.write(bytes[index..]);
                               ^
/Users/jarred/Code/bun/src/deps/zig/lib/std/io.zig:320:50: 0x103d8cd4b in decodeFaultTolerant__anon_111022 (bun-debug)
            return @errorCast(self.any().writeAll(bytes));
                                                 ^
/Users/jarred/Code/bun/src/http/url_path.zig:77:96: 0x103d8d47f in parse (bun-debug)
        decoded_pathname = possibly_encoded_pathname[0..try PercentEncoding.decodeFaultTolerant(@TypeOf(writer), writer, clone, &needs_redirect, true)];
                                                                                               ^
/Users/jarred/Code/bun/src/bun.js/api/filesystem_router.zig:305:39: 0x103d8ffbf in match (bun-debug)
        const url_path = URLPath.parse(path.slice()) catch |err| {

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 windows An issue that only occurs on Windows
Projects
None yet
Development

No branches or pull requests

2 participants