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

Fix[bmqa_message.h]: Enable message d_groupId field regardless of build #433

Closed
wants to merge 1 commit into from

Conversation

pniedzielski
Copy link
Collaborator

Issue number of the reported bug or feature request: #426

Describe your changes
We currently do some cleverness with where and when we enable the incomplete message group ID feature in CMakeLists.txt. However, when using the build-darwin.sh and build-ubuntu.sh scripts, as we currently recommend, the libraries we install using make install have this feature enabled.

Unfortunately, enabling message group IDs changes the size of bmqa_message’s MessageImpl, so a library built with message group IDs enabled is ABI-incompatible with an application built with message group IDs disabled. Because we don’t advertise this feature anywhere or export the definition from CMake, users are unlikely to know they need to compile with the flag -DBMQ_ENABLE_MSG_GROUPID, and will run into characteristic ABI-incompatibility issues: buffer overruns, stack clobbering, and segmentation faults.

This patch makes a minimal change until we decide what to do with message group IDs: the API is still sensitive to BMQ_ENABLE_MSG_GROUPID, but the message structure itself always carries a d_groupId field, regardless of its presence. This field is default-initialized and is otherwise unused.

Testing performed
This change fixes the minimal example given in #426. I will let the CI run all the tests to ensure no breakage.

@pniedzielski pniedzielski added bug Something isn't working A-Client Area: C++ SDK labels Oct 1, 2024
@pniedzielski pniedzielski requested a review from a team as a code owner October 1, 2024 21:32
@pniedzielski pniedzielski force-pushed the groupid-abi-fix branch 2 times, most recently from 095d820 to 6512d02 Compare October 1, 2024 21:34
We currently do some cleverness with where and when we enable the
incomplete message group ID feature in `CMakeLists.txt`.  However, when
using the `build-darwin.sh` and `build-ubuntu.sh` scripts, as we
currently recommend, the libraries we install using `make install` have
this feature enabled.

Unfortunately, enabling message group IDs changes the size of
`bmqa_message`’s `MessageImpl`, so a library built with message group
IDs enabled is ABI-incompatible with an application built with message
group IDs disabled.  Because we don’t advertise this feature anywhere or
export the definition from CMake, users are unlikely to know they need
to compile with the flag `-DBMQ_ENABLE_MSG_GROUPID`, and will run into
characteristic ABI-incompatibility issues: buffer overruns, stack
clobbering, and segmentation faults.

This patch makes a minimal change until we decide what to do with
message group IDs: the API is still sensitive to
`BMQ_ENABLE_MSG_GROUPID`, but the message structure itself always
carries a `d_groupId` field, regardless of its presence.  This field is
default-initialized and is otherwise unused.

Signed-off-by: Patrick M. Niedzielski <[email protected]>
@pniedzielski
Copy link
Collaborator Author

We should probably also fix our build system.

Copy link

@bmq-oss-ci bmq-oss-ci bot left a comment

Choose a reason for hiding this comment

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

Build 285 of commit da89632 has completed with FAILURE

@pniedzielski
Copy link
Collaborator Author

Closed in favor of #437.

@pniedzielski pniedzielski deleted the groupid-abi-fix branch January 8, 2025 18:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Client Area: C++ SDK bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants