Issue2205

classification
Title: Some imp methods do not acquire module import lock, causing race conditions
Type: Severity: major
Components: Core Versions: Jython 2.7
Milestone:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: zyasoft Nosy List: acharis, zyasoft
Priority: urgent Keywords:

Created on 2014-09-09.18:51:47 by acharis, last changed 2014-12-30.15:51:00 by zyasoft.

Files
File name Uploaded Description Edit Remove
start_threads acharis, 2014-09-09.18:51:46
Messages
msg8982 (view) Author: Alex Charis (acharis) Date: 2014-09-09.18:51:46
THREADS=8 jython start_threads

With various values for this environment variable you will see various behaviours.
With low enough values, this results in no error. (The script has no output upon successful completion.)

Sometimes:

[acharis@workstation ~]% THREADS=8 /tmp/jython2.7b3/jython start_threads
Exception in thread Thread-5:Traceback (most recent call last):
  File "/tmp/jython2.7b3/Lib/threading.py", line 207, in _Thread__bootstrap
    self.run()
  File "start_threads", line 11, in run
    os.system("cat /etc/hostname > /dev/null")
  File "/tmp/jython2.7b3/Lib/subprocess.py", line 500, in call
    return Popen(*popenargs, **kwargs).wait()
  File "/tmp/jython2.7b3/Lib/subprocess.py", line 830, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/tmp/jython2.7b3/Lib/subprocess.py", line 1315, in _execute_child
    args = _shell_command + args
TypeError: unsupported operand type(s) for +: 'NoneType' and 'list'

Other times:

AttributeError: 'module' object has no attribute 'call'

Other times: 

NameError: global name 'Popen' is not defined
msg8987 (view) Author: Jim Baker (zyasoft) Date: 2014-09-10.04:14:05
So this due to a race on the module import lock in org.python.core.imp; currently only importName acquires it, but the posix module uses (implicitly) import_first, via load.

The workaround until this is fixed is to import subprocess before any threading is performed.
msg8988 (view) Author: Jim Baker (zyasoft) Date: 2014-09-10.04:14:17
Target beta 4
msg9182 (view) Author: Jim Baker (zyasoft) Date: 2014-10-29.00:13:37
Must fix
msg9247 (view) Author: Jim Baker (zyasoft) Date: 2014-12-18.05:34:03
Fixed as of https://hg.python.org/jython/rev/0ee9d9d530ba
History
Date User Action Args
2014-12-30 15:51:00zyasoftsetstatus: pending -> closed
2014-12-18 05:34:03zyasoftsetstatus: open -> pending
resolution: remind -> fixed
messages: + msg9247
2014-10-29 00:13:37zyasoftsetpriority: high -> urgent
messages: + msg9182
2014-09-24 01:38:21zyasoftsettitle: various errors when subprocess called by several threads -> Some imp methods do not acquire module import lock, causing race conditions
2014-09-24 01:37:33zyasoftsetresolution: accepted -> remind
2014-09-10 04:14:17zyasoftsetpriority: high
messages: + msg8988
2014-09-10 04:14:05zyasoftsetassignee: zyasoft
resolution: accepted
messages: + msg8987
nosy: + zyasoft
2014-09-09 18:51:47achariscreate