Skip to content

Aborting emcc with Ctrl-C often hangs the terminal #8013

Closed

Description

@juj

There is some kind of odd issue going on with python tests/runner.py at least when python 2 is being used (haven't tried running with python 3, if it also has the issue)

Tapping Ctrl-C to abort the test runner often locks up python, and if hangs infinitely somewhere inside the multiprocessing pool, and does not return out back to prompt. One has to open a second prompt, and run

pkill -9 python

on macOS/Linux, or

taskkill -f -im python.exe

on Windows

to get back out to the console.

When one presses Ctrl-C, on macOS at least the following wall of texts is spammed out

test_mmap (test_core.asm0) ... FAIL
^CProcess PoolWorker-3:
Process PoolWorker-4:
Traceback (most recent call last):
Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
tests/runner.py:WARNING: KeyboardInterrupt
Process PoolWorker-2:
Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
Process PoolWorker-1:
Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
    self.run()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/process.py", line 114, in run
    self._target(*self._args, **self._kwargs)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/pool.py", line 102, in worker
    self.run()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/process.py", line 114, in run
    self._target(*self._args, **self._kwargs)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/pool.py", line 102, in worker
    task = get()
  File "/System/Library/Frameworks/Python.framework    self.run()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/process.py", line 114, in run
    self._target(*self._args, **self._kwargs)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/pool.py", line 102, in worker
    task = get()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/queues.py", line 376, in get
    racquire()
KeyboardInterrupt
Process PoolWorker-2:4:
Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
    self.run()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/process.py", line 114, in run
    self._target(*self._args, **self._kwargs)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/pool.py", line 102, in worker
Process PoolWorker-2:3:
Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
    task = get()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/queues.py", line 376, in get
    racquire()
KeyboardInterrupt
    self.run()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/process.py", line 114, in run
    self._target(*self._args, **self._kwargs)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/pool.py", line 102, in worker
    task = get()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/queues.py", line 378, in get
    return recv()
KeyboardInterrupt
Process PoolWorker-2:2:
Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
Process PoolWorker-2:1:
    self.run()
Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/process.py", line 114, in run
    self._target(*self._args, **self._kwargs)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/pool.py", line 102, in worker
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
    task = get()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/queues.py", line 376, in get
    self.run()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/process.py", line 114, in run
    self._target(*self._args, **self._kwargs)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/pool.py", line 102, in worker
    racquire()
KeyboardInterrupt
    task = get()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/queues.py", line 376, in get
    racquire()
KeyboardInterrupt
/Versions/2.7/lib/python2.7/multiprocessing/queues.py", line 376, in get
    task = get()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/queues.py", line 376, in get
    racquire()
KeyboardInterrupt
Process PoolWorker-4:
    racquire()
Traceback (most recent call last):
KeyboardInterrupt
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
    self.run()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/process.py", line 114, in run
    self._target(*self._args, **self._kwargs)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/pool.py", line 102, in worker
Process PoolWorker-2:
Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
    task = get()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/queues.py", line 376, in get
    racquire()
KeyboardInterrupt
Process PoolWorker-3:
Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
Process PoolWorker-1:
Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
    self.run()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/process.py", line 114, in run
    self._target(*self._args, **self._kwargs)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/pool.py", line 102, in worker
    self.run()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/process.py", line 114, in run
    self._target(*self._args, **self._kwargs)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/pool.py", line 102, in worker
    task = get()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/queues.py", line 376, in get
    racquire()
KeyboardInterrupt
emcc:WARNING: KeyboardInterrupt
    task = get()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/queues.py", line 376, in get
Process PoolWorker-3:4:
Traceback (most recent call last):
Process Process-4:
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
Traceback (most recent call last):
    racquire()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
KeyboardInterrupt
    self.run()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/process.py", line 114, in run
    self.run()
    self._target(*self._args, **self._kwargs)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/process.py", line 114, in run
  File "/Users/clb/emsdk/emscripten/incoming/tests/parallel_runner.py", line 28, in g_testing_thread
    self._target(*self._args, **self._kwargs)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/pool.py", line 102, in worker
    test(result)
  File "/System/Library/Frameworks/Python.f    task = get()
ramework/Versions/2.7/lib/python2.7/unittest/case.py", line 395, in __call__
Process PoolWorker-3:3:
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/queues.py", line 376, in get
Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
    racquire()
KeyboardInterrupt
    return self.run(*args, **kwds)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/case.py", line 331, in run
    self.run()
    testMethod()
  File "/Users/clb/emsdk/emscripten/incoming/tests/test_core.py", line 7181, in test_minmax
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/process.py", line 114, in run
    self._target(*self._args, **self._kwargs)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/pool.py", line 102, in worker
Process PoolWorker-3:1:
Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
    task = get()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/queues.py", line 376, in get
    self.run()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/process.py", line 114, in run
    self._target(*self._args, **self._kwargs)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/pool.py", line 102, in worker
    racquire()
KeyboardInterrupt
Process PoolWorker-3:2:
    task = get()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/queues.py", line 378, in get
Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
    self.run()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/process.py", line 114, in run
    self.run()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/process.py", line 114, in run
    self._target(*self._args, **self._kwargs)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/pool.py", line 102, in worker
    self._target(*self._args, **self._kwargs)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/pool.py", line 102, in worker
    self.run()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/process.py", line 114, in run
    self._target(*self._args, **self._kwargs)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/pool.py", line 102, in worker
    task = get()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/queues.py", line 378, in get
Process Process-1:
    return recv()
Traceback (most recent call last):
    self.do_run(open(path_from_root('tests', 'test_minmax.c')).read(), 'NAN != NAN\nSuccess!')
KeyboardInterrupt
  File "/Users/clb/emsdk/emscripten/incoming/tests/runner.py", line 952, in do_run
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
    return recv()
KeyboardInterrupt
    self.run()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/process.py", line 114, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/clb/emsdk/emscripten/incoming/tests/parallel_runner.py", line 28, in g_testing_thread
    test(result)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/case.py", line 395, in __call__
    build_ll_hook=build_ll_hook, post_build=post_build)
  File "/Users/clb/emsdk    return self.run(*args, **kwds)
/emscripten/incoming/tests/runner.py", line 543, in build
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/case.py", line 331, in run
    task = get()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/queues.py", line 378, in get
    run_process(args, stderr=self.stderr_redirect if not DEBUG else None)
    testMethod()
  File "/Users/clb/emsdk/emscripten/incoming/tools/shared.py", line 167, in run_process
  File "/Users/clb/emsdk/emscripten/incoming/tests/runner.py", line 129, in decorated
    return recv()
KeyboardInterrupt
    return func(self, *args, **kwargs)
  File "/Users/clb/emsdk/emscripten/incoming/tests/test_core.py", line 5667, in test_the_bullet
    stdout, stderr = proc.communicate(input)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 796, in communicate
    task = get()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/queues.py", line 376, in get
    self.wait()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1384, in wait
    pid, sts = _eintr_retry_call(os.waitpid, self.pid, 0)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 476, in _eintr_retry_call
    return func(*args)
    racquire()
KeyboardInterrupt
KeyboardInterrupt
    test()
  File "/Users/clb/emsdk/emscripten/incoming/tests/test_core.py", line 5665, in test
    libraries=get_bullet_library(self, use_cmake),
  File "/Users/clb/emsdk/emscripten/incoming/tests/runner.py", line 1367, in get_bullet_library
    cache_name_extra=configure_commands[0])
  File "/Users/clb/emsdk/emscripten/incoming/tests/runner.py", line 745, in get_library
    copy_project=True, env_init=env_init, native=native)
  File "/Users/clb/emsdk/emscripten/incoming/tools/shared.py", line 1784, in build_library
    Building.make(make + make_args, stdout=stdout, stderr=stderr, env=env)
  File "/Users/clb/emsdk/emscripten/incoming/tools/shared.py", line 1694, in make
    res = run_process(args, stdout=stdout, stderr=stderr, env=env, shell=WINDOWS, check=False)
  File "/Users/clb/emsdk/emscripten/incoming/tools/shared.py", line 167, in run_process
    stdout, stderr = proc.communicate(input)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 796, in communicate
emcc:WARNING: KeyboardInterrupt
    self.wait()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1384, in wait
    pid, sts = _eintr_retry_call(os.waitpid, self.pid, 0)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 476, in _eintr_retry_call
    return func(*args)
KeyboardInterrupt
Process Process-2:
Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
    self.run()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/process.py", line 114, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/clb/emsdk/emscripten/incoming/tests/parallel_runner.py", line 28, in g_testing_thread
    test(result)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/case.py", line 395, in __call__
    return self.run(*args, **kwds)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/case.py", line 331, in run
    testMethod()
  File "/Users/clb/emsdk/emscripten/incoming/tests/runner.py", line 129, in decorated
    return func(self, *args, **kwargs)
  File "/Users/clb/emsdk/emscripten/incoming/tests/test_core.py", line 5738, in test_openjpeg
    make_args=[]) # no -j 2, since parallel builds can fail
  File "/Users/clb/emsdk/emscripten/incoming/tests/runner.py", line 745, in get_library
    copy_project=True, env_init=env_init, native=native)
  File "/Users/clb/emsdk/emscripten/incoming/tools/shared.py", line 1784, in build_library
    Building.make(make + make_args, stdout=stdout, stderr=stderr, env=env)
  File "/Users/clb/emsdk/emscripten/incoming/tools/shared.py", line 1694, in make
    res = run_process(args, stdout=stdout, stderr=stderr, env=env, shell=WINDOWS, check=False)
  File "/Users/clb/emsdk/emscripten/incoming/tools/shared.py", line 167, in run_process
    stdout, stderr = proc.communicate(input)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 796, in communicate
    self.wait()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1384, in wait
    pid, sts = _eintr_retry_call(os.waitpid, self.pid, 0)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 476, in _eintr_retry_call
    return func(*args)
KeyboardInterrupt
Process Process-3:

Haven't had time to figure out if this is a python bug or something in our use of multiprocessing, but I just tend to do the pkill/taskkill workaround to avoid having to looking into this..

This affects both regular emcc compilation, but also the test runner.

Activity

  1. changed the title [-]Aborting emcc with Ctrl-C often hangs up the terminal[/-] [+]Aborting emcc with Ctrl-C often hangs the terminal[/+] on Feb 6, 2019
  2. kripken commented on Feb 6, 2019

    @kripken
    Member

    I think we fixed this in the test runner with something like

      except KeyboardInterrupt:
        logger.warning('KeyboardInterrupt')
        sys.exit(1)
    

    Which perhaps we should wrap around other main()s as well.

  3. stale commented on Feb 6, 2020

    @stale

    This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 7 days. Feel free to re-open at any time if this issue is still relevant.

  4. kripken commented on Feb 14, 2020

    @kripken
    Member

    This is still worth verifying.

  5. juj commented on Feb 14, 2020

    @juj
    CollaboratorAuthor

    I do still regularly see this, and resort to running taskkill /f /im python.exe on Windows (kill all python.exe processes). Just yesterday migrated to python 3 as per Sam's pull requests, so interesting to see if the same thing still reproduced on python 3.

  6. sbc100 commented on Feb 14, 2020

    @sbc100
    Collaborator

    I don't get lockups... but I do often see that seeming infinite list of backtracks (Worse to more cores you have). I would love to get to the bottom of that.

    I also sometimes find many zombie emscriten process on my system which I assume is due to this issue. Luckily I think its only effect two siturations:

    1. Running the test suite (which most users don't do)
    2. Running parallel builds of system libraries (which happens only once per installation).
  7. juj commented on Feb 14, 2020

    @juj
    CollaboratorAuthor

    Actually in our unity build system we do have rather nasty python watchdog code in place that looks out for python processes leaking after a build, or build hanging with sub processes alive. Both scenarios do occur for us in normal execution, i.e. no ctrl-c taking place.

  8. juj commented on Feb 14, 2020

    @juj
    CollaboratorAuthor

    It seems that whenever such a hang occurs, emcc has already completed whatever it was doing, so it is as if the hang happens in atexit or something like that

  9. sbc100 commented on Feb 14, 2020

    @sbc100
    Collaborator

    Is this across OSes or just one OS in particular? I'm also curious to see if python3 makes any difference.

  10. pfaffe commented on Jul 31, 2020

    @pfaffe
    Collaborator

    I just ran into this again on linux with python 3.8. I believe the cause lies in the interplay of waiting for subprocesses and signals. I vaguely remember an issue where the child process dies upon SIGINT but the parent process is left hanging.

  11. sbc100 commented on Jul 31, 2020

    @sbc100
    Collaborator

    Did you happen to notice if this happened when emcc was doing parallel tasks in the background such as building libc? Or does it happen with a warm cache too?

  12. pfaffe commented on Jul 31, 2020

    @pfaffe
    Collaborator

    This one happend when I ctrl-C'ed a single long-running task, final linking of a large application.

  13. stale commented on Jul 31, 2021

    @stale

    This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 30 days. Feel free to re-open at any time if this issue is still relevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions