mirror of
https://github.com/oven-sh/bun
synced 2026-02-12 11:59:00 +00:00
Add a way to voluntarily crash on stack overflow in CI
This commit is contained in:
@@ -1040,6 +1040,7 @@ async function spawnBun(execPath, { args, cwd, timeout, env, stdout, stderr }) {
|
||||
SHELL: shellPath,
|
||||
FORCE_COLOR: "1",
|
||||
BUN_FEATURE_FLAG_INTERNAL_FOR_TESTING: "1",
|
||||
BUN_FEATURE_FLAG_CRASH_ON_STACK_OVERFLOW: "1",
|
||||
BUN_DEBUG_QUIET_LOGS: "1",
|
||||
BUN_GARBAGE_COLLECTOR_LEVEL: "1",
|
||||
BUN_JSC_randomIntegrityAuditRate: "1.0",
|
||||
|
||||
@@ -4,6 +4,12 @@ pub const JSGlobalObject = opaque {
|
||||
}
|
||||
extern fn JSGlobalObject__throwStackOverflow(this: *JSGlobalObject) void;
|
||||
pub fn throwStackOverflow(this: *JSGlobalObject) void {
|
||||
if (comptime bun.Environment.is_canary) {
|
||||
if (bun.getRuntimeFeatureFlag(.BUN_FEATURE_FLAG_CRASH_ON_STACK_OVERFLOW)) {
|
||||
@panic("Stack overflow");
|
||||
}
|
||||
}
|
||||
|
||||
JSGlobalObject__throwStackOverflow(this);
|
||||
}
|
||||
extern fn JSGlobalObject__throwOutOfMemoryError(this: *JSGlobalObject) void;
|
||||
|
||||
@@ -3730,6 +3730,12 @@ pub const StackCheck = struct {
|
||||
// Workaround for lack of branch hints.
|
||||
pub noinline fn throwStackOverflow() StackOverflow!void {
|
||||
@branchHint(.cold);
|
||||
if (comptime bun.Environment.is_canary) {
|
||||
if (bun.getRuntimeFeatureFlag(.BUN_FEATURE_FLAG_CRASH_ON_STACK_OVERFLOW)) {
|
||||
@panic("Stack overflow");
|
||||
}
|
||||
}
|
||||
|
||||
return error.StackOverflow;
|
||||
}
|
||||
const StackOverflow = error{StackOverflow};
|
||||
|
||||
@@ -40,6 +40,8 @@ pub const RuntimeFeatureFlag = enum {
|
||||
BUN_NO_CODESIGN_MACHO_BINARY,
|
||||
BUN_TRACE,
|
||||
NODE_NO_WARNINGS,
|
||||
|
||||
BUN_FEATURE_FLAG_CRASH_ON_STACK_OVERFLOW,
|
||||
};
|
||||
|
||||
/// Enable breaking changes for the next major release of Bun
|
||||
|
||||
Reference in New Issue
Block a user