[ python-Bugs-1720241 ] Compiler is not thread safe?

SourceForge.net noreply at sourceforge.net
Sat May 19 01:14:21 CEST 2007


Bugs item #1720241, was opened at 2007-05-16 14:38
Message generated for change (Comment added) made by rhettinger
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1720241&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Parser/Compiler
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: ‹‹PC›› (zpcz)
Assigned to: Nobody/Anonymous (nobody)
Summary: Compiler is not thread safe?

Initial Comment:
r = '''
a(b(c[d]))
'''
from threading import Thread
from compiler import parse
Thread(target = parse, args = (r,)).start()

leads to 
Bus error (core dumped)

When runs not in thread everything is OK.
OS FreeBSD 5.4.
Python 2.5.1 (seems that 2.5 also has this error)
(Runs perfectly on Linux, and on FreeBSD with Python 2.4)

----------------------------------------------------------------------

>Comment By: Raymond Hettinger (rhettinger)
Date: 2007-05-18 18:14

Message:
Logged In: YES 
user_id=80475
Originator: NO

FWIW, I cannot get the OP's script to fail on Py2.5.1 on either Windows XP
or on Gentoo Linux.

----------------------------------------------------------------------

Comment By: Georg Brandl (gbrandl)
Date: 2007-05-18 04:37

Message:
Logged In: YES 
user_id=849994
Originator: NO

> The compiler package is written in pure Python, so no matter what
> statements it makes, it should not crash the interpreter.

This is not entirely true, it uses the C-written parser module to parse
its input.

----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2007-05-18 01:52

Message:
Logged In: YES 
user_id=21627
Originator: NO

The compiler package is written in pure Python, so no matter what
statements it makes, it should not crash the interpreter.

Given that this is not easily reproducable on other systems, chances are
high that this is indeed an operating system bug or limitation.

----------------------------------------------------------------------

Comment By: ‹‹PC›› (zpcz)
Date: 2007-05-17 10:59

Message:
Logged In: YES 
user_id=1395738
Originator: YES

Actually here is the simpler test cases:
r = '(((a)))'
or
r = '[[[a]]]'

info threads in GDB prints folowing:
  4 Thread 2 (LWP 100196)  0x281a02fb in pthread_testcancel () from
/usr/lib/libpthread.so.1
* 3 Thread 3 (LWP 100119)  0x28195aca in _pthread_mutex_lock () from
/usr/lib/libpthread.so.1
  2 Thread 1 (runnable)  0x28198207 in pthread_mutexattr_init () from
/usr/lib/libpthread.so.1
I can also attach traceback if it can help.

Does it means that something wrong with libpthread?

----------------------------------------------------------------------

Comment By: Gabriel Genellina (gagenellina)
Date: 2007-05-16 18:30

Message:
Logged In: YES 
user_id=479790
Originator: NO

No problem either on Windows with 2.4.3 and 2.5 (2.5.1 untested)


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1720241&group_id=5470


More information about the Python-bugs-list mailing list