Skip to content
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

test_capi crash and produce core dumps on FreeBSD 13 #106714

Closed
vstinner opened this issue Jul 13, 2023 · 3 comments
Closed

test_capi crash and produce core dumps on FreeBSD 13 #106714

vstinner opened this issue Jul 13, 2023 · 3 comments
Labels
type-bug An unexpected behavior, bug, or error

Comments

@vstinner
Copy link
Member

vstinner commented Jul 13, 2023

Examples:

[vstinner@freebsd ~/python/main]$ ./python -m test test_capi -m test_no_FatalError_infinite_loop -v
...
Warning -- files was modified by test_capi
Warning --   Before: []
Warning --   After:  ['python.core'] 

and

[vstinner@freebsd ~/python/main]$ ./python -m test -v test_capi -m test_get_set_optimizer 
...
test_get_set_optimizer (test.test_capi.test_misc.TestOptimizerAPI.test_get_set_optimizer) ... Fatal Python error: Segmentation fault

Current thread 0x0000000827265000 (most recent call first):
  File "/usr/home/vstinner/python/main/Lib/unittest/case.py", line 589 in _callTestMethod
  File "/usr/home/vstinner/python/main/Lib/unittest/case.py", line 634 in run
  File "/usr/home/vstinner/python/main/Lib/unittest/case.py", line 690 in __call__
  File "/usr/home/vstinner/python/main/Lib/unittest/suite.py", line 122 in run
  • FreeBSD 13.2-RELEASE-p1
  • clang 14.0.5
  • Python configured with: ./configure --cache-file=../config.cache --with-pydebug CFLAGS="-O0"

Linked PRs

@vstinner vstinner added the type-bug An unexpected behavior, bug, or error label Jul 13, 2023
@vstinner
Copy link
Member Author

Oh, AArch64 Fedora Rawhide buildbot has the same failure: it also produces a coredump.

This issue affects operating systems configured to write a coredump in the current directory if a process does crash. Example on the AArch64 Fedora Rawhide machine:

$ cat /proc/sys/kernel/core_pattern 
[vstinner@python-builder-fedora-rawhide-aarch64 ~]$ file /proc/sys/kernel/core_pattern 
/proc/sys/kernel/core_pattern: empty
[vstinner@python-builder-fedora-rawhide-aarch64 test]$ cat /proc/sys/kernel/core_uses_pid 
1

[vstinner@python-builder-fedora-rawhide-aarch64 test]$ ulimit -c
unlimited

[vstinner@python-builder-fedora-rawhide-aarch64 ~]$ mkdir test
[vstinner@python-builder-fedora-rawhide-aarch64 ~]$ cd test
[vstinner@python-builder-fedora-rawhide-aarch64 test]$ python
Python 3.11.3 (main, Apr  5 2023, 00:00:00) [GCC 13.0.1 20230404 (Red Hat 13.0.1-0)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ctypes
>>> ctypes.string_at(0)
Segmentation fault (core dumped)

[vstinner@python-builder-fedora-rawhide-aarch64 test]$ ls -la
(...)
-rw-------.  1 vstinner vstinner 9465856 Jul 22 13:45 .2755244

A core dump named .2755244 was created in the current directory.

vstinner added a commit to vstinner/cpython that referenced this issue Jul 22, 2023
test_capi: Fix test_no_FatalError_infinite_loop() to no longer write
a coredump, by using test.support.SuppressCrashReport.
vstinner added a commit that referenced this issue Jul 22, 2023
test_capi: Fix test_no_FatalError_infinite_loop() to no longer write
a coredump, by using test.support.SuppressCrashReport.
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jul 22, 2023
test_capi: Fix test_no_FatalError_infinite_loop() to no longer write
a coredump, by using test.support.SuppressCrashReport.
(cherry picked from commit 4a1026d)

Co-authored-by: Victor Stinner <vstinner@python.org>
@vstinner
Copy link
Member Author

Oh, this bug is a recent regression introduced by #102729

@vstinner
Copy link
Member Author

Python 3.11 is not affected:

    @support.requires_subprocess()
    def test_no_FatalError_infinite_loop(self):
        with support.SuppressCrashReport():
            p = subprocess.Popen([sys.executable, "-c",
                                  'import _testcapi;'
                                  '_testcapi.crash_no_current_thread()'],
                                 stdout=subprocess.PIPE,
                                 stderr=subprocess.PIPE)
        (out, err) = p.communicate()

vstinner added a commit that referenced this issue Jul 22, 2023
…107009)

gh-106714: Fix test_capi to not write a coredump (GH-107007)

test_capi: Fix test_no_FatalError_infinite_loop() to no longer write
a coredump, by using test.support.SuppressCrashReport.
(cherry picked from commit 4a1026d)

Co-authored-by: Victor Stinner <vstinner@python.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant