Discussion:
[omniORB] Segmentation fault when marshalling a string from python
Floris Bruynooghe
2010-01-10 21:54:23 UTC
Permalink
Hi

When running this script in Python I get a segementation fault:
"""
import omniORB
import CORBA

omniORB.cdrMarshal(CORBA.TC_string, 'foo')
"""

The problem is in pyMarshal.cc:marshalPyObjectString(), the stream
object there has a pd_tcs_c member with NULL as value, which is what I
think causes the segfault. But I'm afraid I don't understand enough
of the iternals to make much more out of this. Can anybody help find
out what is going on?

Here the raw gdb output:

(gdb) run
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /usr/bin/python test.py
[Thread debugging using libthread_db enabled]

Breakpoint 2, marshalPyObjectString (stream=..., d_o=0xb7c5fdcc,
a_o=0xb7dcfec0) at ../../modules/pyMarshal.cc:1949
1949 ../../modules/pyMarshal.cc: No such file or directory.
in ../../modules/pyMarshal.cc
(gdb) bt
#0 marshalPyObjectString (stream=..., d_o=0xb7c5fdcc, a_o=0xb7dcfec0)
at ../../modules/pyMarshal.cc:1949
#1 0xb7bd6718 in omniPy::marshalPyObject (self=0x0, args=0xb7dd43c4)
at ../../modules/omnipy.h:530
#2 omnipy_cdrMarshal (self=0x0, args=0xb7dd43c4)
at ../../modules/omnipy.cc:618
#3 0x080cd12a in call_function (f=0x81f29d4, throwflag=0)
at ../Python/ceval.c:3612
#4 PyEval_EvalFrameEx (f=0x81f29d4, throwflag=0) at ../Python/ceval.c:2304
#5 0x080ce445 in PyEval_EvalCodeEx (co=0xb7dc0d58, globals=0xb7dc4b54,
locals=0x0, args=0x81a7d38, argcount=2, kws=0x81a7d40, kwcount=0,
defs=0xb7ddb198, defcount=1, closure=0x0) at ../Python/ceval.c:2875
#6 0x080ccde4 in fast_function (f=0x81a7bfc, throwflag=0)
at ../Python/ceval.c:3708
#7 call_function (f=0x81a7bfc, throwflag=0) at ../Python/ceval.c:3633
#8 PyEval_EvalFrameEx (f=0x81a7bfc, throwflag=0) at ../Python/ceval.c:2304
#9 0x080ce445 in PyEval_EvalCodeEx (co=0xb7dc0338, globals=0xb7e11acc,
locals=0xb7e11acc, args=0x0, argcount=0, kws=0x0, kwcount=0, defs=0x0,
defcount=0, closure=0x0) at ../Python/ceval.c:2875
#10 0x080ce657 in PyEval_EvalCode (co=0xb7dc0338, globals=0xb7e11acc,
locals=0xb7e11acc) at ../Python/ceval.c:514
#11 0x080eb36f in run_mod (fp=0x816b008, filename=0xbffff3eb "test.py",
start=257, globals=0xb7e11acc, locals=0xb7e11acc, closeit=1,
---Type <return> to continue, or q <return> to quit---q
flags=0xbffff14Quit
(gdb) pyo d_o
object : (18, 0)
type : tuple
refcount: 2
address : 0xb7c5fdcc
$18 = void
(gdb) pyo a_o
object : 'foo'
type : str
refcount: 5
address : 0xb7dcfec0
$19 = void
(gdb) p stream
$20 = (class cdrStream &) @0xbfffea78: {_vptr.cdrStream = 0xb7b99dc8,
pd_unmarshal_byte_swap = false, pd_marshal_byte_swap = false,
pd_inb_end = 0xbfffeab0, pd_inb_mkr = 0xbfffeab0, pd_outb_end = 0xbfffead0,
pd_outb_mkr = 0xbfffeab1, pd_tcs_c = 0x0, pd_tcs_w = 0x0, pd_ncs_c = 0x0,
pd_ncs_w = 0x0, pd_valueTracker = 0x0, static _classid = 0}
(gdb) s

Program received signal SIGSEGV, Segmentation fault.
0xb7bef6cb in marshalPyObjectString (stream=..., d_o=0xb7c5fdcc,
a_o=0xb7dcfec0) at ../../modules/pyMarshal.cc:1949
1949 in ../../modules/pyMarshal.cc
(gdb)


Any hints appreciated.
Floris
--
Debian GNU/Linux -- The Power of Freedom
www.debian.org | www.gnu.org | www.kernel.org
Duncan Grisby
2010-01-11 16:54:21 UTC
Permalink
Post by Floris Bruynooghe
"""
import omniORB
import CORBA
omniORB.cdrMarshal(CORBA.TC_string, 'foo')
"""
The problem is in pyMarshal.cc:marshalPyObjectString(), the stream
object there has a pd_tcs_c member with NULL as value, which is what I
think causes the segfault. But I'm afraid I don't understand enough
of the iternals to make much more out of this. Can anybody help find
out what is going on?
You need to call CORBA.ORB_init() first. The segfault is caused by it
trying to access code set information that is set up by ORB_init().

It would be nice if it threw an exception rather than giving a segfault,
but I don't really want to add a check for it because that would involve
adding an extra test along the call chain of some really
performance-critical code.

Cheers,

Duncan.
--
-- Duncan Grisby --
-- ***@grisby.org --
-- http://www.grisby.org --
Floris Bruynooghe
2010-01-12 01:23:26 UTC
Permalink
Post by Duncan Grisby
Post by Floris Bruynooghe
"""
import omniORB
import CORBA
omniORB.cdrMarshal(CORBA.TC_string, 'foo')
"""
The problem is in pyMarshal.cc:marshalPyObjectString(), the stream
object there has a pd_tcs_c member with NULL as value, which is what I
think causes the segfault. But I'm afraid I don't understand enough
of the iternals to make much more out of this. Can anybody help find
out what is going on?
You need to call CORBA.ORB_init() first. The segfault is caused by it
trying to access code set information that is set up by ORB_init().
It would be nice if it threw an exception rather than giving a segfault,
but I don't really want to add a check for it because that would involve
adding an extra test along the call chain of some really
performance-critical code.
Ah, thanks! May I suggest adding something to that effect to the
docstring of cdrMarshal? (I would create a patch but it seems a bit
trivial)

Regards
Floris
--
Debian GNU/Linux -- The Power of Freedom
www.debian.org | www.gnu.org | www.kernel.org
Loading...