-
Notifications
You must be signed in to change notification settings - Fork 99
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
c: error: allocation of insufficient size with GCC 14 #2424
Comments
$ c++ --version
c++ (Debian 14.2.0-8) 14.2.0
Copyright (C) 2024 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
This works but ignoring diff --git a/c/validation/adbc_validation_statement.cc b/c/validation/adbc_validation_statement.cc
index cd388623b..e47f183d4 100644
--- a/c/validation/adbc_validation_statement.cc
+++ b/c/validation/adbc_validation_statement.cc
@@ -2817,8 +2817,9 @@ struct ADBC_EXPORT AdbcError100 {
// Test that an ADBC 1.0.0-sized error still works
void StatementTest::TestErrorCompatibility() {
static_assert(sizeof(AdbcError100) == ADBC_ERROR_1_0_0_SIZE, "Wrong size");
+ auto error_buffer = malloc(ADBC_ERROR_1_0_0_SIZE);
// XXX: sketchy cast
- auto* error = reinterpret_cast<struct AdbcError*>(malloc(ADBC_ERROR_1_0_0_SIZE));
+ auto* error = reinterpret_cast<struct AdbcError*>(error_buffer);
std::memset(error, 0, ADBC_ERROR_1_0_0_SIZE);
ASSERT_THAT(AdbcStatementNew(&connection, &statement, error), IsOkStatus(error));
@@ -2831,7 +2832,7 @@ void StatementTest::TestErrorCompatibility() {
::testing::Not(IsOkStatus(error)));
auto* old_error = reinterpret_cast<AdbcError100*>(error);
old_error->release(old_error);
- free(error);
+ free(error_buffer);
}
void StatementTest::TestResultInvalidation() { |
Hmm, that's intentional to test the binary compatibility, but it is indeed sketchy and GCC is right to warn about it... |
We should also set up a job with new GCC (and I should backport the nanoarrow patch so that the current job using new Clang can pass) |
FWIW that line has caused me to have to turn of UBSAN/ASAN for my local build for quite some time (since Apple clang aborts that test at runtime if compiled with the default CMakeUserPresets.json). |
Maybe I can change it to allocate the full struct and just check that the new fields were not touched? |
Ah, it's a good idea. |
- Backport nanoarrow patch to satisfy newer Clang - Add test using GCC 15 - Update tests using sketchy casts to satisfy these compilers - Refactor the clang/gcc Docker jobs Fixes apache#2424.
What feature or improvement would you like to see?
The text was updated successfully, but these errors were encountered: