r/ProgrammerAnimemes • • Jul 20 '21

what even is "void safety"?

Post image
2.2k Upvotes

69 comments sorted by

65

u/elgatoroid Jul 20 '21

sauce is Chainsaw Man, chapter 84

262

u/Knuffya Jul 20 '21

Nullpointer exceptions are nice.

The fun begins when the pointers are not nulled, but point to some random fucking space in memory

86

u/sleepystar96 Jul 20 '21

Yeah.. Cries in segmentation faults and other not-very-fun runtime errors.

53

u/UltraCarnivore Jul 20 '21

There are these peekaboo segfaults, where the memory location usually is zero, until it isn't.

21

u/Knuffya Jul 20 '21

We don't say such vile tings out loud here

24

u/SuperMaxPower Jul 20 '21

Ah yes, schroedinger's address!

15

u/veedant Jul 21 '21

we don't even need quantum computing to be unsure what our pointer points to!

5

u/Diapolo10 Jul 21 '21

A quantum pointer would simply point to every memory location simultaneously, so if you happened to be in the world where the wave function always collapses to an invalid memory location, tough luck!

→ More replies (4)

5

u/JonBruse Jul 21 '21

That reminds me of a bug I wrote for myself when venturing into C for PIC Microcontrollers in college..

was making a thing to rotate precisely across 3 axes to be able to point to a specific angle (or rather sweep through all angles) so as to profile an antenna's radiation pattern. Part of that was to have a display to show current stats of the system in case there was a discrepancy from what the computer reported.

During my testing, there was a point where the motors would turn on 'randomly' as I was testing the display functions... That's when I learned to make bounded char arrays instead of using char*

→ More replies (3)

25

u/auxiliary-character Jul 20 '21 edited Jul 20 '21

When somehow, for some reason, you're misinterpreting some other non-pointer data as a pointer, and end up dereferencing it, and it just so happens to land somewhere in your address space, causing the bug to appear to have been caused by some other part of the program that was actually functioning correctly until this little fucker went along and corrupted memory over there.

11

u/Knuffya Jul 20 '21

And you spend the whole day completely destroying that other innocent module in search of the bug?

And because you were a young dumbfuck you were not using git?

And then you had to recode that module?

If so, then this triggers childhood memories in me that i'm not so fond of.

8

u/davawen Jul 20 '21

Use by reference is really funny until that little shit goes out of scope but you don't realize it because in your head it's not a pointer
I made that mistake once with lambda expressions, never again

12

u/Knuffya Jul 20 '21

seems like something fun to debug.

My favourite 1.5 hours of debugging, and i am truly ashamed of it, was something like this:

SuperLongTemplatedType& DoSomething(const AnotherSuperLongTemplatedType& foo) {
    SuperLongTemplatedType bananas;
    return bananas;
}

// why the fuck is the return value garbage reeeeeeeeeeeeeeeeeeeeeeeee

5

u/davawen Jul 21 '21

I felt that in my soul

4

u/Gydo194 Jul 21 '21

Agreed. This is where the REAL fun begins.

6

u/Knuffya Jul 21 '21

it's especially fun when it results in a segfault, and your debugger reports it comes from some unfortunate module that had its memory fucked by this pointer. So you run it again, it segfaults, but it's a different module this time. And then a different one again.

5

u/Gydo194 Jul 21 '21

It's a fun game of hide and seek.

Fun for the bug, that is.

3

u/rk06 Jul 21 '21

Except when you have a long chain of function call and no idea which one returned null

1

u/Knuffya Jul 21 '21

Any usable debugger should sort that one out fairly quickly

2

u/rk06 Jul 21 '21

When have you ever seen a debugger deployed to production machine?

→ More replies (2)
→ More replies (3)

45

u/AC2302 Jul 20 '21

Can't wait to see how strong the java.lang.NullPointerException demon is

42

u/ThePyroEagle λ Jul 20 '21

Welcome to the safe languages gang! We have:

and many more trying to catch up with the innovative languages of the past.

13

u/curtmack Jul 20 '21

Common Lisp: "Hiya, don't forget about me! I'm a perfectly safe language too! You can even -"

(declare (optimize (speed 3) (safety 0)))

Common Lisp: cracks knuckles "Oh so you like to fuck around, huh? Alright kid, you ready to find out?!"

4

u/Kered13 Aug 05 '21

Common Lisp is dynamically typed, so not type safe.

6

u/raedr7n Jul 20 '21

I might have gone with OCaml instead of a language that hasn't been updated since 1997, but I'm still happy you included an ML. I love ML's. They make me feel all warm and fuzzy and sugar over system Fω inside.

5

u/ThePyroEagle λ Jul 20 '21

I couldn't possibly leave out the first language to implement Hindley-Milner types.

52

u/Y45HK4R4NDIK4R Jul 20 '21

that's why you use rust

16

u/UltraCarnivore Jul 20 '21

Cries in unsafe

10

u/Zyansheep Jul 20 '21

Laughs in never using unsafe

0

u/[deleted] Jul 20 '21

[deleted]

6

u/UltraCarnivore Jul 20 '21

Cries in stdio.h$

-1

u/cronsundathar Jul 21 '21

oh yeah! i heard they got the compile time for a basic cli interface down to a whole afternoon

5

u/[deleted] Jul 21 '21

Nobody forces you to use dependencies.

5

u/TechcraftHD Jul 21 '21

I'll take long compile times instead of hunting for ownership bugs every day.

Rust compile times have also gotten pretty good

9

u/[deleted] Jul 20 '21

Fuck segmentation fault: core dumped$ —this was brought to you by C programmers

6

u/[deleted] Jul 20 '21

Segfault error: Illegal memory access at 0xf***69696969

4

u/xaklx20 Jul 21 '21

That's why the Maybe/Option monad is great

6

u/[deleted] Jul 20 '21

Actually null pointer exceptions are great, they let you know that something's wrong.

4

u/xaklx20 Jul 21 '21

On runtime... That's terrible imo

2

u/Kikiyoshima Jul 26 '21

Better than never still🤣

2

u/GrayRodent Jul 20 '21

This frigging template threw me into a reading fit and I finished it in two days. I still feel bad...

1

u/Frog-Frosch Jul 20 '21

Same for me from another Template. Read it in one go. Anime is soon coming

2

u/Tom11moT Jul 21 '21

Woof woof!

3

u/BochMC Jul 20 '21

Die Makima

1

u/Tom11moT Jul 21 '21

Woof woof

1

u/ImHhW Jul 20 '21

Is this edited or from the original manga?

1

u/[deleted] Jul 21 '21

Use Kotlin.

1

u/veedant Jul 29 '21

see, this is why you take control of the machine in firmware itself before the OS or the bootloader loads. You can write to 0x0000000000000000. Who's gonna stop you?

1

u/donaldhobson Aug 28 '21

Yet if I had to pick 2 of the 3 to vanish forever, I know which I would pick.

1

u/RayeNGames Dec 30 '21

Do not take void safety lightly. The void can devour you before you even notice.

1

u/Guilty-Woodpecker262 Feb 21 '22

ArrayIndexOurOfBoundsException: line 48

-3

u/xx_memebakery_xx Jul 20 '21

Just use Kotlin

5

u/lord_ne Jul 20 '21

Laughs in !!