r/ProgrammerHumor • • Jul 20 '18

Every Time

Post image
52.2k Upvotes

749 comments sorted by

View all comments

Show parent comments

53

u/[deleted] Jul 20 '18

Changing it to mod 31 might prevent someone finding it while it's in debug, but it's still an exception so there's still going to be a stacktrace that points you directly to it. Doesn't matter if the error message is searchable.

0

u/[deleted] Jul 20 '18

[deleted]

27

u/LvS Jul 20 '18

You can see the stacktrace from where your code died.

In C you could mess with the stack pointer and then jump to a random address, but even that can be caught with tools like rr.

What you want to throw is a DNS lookup failure or something that just happens regularly in that piece of code.

12

u/Hdmoney Jul 20 '18

The real way to do it would be by invalidating state in a way that you know will get caught in the future.

3

u/SheepLinux Jul 20 '18

I feel sorry for whoever has to debug/deploy ur horrible horrible mess lol

7

u/FatFingerHelperBot Jul 20 '18

It seems that your comment contains 1 or more links that are hard to tap for mobile users. I will extend those so they're easier for our sausage fingers to click!

Here is link number 1 - Previous text "rr"


Please PM /u/eganwall with issues or feedback! | Delete

2

u/AUTplayed Jul 20 '18

In C you could mess with the stack pointer and then jump to a random address, but even that can be caught with tools like rr.

oh no, why is that a feature? D:

2

u/_realitycheck_ Jul 20 '18

And then hide the result in matrices.

1

u/Lt_Riza_Hawkeye Jul 21 '18

call abort() directly, or if you're worried about someone installing a signal handler, _exit(). Be sure to call if (fork()) _exit(); first to remove any debuggers.

14

u/Kalabasa Jul 20 '18

You can modify the exception's stack trace before throwing.

9

u/[deleted] Jul 20 '18

Wait really? I’ve never seen that or thought to do that before. I guess if people ever do that it’s usually to help debug rather than modify it with malicious intent

10

u/Kalabasa Jul 20 '18

Yeah, at least in Java. I guess it's for frameworks to hide internal stuff (cut off the part of the trace

4

u/citewiki Jul 20 '18

Cutting off... like the parenthes

1

u/[deleted] Jul 20 '18

Ah right yeah, didn’t think about that. Makes sense

2

u/[deleted] Jul 20 '18

Hmm I guess I know where that's useful now ...

2

u/DaMaestroable Jul 20 '18

What they should do is to create a new thread and just have it start allocating memory like crazy, and then watch the whole thing grind to a halt.

0

u/-Unparalleled- Jul 21 '18 edited Jul 21 '18

Would it work if you have it so that instead of throwing an exception that can be traced you catch it or just make it a conditional that will change the return value?

I only started learning C yesterday so I think it would be something like returning a "0" rather than 0? I haven't got that far into C yet.

In python it could be something like:

from random import randint

if randint(0, 31) == 0:`

    return "True"

# rest of code

if condition:
    return True
return False

Strings would count as truthy so I don't know how much impact it would have but it would be hard to figure out where it came from

-1

u/Continuum360 Jul 20 '18

Why are you trying to ruin our fun.