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

archive: fix TOC entry alignment in PKG/CArchive #7571

Merged
merged 1 commit into from
Apr 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions PyInstaller/archive/writers.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,14 +277,16 @@ def _serialize_toc(cls, toc):
name = name.encode('utf-8')
name_length = len(name) + 1 # add 1 for a '\0'

# Align to 16-byte boundary so xplatform C can read
# Ensure TOC entries are aligned on 16-byte boundary, so they can be read by bootloader (C code) on
# platforms with strict data alignment requirements (for example linux on `armhf`/`armv7`, such as 32-bit
# Debian Buster on Raspberry Pi).
entry_length = cls._TOC_ENTRY_LENGTH + name_length
if entry_length % 16 == 0:
name_padding = b'\0'
else:
padding_length = 16 - (entry_length % 16)
name_padding = b'\0' * padding_length
name_length += padding_length
name_length += padding_length

# Serialize
serialized_entry = struct.pack(
Expand Down
5 changes: 5 additions & 0 deletions news/7566.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Fix regression on platforms with strict data alignment requirements
(such as linux on `armhf`/`armv7`), caused by bug in PKG/CArchive
generation that was introduced during the archive writer code cleanup.
The regression caused executable to terminate with ``Bus error`` on
the affected platforms, such as 32-bit Debian Buster on Raspberry Pi 4.