LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-16-2004, 09:07 AM   #1
Kumar
Member
 
Registered: Sep 2003
Location: Pune, India
Distribution: Red Hat
Posts: 106

Rep: Reputation: 15
Unhappy Python giving SegFault


Hi,
I've written a small python script which uses a C program. I've created the interface using swig. The C program contains the code to create a structure of a given type. The problem is that I am getting a segfault when I try to create new members of that structure in python. On tracing it points to malloc_consolidate in libc. I don't know how to solve the problem. I am including the stack trace of the debugged code.

Thanks in advance

Kumar

----------------------------------------------------------------------------------------------------------------------
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1074133056 (LWP 8271)]
0x4207494e in malloc_consolidate () from /lib/tls/libc.so.6
(gdb) where
#0 0x4207494e in malloc_consolidate () from /lib/tls/libc.so.6
#1 0x42073f99 in _int_malloc () from /lib/tls/libc.so.6
#2 0x42073a5e in calloc () from /lib/tls/libc.so.6
#3 0x402b1893 in _wrap_new_iscsi_init_nopout () from ./_pdu.so
#4 0x080d0df4 in PyCFunction_Call ()
#5 0x080b3797 in PyObject_Call ()
#6 0x0807cb13 in PyEval_GetFuncDesc ()
#7 0x0807aaa1 in PyEval_EvalCode ()
#8 0x0807b0ce in PyEval_EvalCodeEx ()
#9 0x080c447c in PyFunction_SetClosure ()
#10 0x080b3797 in PyObject_Call ()
#11 0x080ba4ab in PyMethod_New ()
#12 0x080b3797 in PyObject_Call ()
#13 0x0807c905 in PyEval_GetFuncDesc ()
#14 0x0807a525 in PyEval_EvalCode ()
#15 0x0807b0ce in PyEval_EvalCodeEx ()
#16 0x080c447c in PyFunction_SetClosure ()
#17 0x080b3797 in PyObject_Call ()
#18 0x080ba4ab in PyMethod_New ()
#19 0x080b3797 in PyObject_Call ()
#20 0x08068f9a in _PyObject_SlotCompare ()
#21 0x08060868 in PyTuple_Fini ()
#22 0x080b3797 in PyObject_Call ()
#23 0x0807c905 in PyEval_GetFuncDesc ()
#24 0x0807a525 in PyEval_EvalCode ()
#25 0x0807b0ce in PyEval_EvalCodeEx ()
#26 0x0807c62b in PyEval_GetFuncDesc ()
#27 0x0807a5a3 in PyEval_EvalCode ()
#28 0x0807b0ce in PyEval_EvalCodeEx ()
#29 0x08077fc5 in PyEval_EvalCode ()
#30 0x08097e29 in PyRun_FileExFlags ()
#31 0x080969f5 in PyRun_InteractiveOneFlags ()
#32 0x08096796 in PyRun_InteractiveLoopFlags ()
#33 0x08096697 in PyRun_AnyFileExFlags ()
#34 0x08053a19 in Py_Main ()
#35 0x08053469 in main ()
#36 0x42015574 in __libc_start_main () from /lib/tls/libc.so.6
(gdb)
 
Old 02-16-2004, 11:00 AM   #2
jtshaw
Senior Member
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 67
How are you allocating memory for the structure in the C program? I think I would start looking there for your problem.
 
Old 02-16-2004, 10:51 PM   #3
Kumar
Member
 
Registered: Sep 2003
Location: Pune, India
Distribution: Red Hat
Posts: 106

Original Poster
Rep: Reputation: 15
I am not explicitely allocating any memory for the structures. Swig is generating a wrapper code which in turn allocates memory for my structures. And the code generated by swig is resulting in a segfault(At the position #2 of the stack trace in the file generated by the swig as shown in #3 of the stack trace)

Last edited by Kumar; 02-16-2004 at 10:52 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Processing Conflict: python-devel conflicts python< 2.3.4-13.1 guarriman Fedora 2 04-23-2009 07:02 PM
installing python library's (Python Numeric) Four Linux - Newbie 1 10-16-2005 02:31 PM
Python guru's - Is this a python bug? or is it me? bardinjw Programming 2 06-23-2005 08:17 AM
WineX, python-gnome, and python-gtk DrD Fedora 0 08-03-2004 12:11 PM
install python 2.3 ,necssary to remove python 2.2 ngan_yine Linux - Newbie 7 12-28-2003 04:07 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:39 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration