Skip to content

Commit 3d8a973

Browse files
jpnurmiclaude
andcommitted
test(oom): crash explicitly when malloc returns NULL
Raise an exception (Windows) or write to an invalid address (Unix) when malloc fails, matching how UE terminates on OOM. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent b9a945c commit 3d8a973

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

examples/example.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,13 @@ trigger_oom(void)
387387
size_t count = 1024;
388388
for (;;) {
389389
void *p = malloc(count);
390-
(void)p;
390+
if (!p) {
391+
#ifdef SENTRY_PLATFORM_WINDOWS
392+
RaiseException(0xc000, 0, 0, NULL);
393+
#else
394+
*((volatile int *)3) = 1;
395+
#endif
396+
}
391397
count *= 2;
392398
}
393399
}

0 commit comments

Comments
 (0)