this post was submitted on 03 Sep 2024
852 points (99.4% liked)

Programmer Humor

32490 readers
594 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 
top 50 comments
sorted by: hot top controversial new old
[–] [email protected] 0 points 1 month ago
[–] [email protected] 3 points 2 months ago
[–] [email protected] 4 points 2 months ago

this happens with so many scripts I've tried to debug with strace because strace requires to run as root or sudo which elevates the niceness of process which prevents certain errors from occuring when the script is run with root permissions and so it runs flawlessly without bugs and you sit wondering wtf

[–] [email protected] 12 points 2 months ago (1 children)

Heisenbug. Nasty buggers, especially in my domain: Embedded Engineering. When you are in the debugger, the whole processor is stopped, missing tons of data coming in, missing interrupts, getting network timeouts, etc. More often than not, resuming makes no sense, and you have to get straight to reboot.

[–] [email protected] 7 points 2 months ago (1 children)

"You don't debug embedded" ~my brother, who's been working in embedded for almost 15 years

[–] [email protected] 1 points 2 months ago

That's why I work with an extraordinary diligence to avoid making errors from the very start. Debugging is only a measure of last resort.

[–] [email protected] 2 points 2 months ago

Ya, fuck legacy aggrid

[–] [email protected] 8 points 2 months ago

Heisenbugs are the worst. My condolences for being tasked with diagnosing one.

[–] [email protected] 24 points 2 months ago (1 children)

Clearly you should just ship it with the debugger and call it a day

[–] [email protected] 10 points 2 months ago (1 children)

Exactly, who would put a rebugged version into production anyway?

[–] [email protected] 1 points 2 months ago

That would just be irresponsible we want fewer bugs not more of them!

[–] [email protected] 53 points 2 months ago (2 children)

This is where printf debugging really shines, ironically.

[–] [email protected] 5 points 2 months ago* (last edited 2 months ago)

Honestly, this is why I tell developers that work with/for me to build in logging, day one. Not only will you always have clarity in every environment, but you won't run into cases where adding logging later makes races/deadlocks "go away mysteriously." A lot of the time, attaching a debugger to stuff in production isn't going to fly, so "printf debugging" like this is truly your best bet.

To do this right, look into logging modules/libraries that support filtering, lazy evaluation, contexts, and JSON output for perfect SEIM compatibility (enterprise stuff like Splunk or ELK).

[–] [email protected] 12 points 2 months ago (1 children)

I once had a racing condition that got tipped over by the debugger. So similar behavior to what's in the meme, but the code started working once I put in the print calls as well. I think I ended up just leaving the print calls, because I suck at async programming

[–] [email protected] 2 points 2 months ago

Yeah, I was going to mention race conditions as soon as I saw the parent comment. Though I'd guess most cases where the debugger "fixes" the issue while print statements don't are also race conditions, just the race isn't tight enough that that extra IO time changes the result.

Best way to be thorough with concurrency testing IMO involves using synchronization to deliberately check the results of each potential race going either way. Of course, this is an exponential problem if you really want to be thorough (like some races could be based on thread 1 getting one specific instruction in between two specific instructions in thread 2, or maybe a race involves more than 2 threads, which would make it exponentially grow the exponential problem).

But a trick for print statement debugging race conditions is to keep your message short. Even better if you can just send a dword to some fast logger asynchronously (though be careful to not introduce more race conditions with this!).

This is one of the reasons why concurrency is hard even for those who understand it well.

[–] [email protected] 24 points 2 months ago* (last edited 2 months ago) (1 children)

I'm a contractor at a rocket launch service provider. The final build of the ground control software is compiled and deployed to the launch pad with debug flags enabled because of a "fly like you test" mandate.

Millions of dollars and tons of time invested by brilliant people are riding on rockets that are launched using software with debug flags because of an "if it ain't broke don't fix it" mentality and archaic test strategies.

[–] [email protected] 12 points 2 months ago* (last edited 2 months ago)

I've worked on ground systems and it's actually come in handy two times in five years, usually where we had a hard-to-reproduce bug. Getting the info when the problem happens can occasionally be all the difference.

Addendum: And usually we didn't care about performance. Basically never.

[–] [email protected] 8 points 2 months ago

When I write APIs I like to set endpoints to return all status codes this way no matter what you're doing you can always be confident you're getting the expected status code.

[–] [email protected] 47 points 2 months ago (2 children)

Sound like a critical race condition or bad memory access (this latter only in languages with pointers).

Since it's HTTP(S) and judging by the average developer experience in the domain of multi-threading I've seen even for people doing stuff that naturally tends to involve multiple threads (such as networked access by multiple simultaneous clients), my bet is the former.

PS: Yeah, I know it's a joke, but I made the serious point anyways because it might be useful for somebody.

[–] [email protected] 3 points 2 months ago

Lazy load exception anyone?

[–] [email protected] 24 points 2 months ago (1 children)

This is why we shouldn't ban Critical Race Theory.

[–] [email protected] 4 points 2 months ago

Yeah! Nobody uses CRT monitors anymore.

[–] [email protected] 7 points 2 months ago (1 children)

The most cryptic status code I've received is 403: OK, while the entire app fails to load

[–] [email protected] 4 points 2 months ago* (last edited 2 months ago) (1 children)

That means you're not allowed in, and that's OK 😂

Probably should be redirected to a login page or something though 😅

[–] [email protected] 3 points 2 months ago

"Shhh, it's okay"

[–] [email protected] 23 points 2 months ago

Fear kepts the bits in line

[–] [email protected] 42 points 2 months ago (2 children)
[–] [email protected] 6 points 2 months ago

I always thought it was Cary Elwes.

[–] [email protected] 18 points 2 months ago* (last edited 2 months ago)

He worked for the gaming site/podcast "Giantbomb" years ago. Pretty sure the image macro is pulled from one of their podcast videos.

[–] [email protected] 48 points 2 months ago (2 children)

Just run your prod env in debug mode! Problem solved.

[–] [email protected] 28 points 2 months ago (2 children)

Lol my workplace ships Angular in debug mode. Don't worry though, the whole page kills itself if a dubious third-party library detects the console is open. Very secure and not brittle at all! ~~Please send help~~

[–] [email protected] 2 points 2 months ago (1 children)

Now I'm curious how this detection would work.

[–] [email protected] 5 points 2 months ago

I've seen some that activate an insane number of breakpoints, so that the page freezes when the dev tools open. Although Firefox let's you disable breaking on breakpoints all together, so it only really stops those that don't know what they're doing.

[–] [email protected] 12 points 2 months ago (1 children)

Blink-blink-blink. Blink. Blink. Blink. Blink-blink-blink.

No, I don't have something in my eyes, I swear I'm fine looks nervously at boss.

[–] [email protected] 2 points 2 months ago

Hang tight help is on the way.

[–] [email protected] 25 points 2 months ago* (last edited 2 months ago) (2 children)

You can imagine how many node projects there are running in production with npm run. I have encountered js/ts/node devs that don't even know that you should like, build your project, with npm build and then ship and serve the bundle.

[–] [email protected] 11 points 2 months ago

i have absolutely seen multiple projects on github that specifically tell you to do "npm run" as part of deploying it.

[–] [email protected] 14 points 2 months ago

I just died a little inside. Thank you.

[–] [email protected] 3 points 2 months ago
[–] [email protected] 5 points 2 months ago

One of the worst words in the English language is "intermittent."

[–] [email protected] 4 points 2 months ago

I once had a bug in a C# program I wrote. It made a HTTP request and if the user agent was left to default (whatever that was), the server just gave back an empty string as a reply. I took way to long until I understood what was going on and I kept chasing async, thinking I had messed it up some how.

load more comments
view more: next ›