oven-sh / bun

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

Bun Seg fault #13026

Open szabbbbu opened 3 months ago

szabbbbu commented 3 months ago

How can we reproduce the crash?

Segmentation fault happened apparently when bun was parsing enums

Relevant log output

<-- GET /owner/home
27 |             <OwnerEditPencil tableToEdit={DB_TABLE_NAMES.} />
                                                              ^
error: Expected identifier but found "}"
============================================================
Bun v1.1.21 (70ca2b76) macOS Silicon
macOS v14.4.1
Args: "bun" "run" "--hot" "src/index.tsx"
Features: jsc dotenv(2) http_server transpiler_cache(29) tsconfig 
Builtins: "bun:main" "node:buffer" "node:crypto" "node:events" "node:fs" "node:net" "node:path" "node:stream" "node:string_decoder" "node:timers" "node:tls" "node:tty" "node:url" "node:util" "node:util/types" 
Elapsed: 336920ms | User: 3436ms | Sys: 641ms
RSS: 1.17GB | Peak: 1.17GB | Commit: 0.02ZB | Faults: 68

panic: Segmentation fault at address 0x46976000000
Crashed while parsing /Users/robertszabo/Documents/WORK/AKROPOLEISZ_ADMIN/adminsite/src/Databases/Types/ENUMS.ts
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/Mr170ca2b7AioghwC__+645X20z2Vus16R+u96R2iv6Rmnt9Rmy1jTmso9OA2ymCggggg2D

error: script "dev" was terminated by signal SIGTRAP (Trace or breakpoint trap)
[1]    4804 trace trap  bun dev

Stack Trace (bun.report)

Bun v1.1.21 (70ca2b7) on macos aarch64 [RunCommand]

Segmentation fault at address 0x46976000000

Jarred-Sumner commented 3 months ago

Can you paste the source file where this happened? It likely contains that string - <OwnerEditPencil tableToEdit={DB_TABLE_NAMES.

If you can paste the entire file exactly as-is, that would be especially helpful

szabbbbu commented 3 months ago

sure, i was in the middle of renaming string literals to enum values when it happened this is a hono/htmx app where the EditPencil component assembles a url

import GetGroupClassNameByCode from "../../../../Databases/DB_OPERATIONS/GetGroupClassNameByCode";
import { DB_TABLE_NAMES, GC_COL_NAMES } from "../../../../Databases/Types/ENUMS";
import OwnerEditPencil from "../Icons/OwnerEditPencil.icon";

type Props = {
    classCode: string;
    engName?: string;
}

export default async function ClassEnglishName({classCode, engName}: Props) {

    const findName: {name: string} | null = !engName ? 
        await GetGroupClassNameByCode(classCode, "en")
    : 
        {
            name: engName 
        };

    if (!findName) return <></>
    return (
        <ul class="flex space-x-4 items-center">
            <span class="text-xl ml-4">
                {findName.name}
            </span>
            <OwnerEditPencil tableToEdit={DB_TABLE_NAMES.group_class} columnToEdit={GC_COL_NAMES.EnglishName} id={classCode} />
        </ul>
    );
}
import { DB_TABLE_NAMES } from "../../../../Databases/Types/ENUMS";

type Props = {
    id: string;
    tableToEdit: DB_TABLE_NAMES;
    columnToEdit: string;
}

/**
 * 
 *
 * should be able to get the edit form endpoint for multiple tables and columns
 */
export default function OwnerEditPencil({tableToEdit,columnToEdit,id}: Props) {

    const evalUrlForTableAndCol = () => {
        switch (tableToEdit) {
            case DB_TABLE_NAMES.group_class:  
                return `gc-controls/editgc/${columnToEdit}`
            default:
                return '/dsfsavewvews'
        }
    }

    return (
        <svg
        class={`hover:scale-110 rounded-sm justify-self-end`}
            hx-get={`/owner/${evalUrlForTableAndCol()}/${id}`}
            hx-swap="outerHTML"
            hx-target="closest ul"
            width="22" 
            height="22"
            viewBox="0 0 15 15"
        >
            <path d="M11.8536 1.14645C11.6583 0.951184 11.3417 0.951184 11.1465 1.14645L3.71455 8.57836C3.62459 8.66832 3.55263 8.77461 3.50251 8.89155L2.04044 12.303C1.9599 12.491 2.00189 12.709 2.14646 12.8536C2.29103 12.9981 2.50905 13.0401 2.69697 12.9596L6.10847 11.4975C6.2254 11.4474 6.3317 11.3754 6.42166 11.2855L13.8536 3.85355C14.0488 3.65829 14.0488 3.34171 13.8536 3.14645L11.8536 1.14645ZM4.42166 9.28547L11.5 2.20711L12.7929 3.5L5.71455 10.5784L4.21924 11.2192L3.78081 10.7808L4.42166 9.28547Z" fill="#000" fill-rule="evenodd" clip-rule="evenodd">
            </path>
        </svg>
    )
}

this is the enum file:

export enum DB_TABLE_NAMES { group_class = "group_class", group_class_rsvp = "group_class_rsvp", student = "student", student_registration_session = "student_registration_session", student_session = "student_session", owner = "owner", owner_session = "owner_session", password_reset = "password_reset", trainer = "trainer", trainer_session = "trainer_session" }

//group class editable fields export enum GC_COL_NAMES { TrainerID = "TrainerID", ClassType = "ClassType", MeetingTimes = "meetingtimes", //meta descriptor for ClassDate, MeetingStart, MeetingEnd MeetingRoom = "MeetingRoom", SkillLevel = "SkillLevel", SeatLimit = "SeatLimit", NumReservations = "NumReservations", WaitListLimit = "WaitListLimit", Language = "Language", TrainerEmail = "TrainerEmail", ClassCode = "ClassCode", EnglishName = "EnglishName" }