r/ProgrammerHumor • • Jan 28 '23

Meme C++

Post image
53.9k Upvotes

1.5k comments sorted by

View all comments

Show parent comments

423

u/Sexy_McSexypants Jan 28 '23

“ok, you wanna tell me what went wrong and where?”

“no, fuck you, Segmentation Fault”

89

u/throw3142 Jan 28 '23

I just got a segmentation fault in Python :D

Fun times

It's 3 am, I should go to sleep

45

u/Valmond Jan 28 '23

Prolly in a third-party library.

94

u/CuriousProgrammer72 Jan 28 '23 edited Jan 28 '23

Prolly in a third-party library

That has C++ bindings lol.

→ More replies (1)

50

u/Sinomsinom Jan 28 '23

If you do stuff in python where 99.5% of the actual work isn't done in a library not written in python you're using the wrong language.

57

u/Seanxietehroxxor Jan 28 '23

Python: the best language to call into libraries written in completely different languages.

→ More replies (3)

4

u/MinosAristos Jan 28 '23

I know you're joking but there are plenty of non computationally intensive use cases where "pure" python is fine.

4

u/Jayson_n_th_Rgonauts Jan 28 '23

I use Python because it’s the only one I know how to write an API call in and I’m an accountant

3

u/aridankdev Jan 28 '23

most well documented apis have an example for most languages. Python is pretty easy to figure out for the most part though

6

u/Jayson_n_th_Rgonauts Jan 28 '23

Yeah Python its just like

Import

Import

Import

Call API

🐼

→ More replies (1)
→ More replies (6)

2

u/itsTyrion Feb 15 '23

I once managed to create a Segfault in pure Python

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

0

u/[deleted] Jan 28 '23

[deleted]

→ More replies (6)

15

u/[deleted] Jan 28 '23

gcc file.c -g then gdb

40

u/bad_investor13 Jan 28 '23

Surprise! Now the program works!

9

u/fireflash38 Jan 28 '23

Break out the valgrind, because you have a bounds access issue.

2

u/psychoCMYK Jan 28 '23

Race condition

→ More replies (1)

10

u/[deleted] Jan 28 '23

If it crashes then you're happy. You can debug it. But C++ sometimes doesn't crash, it just does "something"

6

u/_TheDust_ Jan 28 '23

My favorite one is when you write out of bounds to stack allocated array. At that point, you're basically just overwritten random bytes on the stack including return addresses. That was a fun day of debugging

2

u/Giocri Jan 28 '23

Are at the code section and data section of the memory protected from each other or could you override your own code with random stuff you have in memory?

→ More replies (1)

28

u/ArthurM_R2 Jan 28 '23 edited Jan 28 '23

A lot of begginers struggle with debugging this. Segmentation fault is not specific to C or C++. In fact this is a runtime exception signalled by memory hardware. The compiler is not concerned with this at all, since it's job is to make your instructions executable. Whether some memory access is an access violation or not is only decided by the MMU once the OS tries to execute the specific instruction. As to what went wrong - segmentation fault is always related to memory access (dereferencing pointers, accessing array indices out of bounds, etc). The computer cannot tell you what part of the source code is at fault - after compilation the PC only executes machine code which has little to do with your source and nothing else. To find out what went wrong you can use a debugger such as gdb which keeps track of instruction-to-source mappings. Hope I helped!

Edit: beginners struggle with debugging, not segfaults themselves, everyone has their fair share of segfaults

9

u/PayYourRe2pects Jan 28 '23

“A lot of beginners struggle with this problem.”

Bruh everyone struggles with this problem

17

u/ArthurM_R2 Jan 28 '23

The problem being not knowing how to debug it.

→ More replies (1)

5

u/DreamlyXenophobic Jan 28 '23

Debugger is your friend

2

u/nnog Jan 28 '23

"yeah sure I left you a 20GB core file for you to analyze with no debug symbols good luck idiot"

→ More replies (5)