-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
Python 3.13.0a6 freethreading on s390x: test.test_io.CBufferedReaderTest.test_constructor
crash with Floating point exception
#117755
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
Comments
test.test_io.CBufferedReaderTest.test_constructor
ends with Fatal Python error: Floating point exception
test.test_io.CBufferedReaderTest.test_constructor
ends with Fatal Python error: Floating point exception
on s390x
test.test_io.CBufferedReaderTest.test_constructor
ends with Fatal Python error: Floating point exception
on s390xtest.test_io.CBufferedReaderTest.test_constructor
ends with Fatal Python error: Floating point exception
on s390x with freethreading
The test allocates 9 223 372 036 854 775 807 bytes (0x7fffffffffffffff) and mimalloc fails with a division by zero on s390x.
The root issue is a division by zero in mimalloc when requested memory is huge: 0x7fffffffffffffff bytes. It can be reproduced on s390x without test_io:
|
I can reproduce the issue with a Python built with:
I disable all compiler optimizations ( gdb logs when the bug occurs:
|
PyObject_Malloc():
mi_segment_huge_page_alloc() is called with size=0x8000000000000000:
The problem is that static mi_page_t* mi_segment_span_allocate(mi_segment_t* segment, size_t slice_index, size_t slice_count, mi_segments_tld_t* tld) {
...
slice->slice_count = (uint32_t)slice_count;
...
return page;
} gdb:
|
Fix mimalloc allocator for huge memory allocation (around 8,589,934,592 GiB) on s390x. * Abort allocation early in mimalloc if the number of slices doesn't fit into uint32_t, to prevent a integer overflow (cast 64-bit size_t to uint32_t). * Add test_large_alloc() to test_bigaddrspace. * Reenable test_maxcontext_exact_arith() of test_decimal on s390x.
On x86-64, we don't reach this bug, since mmap() fails before. strace on the big mmap() call:
On x86-64, gdb traces around mmap():
|
test.test_io.CBufferedReaderTest.test_constructor
ends with Fatal Python error: Floating point exception
on s390x with freethreadingtest.test_io.CBufferedReaderTest.test_constructor
crash with Floating point exception
on s390x
test.test_io.CBufferedReaderTest.test_constructor
crash with Floating point exception
on s390xtest.test_io.CBufferedReaderTest.test_constructor
crash with Floating point exception
One thing I'm curious about: even with overcommit, I think that Why does it succeed on s390x? Is mmap able to use much bigger pages on IBM Z? Something else? |
Sorry, I have no idea 🤷🏻♂️ |
The test allocates 9 223 372 036 854 775 807 bytes (0x7fffffffffffffff) and mimalloc fails with a division by zero on s390x.
Fix mimalloc allocator for huge memory allocation (around 8,589,934,592 GiB) on s390x. * Abort allocation early in mimalloc if the number of slices doesn't fit into uint32_t, to prevent a integer overflow (cast 64-bit size_t to uint32_t). * Add test_large_alloc() to test_bigaddrspace (test skipped on 32-bit platforms). * Reenable test_maxcontext_exact_arith() of test_decimal on s390x. * Reenable test_constructor() tests of test_io on s390x.
Remove unreliable tests on huge memory allocations: * Remove test_maxcontext_exact_arith() of test_decimal. Stefan Krah, test author, agreed on removing the test: python#114331 (comment) * Remove test_constructor() tests of test_io. Sam Gross suggests remove them: python#117809 (review) On Linux, depending how overcommit is configured, especially on Linux s390x, a huge memory allocation (half or more of the full address space) can succeed, but then the process will eat the full system swap and make the system slower and slower until the whole system becomes unusable. Moreover, these tests had to be skipped when Python is built with sanitizers.
Remove unreliable tests on huge memory allocations: * Remove test_maxcontext_exact_arith() of test_decimal. Stefan Krah, test author, agreed on removing the test: #114331 (comment) * Remove test_constructor() tests of test_io. Sam Gross suggests remove them: #117809 (review) On Linux, depending how overcommit is configured, especially on Linux s390x, a huge memory allocation (half or more of the full address space) can succeed, but then the process will eat the full system swap and make the system slower and slower until the whole system becomes unusable. Moreover, these tests had to be skipped when Python is built with sanitizers.
Fix mimalloc allocator for huge memory allocation (around 8,589,934,592 GiB) on s390x. Abort allocation early in mimalloc if the number of slices doesn't fit into uint32_t, to prevent a integer overflow (cast 64-bit size_t to uint32_t).
Remove unreliable tests on huge memory allocations: * Remove test_maxcontext_exact_arith() of test_decimal. Stefan Krah, test author, agreed on removing the test: python#114331 (comment) * Remove test_constructor() tests of test_io. Sam Gross suggests remove them: python#117809 (review) On Linux, depending how overcommit is configured, especially on Linux s390x, a huge memory allocation (half or more of the full address space) can succeed, but then the process will eat the full system swap and make the system slower and slower until the whole system becomes unusable. Moreover, these tests had to be skipped when Python is built with sanitizers.
…7809) Fix mimalloc allocator for huge memory allocation (around 8,589,934,592 GiB) on s390x. Abort allocation early in mimalloc if the number of slices doesn't fit into uint32_t, to prevent a integer overflow (cast 64-bit size_t to uint32_t).
Bug report
Bug description:
Since #114331 was solved, we once again attempted to build Python with freethreading on s390x Fedora Linux.
test.test_io.CBufferedReaderTest.test_constructor
fails. The traceback:Is this freethreading related? I don't know. Hoping to raise visibility and pointers as where the issue comes from. cc @vstinner
CPython versions tested on:
3.13
Operating systems tested on:
Linux
Linked PRs
The text was updated successfully, but these errors were encountered: