Strace

591 posts

Strace banner
Strace

Strace

@straceX

Katılım Haziran 2024
35 Takip Edilen8.5K Takipçiler
Strace
Strace@straceX·
an int can’t be 1, 2, and 3 at the same time. so this should never print and it doesn’t. because x has one fixed value, and every comparison uses that same value. but there’s a version of this where it can.
Strace tweet media
English
17
13
317
86.4K
Strace
Strace@straceX·
In late 2023, Voyager 1 started sending garbage data because part of its memory failed. On April 18, 2024, engineers sent a software fix to work around it. The signal took ~22 hours each way. About 2 days later, it started working again.
English
0
1
10
380
Strace
Strace@straceX·
imagine debugging something where every test takes nearly 2 days that’s voyager 1 a command takes ~22 hours to reach it and another ~22 hours to get a response back when its memory started failing, engineers reorganized the code to avoid the damaged parts then sent the patch and waited nearly 2 days to see if it worked.
Strace tweet media
English
1
7
32
2.1K
Strace
Strace@straceX·
fork() doesn’t copy memory it uses copy-on-write. on linux, parent and child share private pages until a write occurs. then a page fault copies that page. writes after fork allocate memory lazily one page at a time.
Strace tweet media
English
5
24
238
7.4K
Strace
Strace@straceX·
on linux, you can restrict a process to a tiny set of syscalls anything else is blocked by the kernel. it’s called seccomp. containers and browsers use seccomp bpf to sandbox code. one mistake, and the kernel kills the process.
Strace tweet media
English
5
39
467
16.1K
Strace
Strace@straceX·
linux doesn’t hide complexity it gives you raw building blocks. files, memory, processes… all flexible, all composable. it feels less like an OS and more like a toolkit for building your own runtime.
English
1
4
41
1.5K
Nyssa
Nyssa@iamnotnyssa·
@straceX yeah that's fair but I wanted to demonstrate this pattern. It's what most multithreaded C standard library implementations use for errno for example
English
2
0
6
1.5K
Strace
Strace@straceX·
@iamnotnyssa oh that’s neat lol, though it’s not a single value anymore it’s changing each time due to the function call. you’re using a function call to change the value. mine was about memory mapped hardware doing it.
English
2
0
28
9.7K
Strace
Strace@straceX·
lol version was sloppy wording (sorry). the point isn’t that the same program behaves differently it’s that this expression patternn: x == 1 && x == 2 && x == 3 is impossible for a stored value, but can be true when each read comes from hardware (via *x). that distinction is the whole point.
English
5
0
45
15.6K
Strace
Strace@straceX·
this isn’t one value, each *x is a separate read. if it points to a memory mapped register, hardware can return a different value every time. so 1, then 2, then 3 all in one condition.
Strace tweet media
English
7
4
112
16.2K
Strace
Strace@straceX·
malloc doesn’t allocate physical memory. it just reserves virtual address space. on linux (overcommit), the kernel says yes even without enough RAM. real allocation happens on first touch (page fault). that’s why OOM crashes happen far from malloc.
Strace tweet media
English
22
46
589
47.2K
Strace
Strace@straceX·
goto in C gets treated like a crime in most tutorials. the linux kernel uses it everywhere for error handling. when you need to clean up multiple resources, it’s often the simplest way to keep things correct.
Strace tweet media
English
150
104
1.4K
100.9K
Strace
Strace@straceX·
it recursively spawns processes, each creating more children until the system runs out of PIDs / CPU / memory. exponential growth lol.
English
0
1
17
781
Strace
Strace@straceX·
a fork bomb. don’t run this.
Strace tweet media
English
5
3
70
3.8K
Strace
Strace@straceX·
spent half a day debugging why gettimeofday() was slower than the work between calls turns out linux maps this thing called the vDSO into every process some calls like clock_gettime() can run from there instead of doing a syscall same function, sometimes no kernel switch that’s why they’re way faster
Strace tweet media
English
5
8
100
8.3K
Strace
Strace@straceX·
played around with namespaces + chroot today kinda wild how close you get to a container with barely any code makes you appreciate what docker is actually doing
Strace tweet media
English
3
10
138
4.9K
Strace
Strace@straceX·
linux exposes every running process as a file. you can cat your own memory map. windows users read this and quit.
Strace tweet media
English
10
26
599
24.8K