This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/6684] New: Segmentation fault after getcontext() and setcontext() on ppc64


#include <ucontext.h>
#include <stdarg.h>
#include <stdio.h>

typedef struct ReturnValue { int a; } ReturnValue;
ReturnValue defaultReturnValue = { 0 };

ucontext_t globalUcp;

int outputMessage( char * format, ... ) {
    int res;
    va_list arg_list;
    va_start( arg_list, format );
    res = vprintf( format, arg_list );
    va_end( arg_list );
    return res;
}

ReturnValue getcontextCall( void ) {
    outputMessage( "getcontextCall : 1\n" );
    getcontext( & globalUcp );
    outputMessage( "getcontextCall : 2\n" );
    return defaultReturnValue;
}

ReturnValue setcontextCall( void ) {
    outputMessage( "setcontextCall : 1\n" );
    setcontext( & globalUcp );
    outputMessage( "setcontextCall : 2\n" );
    return defaultReturnValue;
}

int main( int argc,const char ** argv ) {
    getcontextCall();
    setcontextCall();
    return 0;
}


The example above leads to segmentation fault in the outputMessage() function
after call of the setcontext() on ppc64 platform. The output of the process is
as follows:

getcontextCall : 1
getcontextCall : 2
setcontextCall : 1
Segmentation fault

If someone replace "typedef struct ReturnValue { int a; } ReturnValue;" by
"typedef int ReturnValue;" in the example segmentation fault disappears.

See also: http://linuxtesting.org/results/report?num=S0688

-- 
           Summary: Segmentation fault after getcontext() and setcontext()
                    on ppc64
           Product: glibc
           Version: 2.4
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: drepper at redhat dot com
        ReportedBy: khoroshilov at linuxtesting dot org
                CC: glibc-bugs at sources dot redhat dot com


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

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]