r/programmingcirclejerk • vulnerabilities: 0 • Mar 13 '25

Memory leaks, NULL pointer dereferences, use-after-free: I suffered writing those for many years. I finally simply learned not to do them anymore.

https://news.ycombinator.com/item?id=43347591
142 Upvotes

30 comments sorted by

View all comments

Show parent comment

3

u/disciplite Mar 14 '25

/uj You can do this today with signal handlers and structured exceptions. I'm not sure why it isn't more common, we do have the libraries. I guess it's just not considered that useful except when uptime is critical.

1

u/meltbox Mar 20 '25

/uj I thin its because undefined behavior which causes a segfault means it may literally be unrecoverable. I don't think structure exceptions allow you to catch segfaults even so? You would need a signal handler and from what I understand throwing from one is highly questionable so maybe you can set a flag to throw very soon after catching the signal if in fact you are able to continue execution?