LinuxQuestions.org
Register a domain and help support LQ
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 03-17-2010, 09:42 PM   #1
grail
Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 7,519

Rep: Reputation: 1896Reputation: 1896Reputation: 1896Reputation: 1896Reputation: 1896Reputation: 1896Reputation: 1896Reputation: 1896Reputation: 1896Reputation: 1896Reputation: 1896
Segfault in Python 3.x test script


So Python noob question, but here goes, I have issued the following
at a command prompt:

>python3 test_AES.py

and receive:

.python[13026]: segfault at ffffffffffffffff ip ffffffffffffffff sp 00007fffa2234778 error 14
Segmentation fault

My question is, can someone suggest how I would go about debugging where my problem is?

I have tried to use pdb but am not real familiar with options.
Please let me know if there is further detail required?

Cheers
Grail
 
Old 03-24-2010, 09:29 AM   #2
rnesius
LQ Newbie
 
Registered: Jun 2009
Location: St. Cloud, MN
Distribution: Ubuntu LTS
Posts: 15

Rep: Reputation: 2
I'm going to guess the issue isn't your python code, but rather the fact there is a mismatch between shared libraries somewhere. What modules does your script use?
 
Old 03-24-2010, 09:58 AM   #3
grail
Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 7,519

Original Poster
Rep: Reputation: 1896Reputation: 1896Reputation: 1896Reputation: 1896Reputation: 1896Reputation: 1896Reputation: 1896Reputation: 1896Reputation: 1896Reputation: 1896Reputation: 1896
hey mesius ... wasn't sure anyone was going to help on this one.

You are 100% correct about the shared libraries. I have converted (or in the process of) the Pycrypto module
to be Python3.X compatible. I am able to run my own small scripts using the likes of AES, Blowfish encryptions,
but i am receiving this segfault when I am trying to run the built in tests that came with it.

To make it simple I am happy to look at just one of the libraries and when pointed in the right direction
will tackle the others myself. To this end I have been trying to find a way to debug AES.so which was created as
part of the install. Are you able to help me understand the best way to debug this shared library?

I have added the -g option to the compilation and if I do a simple - gdb AES.so it tells me that it loads
all necessary symbols, but of course when I then run and backtrace I am not lead to any intelligible errors.

When searching on google it says that the best way to debug a shared library is to compile it into
another program, but the issue I have here is I would not know what sort of program to write to
illicit the correct outcome

Please let me know what sort of information I can provide to further this effort?
 
Old 03-25-2010, 10:13 AM   #4
rnesius
LQ Newbie
 
Registered: Jun 2009
Location: St. Cloud, MN
Distribution: Ubuntu LTS
Posts: 15

Rep: Reputation: 2
It's been awhile since I've debugged shared libraries - it can be tricky. Often times the problem isn't with the main library you are working with, but rather the problem is an compatibility with a library that is being depended on. So to see what libraries AES.so needs, use the 'ldd' command.

* ldd AES.so # should show you the libraries AES.so depends on.
* ldd -r AES.so # forces the loader to resolve all of the symbols - which will sniff out symbols that can't be found in any libraries.

By the way - make sure the libraries being found are the ones it should be finding. A common problem is that the loader grabs a version of a library out of /usr/lib instead of from your test area. You can use the LD_LIBRARY_PATH or SHLIB_PATH environment variables to give a list of paths to prefer over the default system paths, which are defined in /etc/ld.so.conf (usually).

-Rob
 
Old 03-26-2010, 02:34 AM   #5
grail
Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 7,519

Original Poster
Rep: Reputation: 1896Reputation: 1896Reputation: 1896Reputation: 1896Reputation: 1896Reputation: 1896Reputation: 1896Reputation: 1896Reputation: 1896Reputation: 1896Reputation: 1896
So ldd - AES.so gives:

Quote:
linux-vdso.so.1 => (0x00007fff04dfe000)
libpython3.1.so.1.0 => /usr/lib/libpython3.1.so.1.0 (0x00007f08fc7ac000)
libpthread.so.0 => /lib/libpthread.so.0 (0x00007f08fc590000)
libc.so.6 => /lib/libc.so.6 (0x00007f08fc235000)
libintl.so.8 => /usr/lib/libintl.so.8 (0x00007f08fc029000)
libdl.so.2 => /lib/libdl.so.2 (0x00007f08fbe25000)
libutil.so.1 => /lib/libutil.so.1 (0x00007f08fbc21000)
libm.so.6 => /lib/libm.so.6 (0x00007f08fb99e000)
/lib64/ld-linux-x86-64.so.2 (0x00007f08fcda0000)
I am assuming from this output that all the symbols have been found?
 
Old 03-26-2010, 02:39 PM   #6
rnesius
LQ Newbie
 
Registered: Jun 2009
Location: St. Cloud, MN
Distribution: Ubuntu LTS
Posts: 15

Rep: Reputation: 2
Yes - this means the loader was able to resolve all of the symbols.

This means the problem is a bit (actually, a lot) more subtle. Are you able to do very limited tests with the python script to see if it's possible to invoke the script without provoking the segfault? If so, try to map python code to functionality in the library you're porting. That will help get you "in the right neighborhood". Sorry I can't offer better advice than that... without the ability to poke and prod at this myself I can only offer some high-level advice.

-Rob
 
Old 03-28-2010, 01:18 AM   #7
grail
Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 7,519

Original Poster
Rep: Reputation: 1896Reputation: 1896Reputation: 1896Reputation: 1896Reputation: 1896Reputation: 1896Reputation: 1896Reputation: 1896Reputation: 1896Reputation: 1896Reputation: 1896
Hi Rob

Thanks for the input. Yes I am able to utilise the python code without invoking the segfault.
i was happily doing so until I tried to run the built in tests, which I am guessing are doing
things I haven't tried as yet
I will try as you have suggested and see how I go.

Cheers
 
  


Reply

Tags
python311, segfault


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
scaling network test app python libnet/pcap taltman Linux - Networking 0 05-30-2008 11:43 AM
LXer: PHP, Perl and Python pass Homeland Security test LXer Syndicated Linux News 0 01-09-2008 02:10 PM
Python test script yields 'Connection refused' BigNate37 Linux - Server 1 12-03-2007 09:45 PM
python cgi script and premature end of script headers Neruocomp Programming 1 07-28-2005 11:43 AM
Python giving SegFault Kumar Programming 2 02-16-2004 10:51 PM


All times are GMT -5. The time now is 03:30 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration