oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
74.43k stars 2.78k forks source link

Bun crashing when using my Timing class #12982

Open simplyzetax opened 3 months ago

simplyzetax commented 3 months ago

How can we reproduce the crash?

Bun crashes when using this code:

import chalk from 'chalk';

class Timing {
    private start: number;
    private date: number;
    private nick: string;

    constructor(nick: string) {
        this.start = Bun.nanoseconds();
        this.date = Date.now();
        this.nick = nick;
    }

    public get startDateIso() {
        return new Date(this.date).toISOString();
    }

    public get duration() {
        const ms = (Bun.nanoseconds() - this.start) / 1000000;
        return ms;
    }

    public get durationString() {
        return `${this.duration}ms`;
    }

    public print() {
        console.log(chalk.gray(`${this.startDateIso}`), chalk.bgBlue(`${this.nick} `), chalk.gray(`${this.durationString}`));
    }
}

export default Timing;

Relevant log output

Query: select "account_id", "launcher_token", "display_name", "banned", "discord_id", "email" from "accounts" where "accounts"."launcher_token" = $1 -- params: ["123"]
2024-07-31T22:56:03.744Z launcher websocket  80.5751ms
Connection opened
============================================================
Bun v1.1.21 (70ca2b76) Windows x64
CPU: sse42 avx avx2
Args: "C:\Users\finni\.bun\bin\bun.exe" "run" ".\src\index.ts"
Features: jsc Bun.stdin(2) dotenv http_server transpiler_cache tsconfig(2) 
Builtins: "bun:main" "node:buffer" "node:crypto" "node:dns" "node:events" "node:fs/promises" "node:net" "node:os" "node:process" "node:stream" "node:string_decoder" "node:tls" "node:tty" "node:util" "node:util/types" 
Elapsed: 1547ms | User: 31ms | Sys: 31ms
RSS: 0.20GB | Peak: 0.20GB | Commit: 0.27GB | Faults: 49336

panic(main thread): Segmentation fault at address 0x7FFFFFFF
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.21/wr170ca2b7AqoghwC_mj+70C+mk5RoijsM___A2A+/////D

Stack Trace (bun.report)

Bun v1.1.21 (70ca2b7) on windows x86_64 [AutoCommand]

Segmentation fault at address 0x6C7000006B4

Jarred-Sumner commented 3 months ago

Please provide a complete reproduction. This isn't enough to reproduce the issue.

github-actions[bot] commented 3 months ago

Hello @simplyzetax. Please provide a minimal reproduction using a GitHub repository, Replit, or CodeSandbox. Issues marked with needs repro will be closed if they have no activity within 3 days.

cirospaciari commented 3 months ago

Friday we added some fixes on server.zig, can you try bun upgrade --canary and check if is still happening?