Illegal instruction or undefined symbol from import

M

Mathias Waack

Hi,

I've embedded python into a legacy application. It works - most of the time.
In some special situations the app crashes executing the "import random".
There are two different situations:

1. the sources compiled with gcc 4.1.2 crash with illegal instruction error:

(running my application)

Python 2.3.5 (#1, Jun 9 2006, 11:49:02)
[GCC 4.1.2 20060604 (prerelease) (Debian 4.1.1-2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
dlopen("/usr/lib/python2.3/lib-dynload/readline.so", 2);
import readline # dynamically loaded
from /usr/lib/python2.3/lib-dynload/readline.soimport random # from /usr/lib/python2.3/random.py
# can't create /usr/lib/python2.3/random.pyc
dlopen("/usr/lib/python2.3/lib-dynload/math.so", 2);
import math # dynamically loaded from /usr/lib/python2.3/lib-dynload/math.so
Illegal instruction

Running python itself works.

2. the sources compiled with 4.0.3 give me an undefined symbol error:
# /usr/lib/python2.3/random.pyc matches /usr/lib/python2.3/random.py
import random # precompiled from /usr/lib/python2.3/random.pyc
dlopen("/usr/lib/python2.3/lib-dynload/math.so", 2);
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.3/random.py", line 42, in ?
from math import log as _log, exp as _exp, pi as _pi, e as _e
ImportError: /usr/lib/python2.3/lib-dynload/math.so: undefined symbol:
PyFPE_jbuf
It gives the same traceback in both python itself and the embedded version.

My main problem is the first error. I've found some older postings
describing this behaviour and pointing at a compiler error
(http://mail.python.org/pipermail/python-dev/2003-May/035386.html). But I'm
not able to verify this error with gcc 4.1.2.

Google finds some postings describing the same error - but it looks like
nobody ever got an answer:( Would be nice to have more success...

Regards
Mathias
 
M

Mathias Waack

Continuing my monologe;)

Mathias said:
I've embedded python into a legacy application. It works - most of the
time. In some special situations the app crashes executing the "import
random". There are two different situations:

1. the sources compiled with gcc 4.1.2 crash with illegal instruction
error:

(running my application)

Python 2.3.5 (#1, Jun 9 2006, 11:49:02)
[GCC 4.1.2 20060604 (prerelease) (Debian 4.1.1-2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
dlopen("/usr/lib/python2.3/lib-dynload/readline.so", 2);
import readline # dynamically loaded
from /usr/lib/python2.3/lib-dynload/readline.soimport random # from /usr/lib/python2.3/random.py
# can't create /usr/lib/python2.3/random.pyc
dlopen("/usr/lib/python2.3/lib-dynload/math.so", 2);
import math # dynamically loaded from
/usr/lib/python2.3/lib-dynload/math.so Illegal instruction

Running python itself works.

The error occurred in calls to math.log(). I've patched mathmodule.c and
call log1p(x-1) instead of log. It works as a first workaround.

BTW, does anybody know why the c-lib offers both log and log1p?

Mathias
 
R

Richard Brodie

BTW, does anybody know why the c-lib offers both log and log1p?

So you can get a sensible answer computing log(1 + 10 ^ -30). There's
a lot of somewhat obscure mathematical stuff that got into the standard
C lib. How often do you need Bessel functions?
 
M

Mathias Waack

Richard said:
So you can get a sensible answer computing log(1 + 10 ^ -30).

Ok, that make sense to me.
There's
a lot of somewhat obscure mathematical stuff that got into the standard
C lib. How often do you need Bessel functions?

Maybe each day. What is a Bessel function?;)

Mathias
 
N

Nick Maclaren

|>
|> > There's
|> > a lot of somewhat obscure mathematical stuff that got into the standard
|> > C lib. How often do you need Bessel functions?
|>
|> Maybe each day. What is a Bessel function?;)

Some people use them all the time; there are specific physical problems
where they are fundamental. I have never used them, in 40 years of
wide-ranging experience in the scientific computing arena!


Regards,
Nick Maclaren.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top