This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Compiler is not thread safe?
Type: Stage:
Components: Interpreter Core Versions: Python 2.5
process
Status: closed Resolution: works for me
Dependencies: Superseder:
Assigned To: Nosy List: dfavor, georg.brandl, ggenellina, loewis, rhettinger, zpcz
Priority: normal Keywords:

Created on 2007-05-16 19:38 by zpcz, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (7)
msg32020 - (view) Author: ‹‹PC›› (zpcz) Date: 2007-05-16 19:38
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)
msg32021 - (view) Author: Gabriel Genellina (ggenellina) Date: 2007-05-16 23:30
No problem either on Windows with 2.4.3 and 2.5 (2.5.1 untested)
msg32022 - (view) Author: ‹‹PC›› (zpcz) Date: 2007-05-17 15:59
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?
msg32023 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2007-05-18 06:52
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.
msg32024 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2007-05-18 09:37
> 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.
msg32025 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2007-05-18 23:14
FWIW, I cannot get the OP's script to fail on Py2.5.1 on either Windows XP or on Gentoo Linux.
msg32026 - (view) Author: David Favor (dfavor) Date: 2007-06-02 14:53
This works on Fedora 6 and Python 2.5.1
History
Date User Action Args
2022-04-11 14:56:24adminsetgithub: 44959
2007-05-16 19:38:54zpczcreate