this post was submitted on 04 Sep 2025
83 points (96.6% liked)
Programmer Humor
26427 readers
800 users here now
Welcome to Programmer Humor!
This is a place where you can post jokes, memes, humor, etc. related to programming!
For sharing awful code theres also Programming Horror.
Rules
- Keep content in english
- No advertisements
- Posts must be related to programming or programmer topics
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
I’m going to whoosh the joke for a moment.
Avoid allocating memory in sig segv handlers. I worked at a company once that had written their own handlers that tried to print a stack trace. I was fortunate enough to find a machine in a test environment that segfaulted while allocating memory. The handler then caused a deadlock in a call to malloc (through new). I ended up rewriting the handler to fix two sources of memory allocation. First I preallocate enough space to do string manipulations in the handler. Second I made eager calls to a few libc functions used in the handler to avoid memory allocation from lazy binding from ld.so.
actually, in the production version i check if the sigsegv handler already got triggered at the start of the handler (to avoid a nested sigsegv) and just exit without any fancy error printing if that happened
i left it out of this meme bc it would've cluttered up the code snippet.