Details
-
Task
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
Sprint 7 (07.04.2025), Sprint 8 (21.04.2025), Sprint 9 (05.05.2025)
Description
There are a number of compiler defines that marks variables as 'will not be used uninitialized'.
This is to around issues with compilers that wrongly conclude that a variable will be used uninitialized.
The macros that makes this possible are LINT_INIT and UNINIT_VAR for example.
With modern static analysers and the current usage, these are very shallow path to determine the initialisation did happen. They however still do mistakes.
While we want to have optimal code, we still want to be able to catch uninitialised values usage in the code.
The UNINIT_VAR(x) x= x construct was causing UBSAN issues like:
sql/sql_view.cc:1299:8: runtime error: load of value 16, which is not a valid value for type 'bool'
|
However vallgrind and other memory checkers does not have this issue.
When compling with UBSAN we should use the -DWITH_UBSAN option, like we do in the BUILD scripts.
The fix for this would be to change:
#if defined(__GNUC__)
|
/* GCC specific self-initialization which inhibits the warning. */
|
#define UNINIT_VAR(x) x= x
|
#elif defined(_lint) || defined(FORCE_INIT_OF_VARS)
|
#define UNINIT_VAR(x) x= 0
|
#else
|
#define UNINIT_VAR(x) x
|
#endif
|
|
to
|
|
#if defined(__GNUC__) && !defined(WITH_UBSAN)
|
/* GCC specific self-initialization which inhibits the warning. */
|
#define UNINIT_VAR(x) x= x
|
#elif defined(FORCE_INIT_OF_VARS)
|
#define UNINIT_VAR(x) x= 0
|
#else
|
#define UNINIT_VAR(x) x
|
#endif
|
(I removed _lint as this is not used anymore)
Attachments
Issue Links
- blocks
-
MDBF-741 Remove the gcc UBSAN builder to use the clang based UBSAN
-
- Stalled
-
-
MDBF-1076 create MSAN Debug builder
-
- Open
-
- is duplicated by
-
MDEV-35589 UBSAN: runtime error: load of value 21/58, which is not a valid value for type 'bool' in extract_date_time
-
- Closed
-
- relates to
-
CONC-775 UNINIT_VAR macro - disable for clang
-
- Closed
-
-
MDEV-35589 UBSAN: runtime error: load of value 21/58, which is not a valid value for type 'bool' in extract_date_time
-
- Closed
-
-
MDEV-35590 UBSAN: runtime error: load of value 43, which is not a valid value for type 'bool' on I_S SELECT
-
- Open
-