call to close causing Segmentation fault

call to close causing Segmentation fault

Post by Liam Darragh Whale » Fri, 04 Jul 2003 16:04:43



I'm calling close on a valid file descriptor, I've added a check with
select to make sure the file descriptor is valid,  and it is causing a
Segmentation fault.
Whenever I comment out the call to close  I no longer get the
Segmentation fault.   The code uses SSL to open the connect and the
problem occurs right after a call to
SSL_read fails.   The wierd thing is it doesn't cause the Segmentation
fault right away.  It first returns from the function calling the
close() and prints a message then the
Segmentation fault happens.  I know it is the close that is doing it
though because the Segmentation fault goes away when I comment out the
close() call.

Anybody every come accross something like this?

Liam

 
 
 

call to close causing Segmentation fault

Post by Jens.Toerr.. » Fri, 04 Jul 2003 20:39:59



Quote:> I'm calling close on a valid file descriptor, I've added a check with
> select to make sure the file descriptor is valid,  and it is causing a
> Segmentation fault.
> Whenever I comment out the call to close  I no longer get the
> Segmentation fault.   The code uses SSL to open the connect and the
> problem occurs right after a call to
> SSL_read fails.   The wierd thing is it doesn't cause the Segmentation
> fault right away.  It first returns from the function calling the
> close() and prints a message then the
> Segmentation fault happens.  I know it is the close that is doing it
> though because the Segmentation fault goes away when I comment out the
> close() call.

Probably the segmentation fault has really nothing to do with the
close() call but some memory corruption happening somewhere else
in your program. You probably have written past the end of an array
or to memory locations that have not been allocated to your process.
This often leads to segfaults at seemingly random and unrelated places,
e.g. in some libc function calls. I would recommend to get a memory
checker (valgrind, purify or one of the many other) and/or switching
on the memory checker build into newer glibc's (if you have it) by
compiling with the -DLIBC_MDEBUG flag.
                                           Regards, Jens
--
      _  _____  _____

  _  | |  | |    | |
 | |_| |  | |    | |          http://www.physik.fu-berlin.de/~toerring
  \___/ens|_|homs|_|oerring

 
 
 

call to close causing Segmentation fault

Post by David Schwart » Sat, 05 Jul 2003 07:07:29




Quote:> I'm calling close on a valid file descriptor, I've added a check with
> select to make sure the file descriptor is valid,  and it is causing a
> Segmentation fault.

    Troubleshoot! Compile with symbols, get a core dump, run 'gdb'.

    DS

 
 
 

1. BUG() call in vmalloc.c causes segmentation fault.

In the function __vmalloc() in mm/vmalloc.c. The function
is parsing the "size" parameter passed to it. If the request
is of zero bytes or if it is greater than num_physpages,
then __vmalloc calls BUG(). The NULL pointer is never
returned, which causes the segmentation fault.  This BUG()
call was correctly removed for 2.5.

- Robbie

(See attached file: vmalloc.c.patch)


Linux Test Project
IBM Linux Technology Center
Phone: (512) 838-9295   T/L: 678-9295
Fax: (512) 838-4603
Web: http://ltp.sourceforge.net
IRC: #ltp on freenode.irc.net
====================
"Only two things are infinite, the universe and human stupidity, and I'm
not sure about the former." -Albert Einstein

  vmalloc.c.patch
< 1K Download

2. Wanted, OS's

3. xboard causes Segmentation Fault!

4. sgimips black screen on Indigo2 R4400/250

5. Xfilemanager causing segmentation fault

6. Problems with F1 ...

7. Using libstdc++ causes Segmentation fault

8. Minicom madness

9. FTAPE causes segmentation fault when loading

10. Segmentation fault causes extreme badness?

11. lpq causes a segmentation fault on Solaris 2.7

12. W32.Nimda.A@mm worm causes segmentation fault in Linux Apache httpd 1.3.3

13. Segmentation fault caused by malloc()