public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/3457] New: popen fails in sighandler after double free or corruption
@ 2006-11-03 23:56 schaudhu at blackrock dot com
  2006-11-03 23:57 ` [Bug libc/3457] " schaudhu at blackrock dot com
  2006-11-04  0:03 ` drepper at redhat dot com
  0 siblings, 2 replies; 3+ messages in thread
From: schaudhu at blackrock dot com @ 2006-11-03 23:56 UTC (permalink / raw)
  To: glibc-bugs

Please examine the following atomic example:

#include <iostream>
#include <signal.h>
#include <sys/signal.h>

using std::cout;
using std::endl;

void handler( int sig, siginfo_t *info, void *ctx )
{
    cout << "Got " << sig << " signal." << endl;
    popen( "/bin/ps", "r" );

    cout << "Finished." << endl;
}

int main()
{
    struct sigaction action;

    action.sa_sigaction = &handler;
    sigfillset( &action.sa_mask );
    action.sa_flags = SA_RESETHAND | SA_SIGINFO | SA_ONSTACK;

    sigaction( SIGABRT, &action, NULL );
    sigaction( SIGQUIT, &action, NULL );
    sigaction( SIGILL, &action, NULL );
    sigaction( SIGTRAP, &action, NULL );
    sigaction( SIGABRT, &action, NULL );
    sigaction( SIGFPE, &action, NULL );
    sigaction( SIGBUS, &action, NULL );
    sigaction( SIGSEGV, &action, NULL );
    sigaction( SIGSYS, &action, NULL );
    sigaction( SIGXCPU, &action, NULL );
    sigaction( SIGXFSZ, &action, NULL );

    void *p = ::malloc( 1 );
    ::free( p );
    ::free( p );

    return 0;
}

With older versions of glibc, this produces:

Got 11 signal.
Finished.
Segmentation fault (core dumped)


With newer versions of glibc, this HANGS after producing:

*** glibc detected *** double free or corruption (fasttop): 0x0804a008 ***
Got 6 signal.


The only way to terminate it is to forcibly kill the process.  Using system() 
instead of popen() works okay.  Can someone please investigate?

Thanks!

-- 
           Summary: popen fails in sighandler after double free or
                    corruption
           Product: glibc
           Version: 2.4
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: drepper at redhat dot com
        ReportedBy: schaudhu at blackrock dot com
                CC: glibc-bugs at sources dot redhat dot com,schaudhu at
                    blackrock dot com


http://sourceware.org/bugzilla/show_bug.cgi?id=3457

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug libc/3457] popen fails in sighandler after double free or corruption
  2006-11-03 23:56 [Bug libc/3457] New: popen fails in sighandler after double free or corruption schaudhu at blackrock dot com
@ 2006-11-03 23:57 ` schaudhu at blackrock dot com
  2006-11-04  0:03 ` drepper at redhat dot com
  1 sibling, 0 replies; 3+ messages in thread
From: schaudhu at blackrock dot com @ 2006-11-03 23:57 UTC (permalink / raw)
  To: glibc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|2.4                         |unspecified


http://sourceware.org/bugzilla/show_bug.cgi?id=3457

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug libc/3457] popen fails in sighandler after double free or corruption
  2006-11-03 23:56 [Bug libc/3457] New: popen fails in sighandler after double free or corruption schaudhu at blackrock dot com
  2006-11-03 23:57 ` [Bug libc/3457] " schaudhu at blackrock dot com
@ 2006-11-04  0:03 ` drepper at redhat dot com
  1 sibling, 0 replies; 3+ messages in thread
From: drepper at redhat dot com @ 2006-11-04  0:03 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From drepper at redhat dot com  2006-11-04 00:02 -------
You cannot use any non-async safe function in a signal handler.  The small list
of functions which is allowed is listed in section 2.4.3 of the XSH volume of POSIX.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID


http://sourceware.org/bugzilla/show_bug.cgi?id=3457

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-11-04  0:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-11-03 23:56 [Bug libc/3457] New: popen fails in sighandler after double free or corruption schaudhu at blackrock dot com
2006-11-03 23:57 ` [Bug libc/3457] " schaudhu at blackrock dot com
2006-11-04  0:03 ` drepper at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).