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

Add UBSAN build option and fix building using it #1172

Merged
merged 5 commits into from
Oct 16, 2024
Merged

Conversation

vadz
Copy link
Member

@vadz vadz commented Oct 16, 2024

No description provided.

Even though this didn't any harm in practice, it's still undefined
behaviour and should be avoided.
vadz added 4 commits October 16, 2024 17:11
This ensures that they are initialized, which previously wasn't the
case, e.g. gotData_ wasn't initialized in the default ctor and
poolPosition_ wasn't initialized at all.

This didn't seem to result in any real problems, but triggered UBSAN
reports when copying "bool gotData_" values which didn't have a valid
value for bool type.
Export all backend classes as they can be used in the application code,
and some of them were actually used in our own tests (and, also, some of
them had been already exported, even though most were not, so exporting
all of them is also more consistent).

Also export ref_counted_prepare_info and ref_counted_statement classes
to make their type info information accessible from outside the library:
this is needed at least when UBSAN and, more precisely, its vtbl
sanitizer, is used, as it uses typeinfo.

Closes SOCI#1103.
Allow to easily enable UBSAN.

Don't bother to test for the compiler versions, assume that when someone
enables it, they have compiler support for it.
UBSAN gives nonsensical errors for the ODBC job running under Ubuntu
18.04, e.g. it complains that

src/core/session.cpp:246:16: runtime error: member call on address
0x607000000250 which does not point to an object of type
'session_backend'
1: 0x607000000250: note: object is of type 'soci::odbc_session_backend'

which doesn't make any sense because odbc_session_backend is an object
of type session_backend. But apparently something is broken in this
compiler version, so disable UBSAN for this job for now.
@vadz vadz merged commit 2ce816b into SOCI:master Oct 16, 2024
15 of 16 checks passed
@vadz vadz deleted the add-ubsan branch October 16, 2024 15:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant