Skip to content

Fix GH-10908: Bus error with PDO Firebird on RPI with 64 bit kernel and 32 bit userland #10920

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

Closed
wants to merge 8 commits into from

Conversation

nielsdos
Copy link
Member

@nielsdos nielsdos commented Mar 23, 2023

The alignment of sqldata is in most cases only the basic alignment, so the code type-puns it to a larger type, it can crash due to the misaligned access. This is only an issue for types > 4 bytes because every sensible system requires an alignment of at least 4 bytes for allocated data.

Even though this patch uses memcpy, the compiler is smart enough to optimise it to something more efficient, especially on x86. This is just the usual approach to solve these alignment problems.

Actually, unaligned memory access is undefined behaviour, so even on x86 platforms, where the bug doesn't cause a crash, this can be problematic. Furthermore, even though the issue talks about a 64-bit kernel and 32-bit userspace, this doesn't necessarily need to be the case to trigger this crash.

Test was Co-authored-by: rvk01

…l and 32 bit userland

The alignment of sqldata is in most cases only the basic alignment,
so the code type-puns it to a larger type, it *can* crash due to the
misaligned access. This is only an issue for types > 4 bytes because
every sensible system requires an alignment of at least 4 bytes for
allocated data.

Even though this patch uses memcpy, the compiler is smart enough to
optimise it to something more efficient, especially on x86.
This is just the usual approach to solve these alignment problems.

Actually, unaligned memory access is undefined behaviour, so even on x86
platforms, where the bug doesn't cause a crash, this can be problematic.
Furthermore, even though the issue talks about a 64-bit kernel and
32-bit userspace, this doesn't necessarily need to be the case to
trigger this crash.

Test was Co-authored-by: rvk01
@nielsdos nielsdos changed the title Fix GH-10908: Bus error with PDO Firebird on RPI with 64 bit kernel a… Fix GH-10908: Bus error with PDO Firebird on RPI with 64 bit kernel and 32 bit userland Mar 23, 2023
@nielsdos
Copy link
Member Author

I've checked this again and I think I got everything now. Issue reporter is running the patch on their production system right now and so far no issues.

Copy link
Member

@Girgias Girgias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could the test try and use every single SQL Type that we currently support?

@nielsdos
Copy link
Member Author

Extended the test to test all our supported types.

Copy link
Member

@Girgias Girgias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bus error with PDO Firebird on RPI with 64 bit kernel and 32 bit userland
2 participants