Python faulthandler._sigsegv() Examples
The following are 21
code examples of faulthandler._sigsegv().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
faulthandler
, or try the search function
.
Example #1
Source File: _test_process_executor.py From loky with BSD 3-Clause "New" or "Revised" License | 5 votes |
def _wait_and_crash(cls): _executor_mixin._test_event.wait() faulthandler._sigsegv()
Example #2
Source File: test_concurrent_futures.py From android_universal with MIT License | 5 votes |
def _crash(delay=None): """Induces a segfault.""" if delay: time.sleep(delay) import faulthandler faulthandler.disable() faulthandler._sigsegv()
Example #3
Source File: test_faulthandler.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def test_disable(self): code = """ import faulthandler faulthandler.enable() faulthandler.disable() faulthandler._sigsegv() """ not_expected = 'Fatal Python error' stderr, exitcode = self.get_output(code) stderr = '\n'.join(stderr) self.assertTrue(not_expected not in stderr, "%r is present in %r" % (not_expected, stderr)) self.assertNotEqual(exitcode, 0)
Example #4
Source File: test_faulthandler.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def test_enable_single_thread(self): self.check_fatal_error(""" import faulthandler faulthandler.enable(all_threads=False) faulthandler._sigsegv() """, 3, 'Segmentation fault', all_threads=False)
Example #5
Source File: test_faulthandler.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def test_enable_file(self): with temporary_filename() as filename: self.check_fatal_error(""" import faulthandler output = open({filename}, 'wb') faulthandler.enable(output) faulthandler._sigsegv() """.format(filename=repr(filename)), 4, 'Segmentation fault', filename=filename)
Example #6
Source File: test_faulthandler.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def test_gil_released(self): self.check_fatal_error(""" import faulthandler faulthandler.enable() faulthandler._sigsegv(True) """, 3, 'Segmentation fault')
Example #7
Source File: test_faulthandler.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def test_sigsegv(self): self.check_fatal_error(""" import faulthandler faulthandler.enable() faulthandler._sigsegv() """, 3, 'Segmentation fault')
Example #8
Source File: test_subprocess.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def test_child_terminated_in_stopped_state(self): """Test wait() behavior when waitpid returns WIFSTOPPED; issue29335.""" PTRACE_TRACEME = 0 # From glibc and MacOS (PT_TRACE_ME). libc_name = ctypes.util.find_library('c') libc = ctypes.CDLL(libc_name) if not hasattr(libc, 'ptrace'): raise unittest.SkipTest('ptrace() required') code = textwrap.dedent(""" import ctypes import faulthandler from test.support import SuppressCrashReport libc = ctypes.CDLL({libc_name!r}) libc.ptrace({PTRACE_TRACEME}, 0, 0) """.format(libc_name=libc_name, PTRACE_TRACEME=PTRACE_TRACEME)) child = subprocess.Popen([sys.executable, '-c', code]) if child.wait() != 0: raise unittest.SkipTest('ptrace() failed - unable to test') code += textwrap.dedent(""" with SuppressCrashReport(): # Crash the process faulthandler._sigsegv() """) child = subprocess.Popen([sys.executable, '-c', code]) try: returncode = child.wait() except: child.kill() # Clean up the hung stopped process. raise self.assertNotEqual(0, returncode) self.assertLess(returncode, 0) # signal death, likely SIGSEGV.
Example #9
Source File: test_regrtest.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def test_crashed(self): # Any code which causes a crash code = 'import faulthandler; faulthandler._sigsegv()' crash_test = self.create_test(name="crash", code=code) ok_test = self.create_test(name="ok") tests = [crash_test, ok_test] output = self.run_tests("-j2", *tests, exitcode=2) self.check_executed_tests(output, tests, failed=crash_test, randomize=True)
Example #10
Source File: test_reusable_executor.py From loky with BSD 3-Clause "New" or "Revised" License | 5 votes |
def crash(): """Induces a segfault""" import faulthandler faulthandler._sigsegv()
Example #11
Source File: test_faulthandler.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def test_sigsegv(self): self.check_fatal_error(""" import faulthandler faulthandler.enable() faulthandler._sigsegv() """, 3, 'Segmentation fault')
Example #12
Source File: test_faulthandler.py From ironpython3 with Apache License 2.0 | 5 votes |
def test_disable(self): code = """ import faulthandler faulthandler.enable() faulthandler.disable() faulthandler._sigsegv() """ not_expected = 'Fatal Python error' stderr, exitcode = self.get_output(code) stderr = '\n'.join(stderr) self.assertTrue(not_expected not in stderr, "%r is present in %r" % (not_expected, stderr)) self.assertNotEqual(exitcode, 0)
Example #13
Source File: test_faulthandler.py From ironpython3 with Apache License 2.0 | 5 votes |
def test_enable_single_thread(self): self.check_fatal_error(""" import faulthandler faulthandler.enable(all_threads=False) faulthandler._sigsegv() """, 3, 'Segmentation fault', all_threads=False)
Example #14
Source File: test_faulthandler.py From ironpython3 with Apache License 2.0 | 5 votes |
def test_enable_file(self): with temporary_filename() as filename: self.check_fatal_error(""" import faulthandler output = open({filename}, 'wb') faulthandler.enable(output) faulthandler._sigsegv() """.format(filename=repr(filename)), 4, 'Segmentation fault', filename=filename)
Example #15
Source File: test_faulthandler.py From ironpython3 with Apache License 2.0 | 5 votes |
def test_gil_released(self): self.check_fatal_error(""" import faulthandler faulthandler.enable() faulthandler._sigsegv(True) """, 3, 'Segmentation fault')
Example #16
Source File: test_faulthandler.py From ironpython3 with Apache License 2.0 | 5 votes |
def test_sigsegv(self): self.check_fatal_error(""" import faulthandler faulthandler.enable() faulthandler._sigsegv() """, 3, 'Segmentation fault')
Example #17
Source File: test_faulthandler.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def test_enable_single_thread(self): self.check_fatal_error(""" import faulthandler faulthandler.enable(all_threads=False) faulthandler._sigsegv() """, 3, 'Segmentation fault', all_threads=False)
Example #18
Source File: test_faulthandler.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def test_enable_fd(self): with tempfile.TemporaryFile('wb+') as fp: fd = fp.fileno() self.check_fatal_error(""" import faulthandler import sys faulthandler.enable(%s) faulthandler._sigsegv() """ % fd, 4, 'Segmentation fault', fd=fd)
Example #19
Source File: test_faulthandler.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def test_enable_file(self): with temporary_filename() as filename: self.check_fatal_error(""" import faulthandler output = open({filename}, 'wb') faulthandler.enable(output) faulthandler._sigsegv() """.format(filename=repr(filename)), 4, 'Segmentation fault', filename=filename)
Example #20
Source File: test_faulthandler.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def test_gil_released(self): self.check_fatal_error(""" import faulthandler faulthandler.enable() faulthandler._sigsegv(True) """, 3, 'Segmentation fault')
Example #21
Source File: app_test_helper.py From abseil-py with Apache License 2.0 | 4 votes |
def real_main(argv): """The main function.""" if os.environ.get('APP_TEST_PRINT_ARGV', False): sys.stdout.write('argv: {}\n'.format(' '.join(argv))) if FLAGS.raise_exception: raise MyException if FLAGS.raise_usage_error: if FLAGS.usage_error_exitcode is not None: raise app.UsageError('Error!', FLAGS.usage_error_exitcode) else: raise app.UsageError('Error!') if FLAGS.faulthandler_sigsegv: faulthandler._sigsegv() # pylint: disable=protected-access sys.exit(1) # Should not reach here. if FLAGS.print_init_callbacks: app.call_after_init(lambda: _callback_results.append('during real_main')) for value in _callback_results: print('callback: {}'.format(value)) sys.exit(0) # Ensure that we have a random C++ flag in flags.FLAGS; this shows # us that app.run() did the right thing in conjunction with C++ flags. helper_type = os.environ['APP_TEST_HELPER_TYPE'] if helper_type == 'clif': if 'heap_check_before_constructors' in flags.FLAGS: print('PASS: C++ flag present and helper_type is {}'.format(helper_type)) sys.exit(0) else: print('FAILED: C++ flag absent but helper_type is {}'.format(helper_type)) sys.exit(1) elif helper_type == 'pure_python': if 'heap_check_before_constructors' in flags.FLAGS: print('FAILED: C++ flag present but helper_type is pure_python') sys.exit(1) else: print('PASS: C++ flag absent and helper_type is pure_python') sys.exit(0) else: print('Unexpected helper_type "{}"'.format(helper_type)) sys.exit(1)