bug report - g++ + linuxthreads == seg fault

Brent Verner brent@linux1.org
Tue May 9 19:38:00 GMT 2000


Forgive me if this report is directed to the wrong place, but I
can't figure out _where_ the problem lies. If you can help me solve
this I'd appreciate it greatly :)

cheers.
    brent

==========================
the problem:
==========================
  brent$ g++ -g -Wall breaks.cc -o breaks -lpthread
  brent$ ./breaks
  calling thread
  running me
  thread joined 
  Segmentation fault

==========================
the source: 
==========================
    (g++ -v --save-temps -O2 -lpthreads breaks.cc) [attached]

    extern "C" {
    #include <stdio.h>
    #include <pthread.h>
    }

    using namespace std;

    void* runme(void* arg)
    {
      puts("running me");
      pthread_exit((void*)0);
    }

    int
    main(int argc, char** argv)
    {
      pthread_t th;
      puts("calling thread");
      pthread_create( &th, NULL, runme, (void*)0);
      if( pthread_join(th,NULL) ){
        puts("join error");
      }
      puts("thread joined");
      return 0;
    }

==========================
observations so far:
==========================

from ddd I see. (NOTE that i have '=>' showed its mark)
If the value of set in the following snippet of code is
useful, I have (a screenshot of ddd displaying) it, and
could send it (yeah, I'd get off my ^ss and type it in).

Program received signal ?, Unknown signal.
0x805b9ce in __sigsuspend (set=0xbffff920) 
    at ../sysdeps/unix/sysv/linux/sigsuspend.c:48
___________

[ ../sysdeps/unix/sysv/linux/sigsuspend.c ]

/* Change the set of blocked signals to SET,
   wait until a signal arrives, and restore the set of blocked signals.  */
int
__sigsuspend (set)
     const sigset_t *set;
{
#ifdef __NR_rt_sigsuspend
  /* First try the RT signals.  */
  if (!__libc_missing_rt_sigs)
    {
      /* XXX The size argument hopefully will have to be changed to the
         real size of the user-level sigset_t.  */
      int saved_errno = errno;
=>    int result = INLINE_SYSCALL (rt_sigsuspend, 2, set, _NSIG / 8);
    
      if (result >= 0 || errno != ENOSYS)
        return result;
_________

Dump of assembler code for function __sigsuspend:
    0x804d2a0 <__sigsuspend>:   push   %ebp
    0x804d2a1 <__sigsuspend+1>: mov    %esp,%ebp
    0x804d2a3 <__sigsuspend+3>: push   %edi
    0x804d2a4 <__sigsuspend+4>: push   %esi
    0x804d2a5 <__sigsuspend+5>: push   %ebx
    0x804d2a6 <__sigsuspend+6>: sub    $0xc,%esp
    0x804d2a9 <__sigsuspend+9>: mov    0x8(%ebp),%ebx
    0x804d2ac <__sigsuspend+12>:    cmpl   $0x0,0x8088524
    0x804d2b3 <__sigsuspend+19>:    jne    0x804d301 <__sigsuspend+97>
    0x804d2b5 <__sigsuspend+21>:    call   0x804ab30 <__errno_location>
    0x804d2ba <__sigsuspend+26>:    mov    %eax,%edi
    0x804d2bc <__sigsuspend+28>:    mov    (%edi),%esi
    0x804d2be <__sigsuspend+30>:    mov    $0x8,%ecx
    0x804d2c3 <__sigsuspend+35>:    mov    %ebx,%edx
    0x804d2c5 <__sigsuspend+37>:    xchg   %edx,%ebx
    0x804d2c7 <__sigsuspend+39>:    mov    $0xb3,%eax
    0x804d2cc <__sigsuspend+44>:    int    $0x80
=>  0x804d2ce <__sigsuspend+46>:    xchg   %edx,%ebx
    0x804d2d0 <__sigsuspend+48>:    cmp    $0xfffff000,%eax
    0x804d2d5 <__sigsuspend+53>:    jbe    0x804d2e0 <__sigsuspend+64>
    0x804d2d7 <__sigsuspend+55>:    neg    %eax
    0x804d2d9 <__sigsuspend+57>:    mov    %eax,(%edi)
    0x804d2db <__sigsuspend+59>:    mov    $0xffffffff,%eax
    0x804d2e0 <__sigsuspend+64>:    mov    %eax,%edi
    0x804d2e2 <__sigsuspend+66>:    test   %edi,%edi
    0x804d2e4 <__sigsuspend+68>:    jns    0x804d331 <__sigsuspend+145>
    0x804d2e6 <__sigsuspend+70>:    call   0x804ab30 <__errno_location>
    0x804d2eb <__sigsuspend+75>:    cmpl   $0x26,(%eax)
    0x804d2ee <__sigsuspend+78>:    jne    0x804d331 <__sigsuspend+145>
    0x804d2f0 <__sigsuspend+80>:    call   0x804ab30 <__errno_location>
    0x804d2f5 <__sigsuspend+85>:    mov    %esi,(%eax)
    0x804d2f7 <__sigsuspend+87>:    movl   $0x1,0x8088524
    0x804d301 <__sigsuspend+97>:    mov    $0x0,%edi
    0x804d306 <__sigsuspend+102>:   mov    (%ebx),%edx
    0x804d308 <__sigsuspend+104>:   mov    %edi,%ecx
    0x804d30a <__sigsuspend+106>:   push   %ebx
    0x804d30b <__sigsuspend+107>:   mov    %edi,%ebx
    0x804d30d <__sigsuspend+109>:   mov    $0x48,%eax
    0x804d312 <__sigsuspend+114>:   int    $0x80
    0x804d314 <__sigsuspend+116>:   pop    %ebx
    0x804d315 <__sigsuspend+117>:   mov    %eax,%edi
    0x804d317 <__sigsuspend+119>:   cmp    $0xfffff000,%edi
    0x804d31d <__sigsuspend+125>:   jbe    0x804d331 <__sigsuspend+145>
    0x804d31f <__sigsuspend+127>:   call   0x804ab30 <__errno_location>
    0x804d324 <__sigsuspend+132>:   mov    %eax,%edx
    0x804d326 <__sigsuspend+134>:   mov    %edi,%eax
    0x804d328 <__sigsuspend+136>:   neg    %eax
    0x804d32a <__sigsuspend+138>:   mov    %eax,(%edx)
    0x804d32c <__sigsuspend+140>:   mov    $0xffffffff,%edi
    0x804d331 <__sigsuspend+145>:   mov    %edi,%eax
    0x804d333 <__sigsuspend+147>:   add    $0xc,%esp
    0x804d336 <__sigsuspend+150>:   pop    %ebx
    0x804d337 <__sigsuspend+151>:   pop    %esi
    0x804d338 <__sigsuspend+152>:   pop    %edi
    0x804d339 <__sigsuspend+153>:   pop    %ebp
    0x804d33a <__sigsuspend+154>:   ret    
End of assembler dump.


-- 


More information about the Gcc-bugs mailing list