discuss-gnuradio
[Top][All Lists]
Advanced

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

[Discuss-gnuradio] Information on ticket:181 and invitation to help (lon


From: Johnathan Corgan
Subject: [Discuss-gnuradio] Information on ticket:181 and invitation to help (long)
Date: Thu, 17 Jan 2008 13:09:31 -0800
User-agent: Thunderbird 2.0.0.6 (X11/20071022)

As a follow up to the previous message regarding the segfault issue with
ticket:181, here is a simple test case that shows the problem.  See the
end of this email for a request to help document which systems this
occurs on (you won't need to do all the below, or use gdb as shown; just
run a couple commands.)

The problem in short:

$ python
Python 2.5.1 (r251:54863, Oct  5 2007, 13:50:07)
[GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from gnuradio import gr
>>> gr.firdes.hilbert(0)
terminate called after throwing an instance of 'std::out_of_range'
  what():  Hilbert:  Must have odd number of taps
Aborted (core dumped)
$

To show the problem in gory detail:

First, run Python inside gdb:

$ gdb python
GNU gdb 6.6-debian
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu"...
(no debugging symbols found)
Using host libthread_db library "/lib/libthread_db.so.1".
(gdb)

Then run it to get the interactive prompt:

(gdb) run
Starting program: /usr/bin/python
(no debugging symbols found)
(no debugging symbols found)
[Thread debugging using libthread_db enabled]
[New Thread 47791743497952 (LWP 9791)]
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
Python 2.5.1 (r251:54863, Oct  5 2007, 13:50:07)
[GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
>>>

Now execute a command that will generate an exception in swig wrapped
C++ code.  In this case, we call the Hilbert filter generator with an
invalid number of taps.  What should happen is that the swig wrapper
would catch this C++ exception and turn it into a Python exception,
which would then get printed and control returned to the Python command
line.  Instead:

>>> from gnuradio import gr
>>> gr.firdes.hilbert(0)
terminate called after throwing an instance of 'std::out_of_range'
  what():  Hilbert:  Must have odd number of taps

Program received signal SIGABRT, Aborted.
[Switching to Thread 47791743497952 (LWP 9791)]
0x00002b7761b25765 in raise () from /lib/libc.so.6
(gdb)

This above is what would happen if the exception thrown by GNU Radio C++
code were not being caught; it would unwind and eventually blow out the
top with an abort like above.  However, lets look at the stack:

(gdb) info threads
* 1 Thread 47791743497952 (LWP 9791)  0x00002b7761b25765 in raise ()
from /lib/libc.so.6
(gdb) thread apply all bt

Thread 1 (Thread 47791743497952 (LWP 9791)):
#0  0x00002b7761b25765 in raise () from /lib/libc.so.6
#1  0x00002b7761b271c0 in abort () from /lib/libc.so.6
#2  0x00002b7762f2c7b4 in __gnu_cxx::__verbose_terminate_handler () from
/usr/lib/libstdc++.so.6
#3  0x00002b7762f2a746 in ?? () from /usr/lib/libstdc++.so.6
#4  0x00002b7762f2a773 in std::terminate () from /usr/lib/libstdc++.so.6
#5  0x00002b7762f2a85a in __cxa_throw () from /usr/lib/libstdc++.so.6
#6  0x00002b7762b56ea6 in gr_firdes::hilbert (ntaps=0,
windowtype=gr_firdes::WIN_RECTANGULAR, beta=6.7599999999999998) at
gr_firdes.cc:306
#7  0x00002b7763f11f7f in _wrap_firdes_hilbert (self=0x0, args=<value
optimized out>) at gnuradio_swig_py_general.cc:24183
#8  0x0000000000417e53 in PyObject_Call ()
#9  0x0000000000486997 in PyEval_EvalFrameEx ()
#10 0x0000000000489d60 in PyEval_EvalCodeEx ()
#11 0x0000000000487f32 in PyEval_EvalFrameEx ()
#12 0x0000000000489d60 in PyEval_EvalCodeEx ()
#13 0x0000000000489da2 in PyEval_EvalCode ()
#14 0x00000000004abbb7 in PyRun_InteractiveOneFlags ()
#15 0x00000000004abdc4 in PyRun_InteractiveLoopFlags ()
#16 0x00000000004abeca in PyRun_AnyFileExFlags ()
#17 0x0000000000414725 in Py_Main ()
#18 0x00002b7761b11b44 in __libc_start_main () from /lib/libc.so.6
#19 0x0000000000413c69 in _start ()
(gdb)

Stack frame #7 is the call to the swig generated C++ wrapper, #6 is the
actual GNU Radio C++ implementation of the Hilbert code.  Let's look at #6:

(gdb) up 6
#6  0x00002b7762b56ea6 in gr_firdes::hilbert (ntaps=0,
windowtype=gr_firdes::WIN_RECTANGULAR, beta=6.7599999999999998) at
gr_firdes.cc:306
306         throw std::out_of_range("Hilbert:  Must have odd number of
taps");
Current language:  auto; currently c++
(gdb) l
301     gr_firdes::hilbert (unsigned int ntaps,
302                         win_type windowtype,
303                         double beta)
304     {
305       if(!(ntaps & 1))
306         throw std::out_of_range("Hilbert:  Must have odd number of
taps");
307
308       vector<float> taps(ntaps);
309       vector<float> w = window (windowtype, ntaps, beta);
310       unsigned int h = (ntaps-1)/2;
(gdb)

So in line 305 we tested the number of taps and in 306 we throw the
std::out_of_range exception.  In the calling stack frame:

(gdb) up
#7  0x00002b7763f11f7f in _wrap_firdes_hilbert (self=0x0, args=<value
optimized out>) at gnuradio_swig_py_general.cc:24183
24183       result = gr_firdes::hilbert(arg1);
(gdb) l
24178     if (!SWIG_IsOK(ecode1)) {
24179       SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '"
"firdes_hilbert" "', argument " "1"" of type '" "unsigned int""'");
24180     }
24181     arg1 = static_cast< unsigned int >(val1);
24182     try {
24183       result = gr_firdes::hilbert(arg1);
24184     }
24185     catch(std::out_of_range &_e) {
24186       SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
24187     }
(gdb)

This is the swig generated wrapper code that does the transition from
Python to C++. Line 24182 sets up a try block to call our code; when we
throw the exception, it should be getting caught by the handler in line
24185.  Instead, it acts "as if" this code didn't exist, and stack
frames #4-#0 show the call into glibc to abort the application.

*** Request For Help ***

We need people to run this simple test case and post to the list whether
it works or not, and a few items of information about their configuration:

$ python
Python 2.5.1 (r251:54863, Oct  5 2007, 13:50:07)
[GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from gnuradio import gr
>>> gr.firdes.hilbert(0)
terminate called after throwing an instance of 'std::out_of_range'
  what():  Hilbert:  Must have odd number of taps
Aborted (core dumped)
$

$ g++ --version
gcc (GCC) 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$


$ swig -version

SWIG Version 1.3.31

Compiled with g++ [x86_64-unknown-linux-gnu]
Please see http://www.swig.org for reporting bugs and further information
$

Finally, the GNU Radio version in use (here I'm using 3.1svn), and the
OS/platform (here I have Ubuntu 7.10 64-bit desktop on an Intel Core 2
Duo processor.)

Thanks!

-- 
Johnathan Corgan
Corgan Enterprises LLC
http://corganenterprises.com




reply via email to

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