-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
MDEV-37502 Make Server Debug + Clang compile ready #4145
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these blocking releases?
Because I would rather not publish temporary kludges if we can focus on proper solutions.
While I wonder why there exists -Wframe-larger-than
only to shackle so many places, I’m equally curious about how those places manage to exhaust all 16KiB of the allowance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding Groonga, I heard that Mroonga is looking to address issues as part of #4185, including your comment on the stack size, #3864 (comment).
Let’s tune in on their progress first and ask if they’ll support 10.11.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR hasn’t had any activity for just over a month. Do we know what’s up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 weeks on mroonga/mroonga#900 so I pinged. Thanks.
Marko closed MDEV-34388 two months ago. You may prefer to track these follow-ups on a split issue. |
d46fa58
to
a3f7d90
Compare
client/mysql.cc
Outdated
warning: passing an object that undergoes default argument promotion | ||
to 'va_start' has undefined behavior [-Wvarargs] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is new since my last review, right?
I don’t get how this warning could arise.
Can you paste me the full message?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UBSAN makes sure the functions match in args.
SUMMARY: UndefinedBehaviorSanitizer: function-type-mismatch /source/libmariadb/libmariadb/mariadb_lib.c:2723:17
--- /source/mysql-test/main/mysqlbinlog.result 2025-07-31 08:07:44.470657901 +0000
+++ /build/mysql-test/var/5/log/mysqlbinlog.reject 2025-09-01 01:40:41.565758662 +0000
@@ -904,6 +904,50 @@
DROP TABLE t1;
DROP DATABASE test1;
FLUSH LOGS;
+/source/libmariadb/libmariadb/mariadb_lib.c:2628:3: runtime error: call to function status_info_cb(void*, enum_mariadb_status_info, enum_session_state_type, st_ma_const_string*) through pointer to incorrect function type 'void (*)(void *, enum enum_mariadb_status_info, ...)'
+/source/client/mysql.cc:3204: note: status_info_cb(void*, enum_mariadb_status_info, enum_session_state_type, st_ma_const_string*) defined here
+ #0 0x5585a84e8211 in ma_read_ok_packet /source/libmariadb/libmariadb/mariadb_lib.c:2628:3
+ #1 0x5585a857f920 in run_plugin_auth /source/libmariadb/plugins/auth/my_auth.c:744:12
+ #2 0x5585a84de81b in mthd_my_real_connect /source/libmariadb/libmariadb/mariadb_lib.c:1982:7
+ #3 0x5585a84da759 in mysql_real_connect /source/libmariadb/libmariadb/mariadb_lib.c:1555:10
+ #4 0x5585a84b4c93 in do_connect(st_mysql*, char const*, char const*, char const*, char const*, unsigned long) /source/client/mysql.cc:1521:10
+ #5 0x5585a849eb1a in sql_real_connect(char*, char*, char*, char*, unsigned int) /source/client/mysql.cc:5017:8
+ #6 0x5585a849eb1a in sql_connect(char*, char*, char*, char*, unsigned int) /source/client/mysql.cc:5074:16
+ #7 0x5585a849da79 in main /source/client/mysql.cc:1304:7
+ #8 0x7f9db31fc249 (/lib/x86_64-linux-gnu/libc.so.6+0x27249) (BuildId: 79005c16293efa45b441fed45f4f29b138557e9e)
+ #9 0x7f9db31fc304 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x27304) (BuildId: 79005c16293efa45b441fed45f4f29b138557e9e)
+ #10 0x5585a83b2f80 in _start (/build/client/mariadb+0x1b2f80) (BuildId: b015c96ff77d7c9ddf4f3547b595f7bdd9eb9a30)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, why don’t we change this static
function to variadic to match the struct member?
static void status_info_cb(void *data, enum enum_mariadb_status_info type, ...)
{
enum enum_session_state_type state_type;
[[maybe_unused]] MARIADB_CONST_STRING *val;
va_list args;
va_start(args, fmt);
state_type= va_arg(args, int); // enum is promoted to 'int' when passed through '...'
if (…)
{
val= va_arg(args, MARIADB_CONST_STRING *);
…
}
va_end(args);
}
Alternatively, it looks like Connector/C only calls the function passed to MARIADB_OPT_STATUS_CALLBACK
with specific argument types, which means st_mysql_options_extension::status_callback
doesn’t need to be variadic.
Though switching to non-variadic would impact user projects that were passing variadic callbacks already. Bug fixes should not have API changes, after all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It used to 3e43606 - a variadic is a compile warning on undefined behaviour.
The same C/C callback is called in a few ways:
mariadb-corporation/mariadb-connector-c@a8832af
But yes, too late to change API with undefined behaviour.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Googling a bit…
Looks like this -Wvarargs
problem comes from preceding the varargs with an enum parameter.
See this example and its explanation: mamh-mixed/glusterfs@11ea746
It means the API itself is problematic, and there aren’t really “user projects with correct signatures” because the “correct” signature is stuck with UB.
The best a caller could do is to write int
instead of enum enum_mariadb_status_info
with fingers crossed.
We should inform the Connector/C team.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ParadoxV5 I'm happy to revert 3e43606 and apply a disable of the warning varargs
around this block too as an alternate to this.
In the just deployed amd64-ubasan-clang-20 its causing the test failures to hit the 30 limit rather quickly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While we wait for Con/C to solve this, yap, let’s do that instead, as it is one layer of kludge thinner.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ack, have done this now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR hasn’t had any activity for just over a month. Do we know what’s up?
a3f7d90
to
89a38dd
Compare
# Workaround Win8.1 SDK bug, that breaks /permissive- | ||
string(REPLACE "/permissive-" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") | ||
else() | ||
set_source_files_properties(${ROCKSDB_SOURCE_DIR}/options/db_options.cc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dr-m @vlad-lesin on the assumption that the two warnings in the commit message are what was seen, I pushed the warning down to just these two files. I didn't use CHECK_CXX_COMPILER_FLAG
because like many of the other things in the build_rocksdb.cmake
file that assumed clang or gcc (because of the other flags used).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a couple of commas to your GitHub comment here?
Update: The comment has been updated inline.
21ea528
to
8238122
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not know what happened to the codebase that led to these issues.
But I acknowledge your patch, including parts that are currently “waiting for the dependency to update”.
# Workaround Win8.1 SDK bug, that breaks /permissive- | ||
string(REPLACE "/permissive-" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") | ||
else() | ||
set_source_files_properties(${ROCKSDB_SOURCE_DIR}/options/db_options.cc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a couple of commas to your GitHub comment here?
Update: The comment has been updated inline.
This is frequently violated within the mroonga implementatation and therefore should not error. Reviewer: Jimmy Hu <jimmy.hu@mariadb.com>
Stack limits exceeded for clang-20 +Debug + MSAN. Added disables for the following functions. storage/mroonga/vendor/groonga/lib/ii.c:303:1: error: stack frame size (16696) exceeds limit (16384) in 'buffer_segment_reserve' [-Werror,-Wframe-larger-than] 303 | buffer_segment_reserve(grn_ctx *ctx, grn_ii *ii, | ^ storage/mroonga/vendor/groonga/lib/ii.c:4803:1: error: stack frame size (20936) exceeds limit (16384) in 'grn_ii_delete_one' [-Werror,-Wframe-larger-than] 4803 | grn_ii_delete_one(grn_ctx *ctx, grn_ii *ii, grn_id tid, grn_ii_updspec *u, grn_hash *h) | ^ storage/mroonga/vendor/groonga/lib/ii.c:6313:1: error: stack frame size (25736) exceeds limit (16384) in 'grn_ii_column_update' [-Werror,-Wframe-larger-than] 6313 | grn_ii_column_update(grn_ctx *ctx, grn_ii *ii, grn_id rid, unsigned int section, | ^ For non-Debug the following stack frame sizes wher exceeded: storage/mroonga/vendor/groonga/lib/proc/proc_select.c:3575:1: warning: stack frame size (94072) exceeds limit (49152) in 'command_select' [-Wframe-larger-than] 3575 | command_select(grn_ctx *ctx, int nargs, grn_obj **args, grn_user_data *user_data) | ^ storage/mroonga/vendor/groonga/lib/proc/proc_schema.c:1134:1: warning: stack frame size (98360) exceeds limit (49152) in 'command_schema_output_tables' [-Wframe-larger-than] 1134 | command_schema_output_tables(grn_ctx *ctx, grn_schema_data *data) Reviewer: Jimmy Hu <jimmy.hu@mariadb.com>
…lags sign-compare Under Debug build this becomes a Werror. Resolved this by changing the grn_mecab_chunk_size_threshold to a ptrdiff_t along with chunked_tokenize_utf8's string_bytes argument so there is no need to case. Reviewer: Jimmy Hu <jimmy.hu@mariadb.com>
Follow up to MDEV-34388 82d7419 Relax limit on specific files only. clang-20 + CMAKE_BUILD_TYPE=Debug: options/cf_options.cc:0:0: stack frame size (17624) exceeds limit (16384) in function '__cxx_global_var_init.33' options/db_options.cc:0:0: stack frame size (34328) exceeds limit (32768) in function '__cxx_global_var_init.45' Reviewer: Jimmy Hu <jimmy.hu@mariadb.com>
…formation (fix)" This reverts commit 3e43606. This caused Clang-18+ UBSAN errors: SUMMARY: UndefinedBehaviorSanitizer: function-type-mismatch libmariadb/libmariadb/mariadb_lib.c:2723:17 +/libmariadb/libmariadb/mariadb_lib.c:2628:3: runtime error: call to function status_info_cb(void*, enum_mariadb_status_info, enum_session_state_type, st_ma_const_string*) through pointer to incorrect function type 'void (*)(void *, enum enum_mariadb_status_info, ...)' +/client/mysql.cc:3204: note: status_info_cb(void*, enum_mariadb_status_info, enum_session_state_type, st_ma_const_string*) defined here Reviewer: Jimmy Hu <jimmy.hu@mariadb.com>
Clang complains that the callback is using a variadic based on an enum. client/mysql.cc:3207:16: error: passing an object that undergoes default argument promotion to 'va_start' has undefined behavior [-Werror,-Wvarargs] 3207 | va_start(ap, type); This is part of the C/C API this has been referred as bug: * CONC-789 MARIADB_OPT_STATUS_CALLBACK Variadic around enums is undefined behaviour In the mean time, we are just disabling the warning. Reviewer: Jimmy Hu <jimmy.hu@mariadb.com>
8238122
to
c7f2de5
Compare
Description
Clang under a debug build triggered a few too many -Werror conditions on stack.
The code on mroonga is kept be ready for its update #3864 where these directives aren’t' necessary.
https://github.com/MariaDB/server/pull/3961/files#diff-8adababce2dec657ca89490f1922da7d4d0ec4db824261594114d9542bc575cc
Didn't seem to hit this in 10.11 so this patch is omitted.
Release Notes
nothing - compile/debug only.
How can this PR be tested?
Compile with clang and
-DCMAKE_BUILD_TYPE=Debug
Basing the PR against the correct MariaDB version
main
branch.PR quality check