On 5/4/2012 11:00 AM, Jan de Kruyf wrote:
> So personally in this case I would set a breakpoint at a stategic place and
> only use gdb to give me a stacktrace. Then work my way back through the
> software to see if I could spot the culprit.

Here's a stack trace for two different cases:

* Running rtapi_app using electric fence

* Running hal_cmd and following the child on fork (the crash happens in
rtapi_app, launched by hal_cmd)

Of possible interest:
If you run rtapi_app on it's own without electric fence, it doesn't crash.

-- 
Charles Steinkuehler
char...@steinkuehler.net
root@maker:/home/charles/src/linuxcnc-bitmuster# gdb bin/halcmd
GNU gdb (GDB) 7.4-debian
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/charles/src/linuxcnc-bitmuster/bin/halcmd...done.
(gdb) start -V -f lat.hal
Temporary breakpoint 1 at 0x402970: file hal/utils/halcmd_main.c, line 73.
Starting program: /home/charles/src/linuxcnc-bitmuster/bin/halcmd -V -f lat.hal

Temporary breakpoint 1, main (argc=4, argv=0x7fffffffec28) at 
hal/utils/halcmd_main.c:73
73      {
(gdb) set follow-fork-mode child
(gdb) c
Continuing.
HAL: initializing hal_lib
HAL: initializing component 'halcmd13705'
HAL: component 'halcmd13705' initialized, ID = 13705
HAL: removing component 13705
HAL: component 13705 removed, name = 'halcmd13705'
[New process 13709]
HAL: initializing hal_lib
HAL: initializing component 'halcmd13705'
HAL: component 'halcmd13705' initialized, ID = 13705
/home/charles/src/linuxcnc-bitmuster/bin/rtapi_app load threads name1=fast 
period1=25000 name2=slow period2=1000000
process 13709 is executing new program: 
/home/charles/src/linuxcnc-bitmuster/bin/rtapi_app
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
rtapi_clock_set_period (res=1) -> 25000
Creating new task with requested priority 98 (highest=99 lowest=1)
About to pthread_create task 0
[New Thread 0x6128e0 (LWP 13710)]
Created task 0
Hello world, I am task 0
rtapi task 0: Reset pagefault counter
task 0x60a9b0 period = 25000 ratio=1
Setting affinity of 0
Using CPU 3
Calling pthread_setaffinity_np() for 0
pthread_setaffinity_np() for 0 done
Affinity set for 0
Task 0 finished its basic init
THREADS: created 25 uS thread

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffff7fe0720 (LWP 13709)]
_int_malloc (av=0x7ffff7011e60, bytes=16384) at malloc.c:4439
4439    malloc.c: No such file or directory.
(gdb) bt
#0  _int_malloc (av=0x7ffff7011e60, bytes=16384) at malloc.c:4439
#1  0x00007ffff6d098d0 in *__GI___libc_malloc (bytes=16384) at malloc.c:3660
#2  0x000000000040741c in rtapi_task_new (taskcode=0x7ffff6a87cf8 
<thread_task>, arg=0x7ffff7fdee00, prio=97, owner=32768, stacksize=16384, 
uses_fp=<optimized out>)
    at rtapi/linux_rtapi.c:260
#3  0x00007ffff6a8849f in hal_create_thread (name=<optimized out>, 
period_nsec=1000000, uses_fp=1) at hal/hal_lib.c:1823
#4  0x00007ffff6885330 in rtapi_app_main () at hal/components/threads.c:121
#5  0x00000000004059f9 in do_load_cmd (name=..., args=...) at 
rtapi/linux_rtapi_app.cc:256
#6  0x0000000000405b34 in handle_command (args=...) at 
rtapi/linux_rtapi_app.cc:361
#7  0x0000000000404751 in master (args=<error reading variable: access outside 
bounds of object referenced via synthetic pointer>, fd=7) at 
rtapi/linux_rtapi_app.cc:389
#8  main (argc=<optimized out>, argv=<optimized out>) at 
rtapi/linux_rtapi_app.cc:718
(gdb)
root@maker:/home/charles/src/linuxcnc-bitmuster# gdb bin/rtapi_app
GNU gdb (GDB) 7.4-debian
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/charles/src/linuxcnc-bitmuster/bin/rtapi_app...done.
(gdb) underfence
Enabled Electric Fence for undeflow detection
(gdb) start load threads name1=fast period1=50000
Temporary breakpoint 1 at 0x404450: file rtapi/linux_rtapi_app.cc, line 673.
Starting program: /home/charles/src/linuxcnc-bitmuster/bin/rtapi_app load 
threads name1=fast period1=50000
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Temporary breakpoint 1, main (argc=5, argv=0x7fffffffebc8) at 
rtapi/linux_rtapi_app.cc:673
673     {
(gdb) c
Continuing.

  Electric Fence 2.1 Copyright (C) 1987-1998 Bruce Perens.
rtapi_clock_set_period (res=1) -> 50000
Creating new task with requested priority 98 (highest=99 lowest=1)
About to pthread_create task 0
[New Thread 0x7ffff7f13700 (LWP 13667)]
Created task 0
Hello world, I am task 0

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffff7f13700 (LWP 13667)]
0x00007ffff6ace4b3 in _IO_vfprintf_internal (s=0x7ffff7f124e0, format=0x4083d6 
"rtapi task %d: Reset pagefault counter\n", ap=0x7ffff7f12c98) at vfprintf.c:245
245     vfprintf.c: No such file or directory.
(gdb) bt
#0  0x00007ffff6ace4b3 in _IO_vfprintf_internal (s=0x7ffff7f124e0, 
format=0x4083d6 "rtapi task %d: Reset pagefault counter\n", ap=0x7ffff7f12c98) 
at vfprintf.c:245
#1  0x00007ffff6ad3a60 in buffered_vfprintf (s=0x7ffff6e0d880, format=0x4083d6 
"rtapi task %d: Reset pagefault counter\n", args=0x7ffff7f12c98) at 
vfprintf.c:2260
#2  0x00007ffff6ace68e in _IO_vfprintf_internal (s=0x7ffff6e0d880, 
format=0x4083d6 "rtapi task %d: Reset pagefault counter\n", ap=0x7ffff7f12c98) 
at vfprintf.c:1306
#3  0x00000000004069b9 in rtapi_print_msg (level=<optimized out>, 
fmt=<optimized out>) at ./rtapi/linux_common.h:207
#4  0x0000000000407130 in rtapi_reset_pagefault_count (task=0x60a9b0) at 
rtapi/linux_rtapi.c:131
#5  realtime_thread (arg=0x60a9b0) at rtapi/linux_rtapi.c:497
#6  0x00007ffff77c0b50 in start_thread (arg=<optimized out>) at 
pthread_create.c:304
#7  0x00007ffff6b6490d in clone () at 
../sysdeps/unix/sysv/linux/x86_64/clone.S:112
#8  0x0000000000000000 in ?? ()
(gdb) q
A debugging session is active.

        Inferior 1 [process 13664] will be killed.

Quit anyway? (y or n) y
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Emc-developers mailing list
Emc-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-developers

Reply via email to