[ee122] malloc segfaults? out of memory?

Daniel Killebrew dank at eecs.berkeley.edu
Wed Sep 26 20:08:14 PDT 2007



abhishekd at berkeley.edu wrote:
> On running my client on c199.eecs.berkeley.edu i am intermittently getting
> segfaults after returning server information to the cliet and then having
> the client malloc space to get input from stdin again. i am not having
> this error on servers such as ilinux3.eecs (where i could valgrind and see
> if there is a misplaced free causing intermittent segfaults on other
> mallocs...) or even sphere.cs at this point. an example of what i am doing
> is provided below.
>
>
> Client:
>   
>> http://www.aol.com
>>     
>
> **server returns stuff
>
>   
>> http://www.google.com
>>     
>
> **server returns stuff
>
>   
>> http://www.yahoo.com
>>     
>
> **server returns stuff
> SEGFAULT!
>
> a bt of the segfault shows the fault occuring on this line:
> char* userInput = (char*) malloc(sizeof(char)*maxInputSize);
>
>
> My question is could malloc be screwing up due to lots of people using
> c199 and potentially not freeing their memory after use? 
I very much doubt it.
Every process is in its own virtual address space, and once a process 
closes, the OS cleans up the process' outstanding memory. Meaning that 
the worst other processes could do to you is cause malloc to not be able 
to allocate any memory.
> If its something
> with my code why do i not have this problem on ilinux3 or sphere.cs ...?
>   
I'm sure you'll figure that out once you find your bug. :)

One of the harder things to learn as a computer scientist is that 99.99% 
of the time when stuff doesn't work, it's your fault.

Daniel
> _______________________________________________
> ee122 mailing list
> ee122 at mailman.ICSI.Berkeley.EDU
> http://mailman.ICSI.Berkeley.EDU/mailman/listinfo/ee122
>
>   


More information about the ee122 mailing list