Skip to content

gh-132097: skip tests raising an explicit SIGSEV when UB sanitizer is on #132398

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 12, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 19 additions & 15 deletions Lib/test/test_concurrent_futures/test_deadlock.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,8 @@ def _fail_on_deadlock(self, executor):
print(f"\nTraceback:\n {tb}", file=sys.__stderr__)
self.fail(f"Executor deadlock:\n\n{tb}")


def _check_crash(self, error, func, *args, ignore_stderr=False):
# test for deadlock caused by crashes in a pool
def _check_error(self, error, func, *args, ignore_stderr=False):
# test for deadlock caused by crashes or exiting in a pool
self.executor.shutdown(wait=True)

executor = self.executor_type(
Expand All @@ -138,65 +137,69 @@ def _check_crash(self, error, func, *args, ignore_stderr=False):
def test_error_at_task_pickle(self):
# Check problem occurring while pickling a task in
# the task_handler thread
self._check_crash(PicklingError, id, ErrorAtPickle())
self._check_error(PicklingError, id, ErrorAtPickle())

def test_exit_at_task_unpickle(self):
# Check problem occurring while unpickling a task on workers
self._check_crash(BrokenProcessPool, id, ExitAtUnpickle())
self._check_error(BrokenProcessPool, id, ExitAtUnpickle())

def test_error_at_task_unpickle(self):
# gh-109832: Restore stderr overridden by _raise_error_ignore_stderr()
self.addCleanup(setattr, sys, 'stderr', sys.stderr)

# Check problem occurring while unpickling a task on workers
self._check_crash(BrokenProcessPool, id, ErrorAtUnpickle())
self._check_error(BrokenProcessPool, id, ErrorAtUnpickle())

@support.skip_if_sanitizer("UBSan: explicit SIGSEV not allowed", ub=True)
def test_crash_at_task_unpickle(self):
# Check problem occurring while unpickling a task on workers
self._check_crash(BrokenProcessPool, id, CrashAtUnpickle())
self._check_error(BrokenProcessPool, id, CrashAtUnpickle())

@support.skip_if_sanitizer("UBSan: explicit SIGSEV not allowed", ub=True)
def test_crash_during_func_exec_on_worker(self):
# Check problem occurring during func execution on workers
self._check_crash(BrokenProcessPool, _crash)
self._check_error(BrokenProcessPool, _crash)

def test_exit_during_func_exec_on_worker(self):
# Check problem occurring during func execution on workers
self._check_crash(SystemExit, _exit)
self._check_error(SystemExit, _exit)

def test_error_during_func_exec_on_worker(self):
# Check problem occurring during func execution on workers
self._check_crash(RuntimeError, _raise_error, RuntimeError)
self._check_error(RuntimeError, _raise_error, RuntimeError)

@support.skip_if_sanitizer("UBSan: explicit SIGSEV not allowed", ub=True)
def test_crash_during_result_pickle_on_worker(self):
# Check problem occurring while pickling a task result
# on workers
self._check_crash(BrokenProcessPool, _return_instance, CrashAtPickle)
self._check_error(BrokenProcessPool, _return_instance, CrashAtPickle)

def test_exit_during_result_pickle_on_worker(self):
# Check problem occurring while pickling a task result
# on workers
self._check_crash(SystemExit, _return_instance, ExitAtPickle)
self._check_error(SystemExit, _return_instance, ExitAtPickle)

def test_error_during_result_pickle_on_worker(self):
# Check problem occurring while pickling a task result
# on workers
self._check_crash(PicklingError, _return_instance, ErrorAtPickle)
self._check_error(PicklingError, _return_instance, ErrorAtPickle)

def test_error_during_result_unpickle_in_result_handler(self):
# gh-109832: Restore stderr overridden by _raise_error_ignore_stderr()
self.addCleanup(setattr, sys, 'stderr', sys.stderr)

# Check problem occurring while unpickling a task in
# the result_handler thread
self._check_crash(BrokenProcessPool,
self._check_error(BrokenProcessPool,
_return_instance, ErrorAtUnpickle,
ignore_stderr=True)

def test_exit_during_result_unpickle_in_result_handler(self):
# Check problem occurring while unpickling a task in
# the result_handler thread
self._check_crash(BrokenProcessPool, _return_instance, ExitAtUnpickle)
self._check_error(BrokenProcessPool, _return_instance, ExitAtUnpickle)

@support.skip_if_sanitizer("UBSan: explicit SIGSEV not allowed", ub=True)
def test_shutdown_deadlock(self):
# Test that the pool calling shutdown do not cause deadlock
# if a worker fails after the shutdown call.
Expand Down Expand Up @@ -235,6 +238,7 @@ def test_shutdown_deadlock_pickle(self):
# dangling threads
executor_manager.join()

@support.skip_if_sanitizer("UBSan: explicit SIGSEV not allowed", ub=True)
def test_crash_big_data(self):
# Test that there is a clean exception instead of a deadlock when a
# child process crashes while some data is being written into the
Expand Down
Loading