This is a maintenance fork
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

89 lines
3.2 KiB

#if 0
│ To the extent possible under law, Justine Tunney has waived │
│ all copyright and related or neighboring rights to this file, │
│ as it is written in the following disclaimers: │
│ • │
│ • │
#include "libc/bits/pushpop.h"
#include "libc/calls/ucontext.h"
#include "libc/log/log.h"
#include "libc/math.h"
#include "libc/nt/enum/errormodeflags.h"
#include "libc/nt/signals.h"
#include "libc/runtime/runtime.h"
#include "libc/stdio/stdio.h"
* @fileoverview Demonstrates SEGFAULT via NULL pointer dereference.
* In MODE=dbg mode, UBSAN should catch this and display a backtrace.
* In most other modes, e.g. MODE=balanced, the oncrash.c sig handler
* will either launch GDB or display a very fancy report.
* make -j8 -O MODE=opt o/opt/examples/
* o/opt/examples/
* To prevent the GDB GUI from popping up:
* export GDB=""
* make -j8 -O MODE=opt o/opt/examples/
* o/opt/examples/
int boo;
void boop(void);
int main(int argc, char *argv[]) {
int64_t res;
res = 0;
asm volatile(
res = *(int *)(intptr_t)boo / boo;
return res;