bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sigprocmask.c appears to be incompatible w/ system headers


From: Godfrey, Keith
Subject: Re: sigprocmask.c appears to be incompatible w/ system headers
Date: Mon, 14 Mar 2011 19:35:42 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.16) Gecko/20110307 Icedove/3.0.11

Hi Bruno,

Thank you for quick the response.

There is no sigprocmask.lo in this list. This is normal; gnulib's sigprocmask.c
is not compiled on glibc systems. You can see from the gnulib documentation
<http://www.gnu.org/software/gnulib/manual/html_node/sigprocmask.html>
that this source file is only compiled on mingw platforms.

Indeed. Placing an "#error" line in sigprocmask.cc did not disrupt the build.


Also, the generated signal.h is built with HAVE_SIGSET_T being replaced with 1,
therefore it does not redefine the 'sigset_t' type.

In<https://savannah.gnu.org/bugs/?30685>  you write:
A change (similar to Leonardo's) that seems to work while theoretically 
maintaining sigaction
functionality is to explicitly call the sigemptyset macro (bits/sigset.h):

octave-3.4.0/src/sighandlers.cc line 225
  //gnulib::sigemptyset (&act.sa_mask);
  //gnulib::sigemptyset (&oact.sa_mask);
  //gnulib::sigaction (sig,&act,&oact);
  __sigemptyset (&act.sa_mask);
  __sigemptyset (&oact.sa_mask);
  sigaction (sig,&act,&oact);

(only removing the namespace didn't work for me either)
This indicates that the crucial difference is between the __sigemptyset
macro and the sigemptyset functions, both from glibc.

This report might be misleading, and there might not be a difference. When I removed the gnulib namespace from the file entirely, and recompiled, octave started and ran. The problem with this report was that there were still some instances of "gnulib::" on other function calls. I suspect this was also the case when others removed "gnulib" on sigemptyset and it still crashed (presumably on the subsequent gnulib::sigaction).


Or if 'sigemptyset' would work fine, then the crucial difference would
be in the function pointer indirection by which gnulib implements the
'gnulib::sigemptyset' function in term of the 'sigemptyset' function
pointer.

In order to debug this, I would recommend to look at

   - the source code of the __sigemptyset macro and of the sigemptyset
     function,

From /usr/include/bits/sigset.h

# define _SIGSET_NWORDS (1024 / (8 * sizeof (unsigned long int)))
typedef struct
  {
    unsigned long int __val[_SIGSET_NWORDS];
  } __sigset_t;


#  define __sigemptyset(set) \
  (__extension__ ({ int __cnt = _SIGSET_NWORDS;                   \
            sigset_t *__set = (set);                      \
            while (--__cnt >= 0) __set->__val[__cnt] = 0;         \
            0; }))

I am unable to find source code for the sigemptyset function of glibc.


   - the assembly level instructions where it crashes:

      #0  0xb785896c in sigemptyset () from 
/home/muttoni/a/octave-3.3.53/src/.libs/liboctinterp-3.3.53.so

     because it's not clear why liboctinterp-3.3.53.so would contain
     a sigemptyset function at all (since gnulib's one is not being
     compiled).

This is naive speculation, but perhaps liboctinterp is involved because "gnulib::sigemptyset" is being called, instead of simply "sigemptyset"? As mentioned above, I removed all references of "gnulib::" from the problem file and recompiled, and it seemed to run fine. With the namespace declared, it reliably crashes. Perhaps a link issue? This speculation is discrepant with reports in the original octave bug, but in those cases people (seem to have) only removed "gnulib::" from sigemptyset, leaving the other instances intact. If I do that, it does crash.


Assembly instructions at breakpoint shortly before crash. Crash occurs stepping past instruction at 0x2b630861baff.

Breakpoint 1, octave_set_signal_handler (sig=2,
    handler=0x2b630861c080 <sigint_handler>, restart_syscalls=true)
    at sighandlers.cc:206
206      act.sa_flags = 0;
2: x/10i $pc
0x2b630861bae3 <_Z25octave_set_signal_handleriPFviEb+35>:
---Type <return> to continue, or q <return> to quit---
    movl   $0x0,0x128(%rsp)
0x2b630861baee <_Z25octave_set_signal_handleriPFviEb+46>:
    je     0x2b630861bb50 <_Z25octave_set_signal_handleriPFviEb+144>
0x2b630861baf0 <_Z25octave_set_signal_handleriPFviEb+48>:    test   %dl,%dl
0x2b630861baf2 <_Z25octave_set_signal_handleriPFviEb+50>:
    je     0x2b630861baff <_Z25octave_set_signal_handleriPFviEb+63>
0x2b630861baf4 <_Z25octave_set_signal_handleriPFviEb+52>:
    movl   $0x10000000,0x128(%rsp)
0x2b630861baff <_Z25octave_set_signal_handleriPFviEb+63>:
    lea    0xa0(%rsp),%r12
0x2b630861bb07 <_Z25octave_set_signal_handleriPFviEb+71>:
    lea    0x8(%r12),%rdi
0x2b630861bb0c <_Z25octave_set_signal_handleriPFviEb+76>:
    callq  0x2b630905ede8 <sigemptyset>
0x2b630861bb11 <_Z25octave_set_signal_handleriPFviEb+81>:
    lea    0x8(%rsp),%rdi
0x2b630861bb16 <_Z25octave_set_signal_handleriPFviEb+86>:
    callq  0x2b630905ede8 <sigemptyset>
1: x/3i $pc
0x2b630861bae3 <_Z25octave_set_signal_handleriPFviEb+35>:
    movl   $0x0,0x128(%rsp)
0x2b630861baee <_Z25octave_set_signal_handleriPFviEb+46>:
    je     0x2b630861bb50 <_Z25octave_set_signal_handleriPFviEb+144>
---Type <return> to continue, or q <return> to quit---
0x2b630861baf0 <_Z25octave_set_signal_handleriPFviEb+48>:    test   %dl,%dl
Current language:  auto; currently c++
(gdb)
-------------------------------------


Assembly instructions at crash
(gdb) s

Program received signal SIGSEGV, Segmentation fault.
0x00002b630905ede8 in sigemptyset ()
from /global/home/keith/software/octave-3.4.0/src/.libs/liboctinterp-3.4.0.so
2: x/10i $pc
0x2b630905ede8 <sigemptyset>:    callq  0x2b636c0ef3da
0x2b630905eded <sigemptyset+5>:    sub    (%rax),%eax
0x2b630905edef <sigemptyset+7>:    add    %dh,%al
0x2b630905edf1 <sigaction+1>:    in     (%dx),%eax
0x2b630905edf2 <sigaction+2>:    add    $0x2b6309,%eax
0x2b630905edf7 <sigaction+7>:    add    %bh,%al
0x2b630905edf9 <sigaddset+1>:    in     (%dx),%eax
0x2b630905edfa <sigaddset+2>:    add    $0x2b6309,%eax
0x2b630905edff <sigaddset+7>:    add    %al,(%rax)
0x2b630905ee01 <sigprocmask+1>:    out    %al,(%dx)
1: x/3i $pc
0x2b630905ede8 <sigemptyset>:    callq  0x2b636c0ef3da
0x2b630905eded <sigemptyset+5>:    sub    (%rax),%eax
0x2b630905edef <sigemptyset+7>:    add    %dh,%al
(gdb)


   - the preprocessed source file (g++ -E -dD) of the compilation unit
     that contains the gnulib::sigemptyset invocation.

It's beyond my mental capacity right now to parse the make command and set up the proper environment to do this manually. I've attached make output that includes "sighandlers", in case that might be of help. If it's necessary, I can try to get preprocessor output.

Keith

Bruno

Attachment: sighandler.txt
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]