Bug #362

common_sighandler.c undefined EIP & more

Added by Eduardo almost 4 years ago. Updated over 2 years ago.

Status:ClosedStart date:2013-09-06
Priority:HighDue date:
Assignee:-% Done:

0%

Category:-
Target version:Candidate for next bugfix release
Affected version:5.1.x Platform:Linux

Description

linux 32 bits and gcc-4.8.1. Logs attached.

I think that is missing #include <sys/reg.h>

after adding that I get

/root/software/gmt/GMTdev/gmt5/trunk/src/gmt_memory.c: In function 'GMT_memory_func':
/root/software/gmt/GMTdev/gmt5/trunk/src/gmt_memory.c:471:26: error: #elif with no expression
#elif HAVE_POSIX_MEMALIGN
^
/root/software/gmt/GMTdev/gmt5/trunk/src/gmt_memory.c:473:20: error: #elif with no expression
#elif HAVE_MEMALIGN
^
/root/software/gmt/GMTdev/gmt5/trunk/src/gmt_memory.c:491:26: error: #elif with no expression
#elif HAVE_POSIX_MEMALIGN
^
/root/software/gmt/GMTdev/gmt5/trunk/src/gmt_memory.c:493:20: error: #elif with no expression
#elif HAVE_MEMALIGN
^
make2: * [src/CMakeFiles/gmtlib.dir/gmt_memory.c.o] Error 1
make1:
[src/CMakeFiles/gmtlib.dir/all] Error 2
make: *
* [all] Error 2

mc.txt Magnifier (35 KB) Eduardo, 2013-09-06 18:15

mr.txt Magnifier (33.3 KB) Eduardo, 2013-09-06 18:15

Associated revisions

Revision 12126
Added by Florian almost 4 years ago

Add missing defined-operator (fixes #362).

Revision 12127
Added by Florian almost 4 years ago

Make retrieval of instruction pointer more robust (fixes #362).

Revision 12128
Added by Florian almost 4 years ago

32 bit glibc uses REG_EIP instead of EIP (fixes #362).

History

#1 Updated by Florian almost 4 years ago

  • Status changed from New to Feedback

Thanks for reporting. I added the missing defined-operator in r12126:

#elif defined(HAVE_POSIX_MEMALIGN)
#elif defined(HAVE_MEMALIGN)
Try again. I didn't see any errors related to uc_mcontext. How old is your glibc? Can you check whether uc_mcontext contains a field named eip or gregs in sys/ucontext.h?

#2 Updated by Eduardo almost 4 years ago

libc6-dev:i386 2.17-92 (Debian Jessie, 32 bits)

sys/ucontext.h has for !__x86_64__ :

/* Context to describe whole processor state. */
typedef struct {
gregset_t gregs;
/* Due to Linux's history we have to use a pointer here. The SysV/i386
ABI requires a struct with the values. */
fpregset_t fpregs;
unsigned long int oldmask;
unsigned long int cr2;
} mcontext_t;

/* Userlevel context. */
typedef struct ucontext {
unsigned long int uc_flags;
struct ucontext *uc_link;
stack_t uc_stack;
mcontext_t uc_mcontext;
__sigset_t uc_sigmask;
struct _libc_fpstate __fpregs_mem;
} ucontext_t;

Is that what you are looking for?

#3 Updated by Florian almost 4 years ago

Is that what you are looking for?

Yes. Well, then the signal handler should compile fine on your debian machine. Or do you still get errors?

#4 Updated by Florian almost 4 years ago

Could you also check whether ucontext.h defines EIP or REG_EIP? You might have to change the macro in common_sighandler.c:

#  define UC_IP(uc) ((void *) (uc)->uc_mcontext.gregs[REG_EIP])

#5 Updated by Eduardo almost 4 years ago

Now compiles in my box with that change (REG_EIP instead of EIP).

Also if you have libc6-dev-amd64 (I have it in my 32 bit linux), you can include /usr/include/sys/reg.h and let EIP.

I don't know the difference.

Besides compilation, is there any way to test if this is working?

#6 Updated by Florian almost 4 years ago

Now compiles in my box with that change (REG_EIP instead of EIP).

OK, thanks for the input.

Besides compilation, is there any way to test if this is working?

For example:

gmt convert -i1
killall -11 gmt # in another terminal
or hit ctrl-c.

#7 Updated by Eduardo almost 4 years ago

This on x86_64

$ gmt convert -i1
(I hit CTRL-C)
Interrupt at /lib/x86_64-linux-gnu/libc.so.6(__read+0x10)[0x7f9e4a028a90]
Tuser: 0.040s Tsys: 0.004s VmRSS: 18552kB VmSize: 260796kB
Press return to continue, ctrl-c to quit.
(I hit return)
gmtconvert: Selection lead to no output columns.

This on i386:

$ gmt convert -i1
(I hit CTRL-C)
Interrupt at linux-gate.so.1(__kernel_vsyscall+0x10)[0xb7729424]
Tuser: 0.032s Tsys: 0.016s VmRSS: 13324kB VmSize: 93436kB
Press return to continue, ctrl-c to quit.
(I hit return)
gmtconvert: Selection lead to no output columns.

#8 Updated by Florian almost 4 years ago

  • Status changed from Feedback to Resolved

I admit, that the stack backtrace is insignificant when you do blocking I/O. It makes more sense when you do something CPU-intensive. Try interrupting psxy in your example from #357 at different times. The complete stack backtrace comes handy when gmt crashes and receives SIGSEGV. Note, this feature is only implemented for UNIX OSs that provide the backtrace() function. And program interruption is not implemented for Windows at all although it would be possible: http://stackoverflow.com/questions/16826097/equivalent-to-sigint-posix-signal-for-catching-ctrlc-under-windows-mingw.

#9 Updated by Florian almost 4 years ago

  • Target version changed from 5.1.0 to Candidate for next bugfix release

#10 Updated by Remko over 2 years ago

  • Status changed from Resolved to Closed
  • Affected version changed from 5.x-dev to 5.1.x

Also available in: Atom PDF