By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,766 Members | 1,427 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,766 IT Pros & Developers. It's quick & easy.

Illegal instruction or undefined symbol from import

P: n/a
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.so
>>import random
import 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:
>>import random
# /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/pyt...y/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

Jul 4 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Continuing my monologe;)

Mathias Waack wrote:
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.so
>>>import random
import 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
Jul 5 '06 #2

P: n/a

"Mathias Waack" <M.*****@gmx.dewrote in message
news:WV*****************@se2-cb104-9.zrh1.ch.colt.net...
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?
Jul 5 '06 #3

P: n/a
Richard Brodie wrote:
"Mathias Waack" <M.*****@gmx.dewrote in message
news:WV*****************@se2-cb104-9.zrh1.ch.colt.net...
>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).
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
Jul 5 '06 #4

P: n/a

In article <ll*****************@se2-cb104-9.zrh1.ch.colt.net>,
Mathias Waack <M.*****@gmx.dewrites:
|>
| 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.
Jul 5 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.