karas84 · GitHub

Crash report

What happened?

Tested on the latest ubuntu:25.04 docker image.

from ctypes import Structure
class MyStructure(Structure):
    _align_ = 0
    _fields_ = []

Crashes with Floating point exception on CPython 3.13.

I'm attaching both gdb core dump and backtrace: dump.zip

Problem seems caused by _ctypes/stgdict.c:573:
aligned_size = ((size + total_align - 1) / total_align) * total_align;

Also tested on CPython 3.14, which doesn't segfaults but exits on an assert in ctypes/_layout.py:19:
assert multiple > 0

called by ctypes/_layout.py:314:
aligned_size = round_up(total_size, align)

CPython versions tested on:

3.13

Operating systems tested on:

Linux

Output from running 'python -VV' on the command line:

Python 3.13.3 (main, Apr 8 2025, 19:55:40) [GCC 14.2.0]

Linked PRs

Read the original on github.com ↗