I tried to break as much Rust rules as possible within unsafe blocks just to replace (2+3) * 2.
Also I probably made the most unconvertable, Linux-only code possible. But somehow, it works, even with using FFI setjmp and longjmp across Rust stack frames, which breaks LLVM's control flow graph and ignores Drop semantics. UB bingo code.
Exactly what i did:
- STATIC MUT :)) with zero synchronization.
- Reading and writing the program's own memory by opening /proc/self/mem and using the process_vm_readv syscall.
- Storing the variable inside the x86 GS segment register via arch_prctl, and hiding it inside the OS thread name via prctl(PR_SET_NAME).
- Deconstructing &dyn Op and dyn Any into raw [usize; 2] fat pointers, manually calculating vtable offsets, and executing the raw function pointers (add, extract).
- Overwriting an AtomicI32 by using a raw FFI memcpy on its memory address instead of atomic operations.
...and much more weird things.