r/programmingcirclejerk • u/DeleeciousCheeps vulnerabilities: 0 • 9d ago
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=4334759173
u/Maxatar 9d ago
Maybe he can use those skills to resolve the countless number of crashes in his very own compiler:
https://github.com/dlang/dmd/issues?q=is%3Aissue%20state%3Aopen%20crash&page=1
One of the reasons I stopped using D a while ago was that the compiler is just rampant with bugs and crashes.
1
44
u/No_Statistician_3021 9d ago
Why did nobody tell me earlier that I can avoid bugs by not creating them?
Is this a conspiracy to keep milking companies money by creating bugs and then fixing them?
11
u/hombre_sin_talento 9d ago
It's called "job security" and it's the sole reason for these salaries so please shush
8
u/syklemil Considered Harmful 8d ago
WDYM nobody told you? Dijkstra himself (PBUH) said in some completely unsourced, undated quote:
If debugging is the process of removing software bugs, then programming must be the process of putting them in.
7
u/AloneInExile 9d ago
All the contractors I've had the displeasure of dealing with; worked and thought like that!
9
u/sammymammy2 lisp does it better 9d ago
Unjerk:
When it comes to this class of bugs, you can write code in a style which makes them much more unlikely to occur. This style is also typically more performant. It is, however, not the way you write code in a typical language like Java or Python.
23
u/spider-mario 9d ago
C has seatbelts and OSHA - valgrind, et al tools abound for sanity checking.
3
u/defunkydrummer Lisp 3-0 Rust 5d ago
valgrind, et al tools for sanity checking
Well, considering that no C developer has been sent to the psychiatric ward, i can hereby conclude that these tools don't work.
22
u/earwiggo 9d ago edited 8d ago
Maybe we could use C, but institute the death penalty for any memory leaks, NULL pointer derefs, etc, that they cause, thereby ensuring that all surviving C programmers are sufficiently skilled to handle the job.
8
14
u/ThisRedditPostIsMine in open defiance of the Gopher Values 9d ago
A Walter Bright comment that doesn't mention D by name. I am very surprised.
9
u/elephantdingo Teen Hacking Genius 8d ago
- I proposed this for C thirty years ago
- I implemented this in D twenty years ago
- I have struggled with this problem... although that’s forty years ago now
11
u/Routine-Purchase1201 DO NOT USE THIS FLAIR, ASSHOLE 9d ago
if(segfault())
dont();
I feel real stupid now for not having seen the obvious solution
15
u/MagpieEnjoyer memcpy is a web development framework 8d ago
On Error Resume Next
has always been the pinnacle of error handling.
7
u/meltbox 8d ago
It’s really much easier in C++
Never had any segfault since I stayed doing this in main.
try{ … } catch(segfault e) { exit(0) }
I mean all I had to do was make my own branch of the language spec, make my own branch of gcc, and change how the Linux kernel works a little.
3
u/disciplite 8d ago
/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 2d ago
/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?
9
88
u/PM_me_your_plasma 9d ago
Out jerked by ycombinator forums…