Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

[b][u][i]GNU QUALITY[/i][/u][/b]

Name: Anonymous 2011-11-14 17:14

So my C code segfaults. Nothing new or interesting about that, let's just sprinkle the code with printfs and fire up gdb.
Oh wait, it segfaults WITHIN FUCKING malloc.
I call
malloc(24)
and the bitch just segfaults. What the fuck. (Yes, it's glibc)

GNU QUALITY

Name: Anonymous 2011-11-14 17:24

malloc considered harmful.
Use C++ instead.

Name: Anonymous 2011-11-14 17:27

>>2
Because your precious new doesn't call malloc somewhere deep inside all that shit.

Name: Anonymous 2011-11-14 17:36

If you don't need a lot of memory and/or complicated management, you can implement your own malloc that allocs from an extern array.

Name: Anonymous 2011-11-14 18:44

Perhaps you are allocating more memory than the machine can spare, or perhaps you are leaking memory.

Name: Anonymous 2011-11-14 18:48

>>1
That's because you have doubly free'd a pointer or stepped out of bounds of a previously allocated array before calling malloc.

This typically happens when you have forgotten a sizeof in a previous malloc.

Note that these lead to undefined behavior which includes a segmentation fault in your malloc call.

Name: Anonymous 2011-11-14 18:56

>>6
Yes, you are right. I'm retarded. I'd like to apologise to everyone involved in GNU project.

Name: rms 2011-11-14 19:02

>>7
Happy hacking.

Name: Anonymous 2011-11-14 19:21

>>1
Get back to the imageboards.

Name: Anonymous 2011-11-14 19:55

/b/ i owe you

Name: Anonymous 2011-11-14 21:25

CHECK MY DUBZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Name: Anonymous 2011-11-14 21:32

Only through GNUPAIN can one attain GNUFREEDOM.

Name: Anonymous 2011-11-14 22:32

This happens on Windows' CRT too if you corrupt the block headers in the wrong way.

Name: Anonymous 2011-11-15 1:00

>>7
You haven't met drpepper yet have you?

Name: FrozenVoid !!mJCwdV5J0Xy2A21 2011-11-15 2:12

if you want exact 24 bytes why don't use a static array?
If its used in a function you can make it a global first like
char somearray[24]; and assign values to it in functions or inside main. Problem solved

Name: Anonymous 2011-11-15 2:35

>>15
I, of course, was calling it with sizeof some struct (of size 24). I put 24 there just to be clear that I don't try to allocate something stupid.

Name: Anonymous 2011-11-15 3:13

>>16
char buffa[sizeof(dicks)];

Don't change these.
Name: Email:
Entire Thread Thread List