Bug #116372 ODR violation reported by AddressSanitizer for plugin variables
Submitted: 16 Oct 11:47 Modified: 17 Oct 12:16
Reporter: Laurynas Biveinis (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Storage Engine API Severity:S3 (Non-critical)
Version:8.0.40, 8.4.3, 9.1.0 OS:MacOS (15.0.1)
Assigned to: CPU Architecture:ARM

[16 Oct 11:47] Laurynas Biveinis
Description:
./mtr main.disabled_storage_engines
...
mysqltest: At line 127: Query 'INSTALL PLUGIN example SONAME '$EXAMPLE_PLUGIN'' failed.
ERROR 2013 (HY000): Lost connection to MySQL server during query
...
2024-10-16T11:45:20.787737Z 8 [Note] [MY-010733] [Server] Shutting down plugin 'EXAMPLE'
=================================================================
==93375==ERROR: AddressSanitizer: odr-violation (0x0001363e1a20):
  [1] size=8 'example_hton' /Users/laurynas/vilniusdb/mysql-8.0.40/storage/example/ha_example.cc
  [2] size=8 'example_hton' /Users/laurynas/vilniusdb/mysql-8.0.40/storage/example/ha_example.cc
These globals were registered at these points:
  [1]:
    #0 0x11ed756a0 in __asan_register_globals+0x9c (libclang_rt.asan_osx_dynamic.dylib:arm64e+0x156a0)
    #1 0x11edb3124 in __asan::AsanApplyToGlobals(void (*)(__asan_global*, unsigned long), void const*)+0x70 (libclang_rt.asan_osx_dynamic.dylib:arm64e+0x53124)
    #2 0x11ed755ec in __asan_register_image_globals+0x3c (libclang_rt.asan_osx_dynamic.dylib:arm64e+0x155ec)
    #3 0x1363d1bcc in asan.module_ctor+0x18 (ha_example.so:arm64+0xdbcc)
    #4 0x18f4a7b84 in invocation function for block in dyld4::Loader::findAndRunAllInitializers(dyld4::RuntimeState&) const+0x24c (dyld:arm64e+0xfffffffffff57b84)
    #5 0x18f4e63b8  (<unknown module>)
    #6 0x18f4d9b20  (<unknown module>)
    #7 0x18f48c2d8  (<unknown module>)
    #8 0x18f4d8ab4  (<unknown module>)
    #9 0x18f4e5ecc  (<unknown module>)
    #10 0x18f4a78a8 in dyld4::Loader::findAndRunAllInitializers(dyld4::RuntimeState&) const+0xac (dyld:arm64e+0xfffffffffff578a8)
    #11 0x18f4aee84  (<unknown module>)
    #12 0x18f4a7f64 in dyld4::Loader::runInitializersBottomUp(dyld4::RuntimeState&, dyld3::Array<dyld4::Loader const*>&, dyld3::Array<dyld4::Loader const*>&) const+0x134 (dyld:arm64e+0xfffffffffff57f64)
    #13 0x18f4ac254  (<unknown module>)
    #14 0x18f4a8154 in dyld4::Loader::runInitializersBottomUpPlusUpwardLinks(dyld4::RuntimeState&) const+0x198 (dyld:arm64e+0xfffffffffff58154)
    #15 0x18f4c0484  (<unknown module>)
    #16 0x11eda0d28 in dlopen+0x108 (libclang_rt.asan_osx_dynamic.dylib:arm64e+0x40d28)
    #17 0x104b659b8 in plugin_dl_add(MYSQL_LEX_STRING const*, int, bool) sql_plugin.cc:687
    #18 0x104b640b0 in plugin_add(MEM_ROOT*, MYSQL_LEX_CSTRING, MYSQL_LEX_STRING const*, int*, char**, int, bool) sql_plugin.cc:1047
    #19 0x104b516dc in mysql_install_plugin(THD*, MYSQL_LEX_CSTRING, MYSQL_LEX_STRING const*) sql_plugin.cc:2358
    #20 0x104b509f8 in Sql_cmd_install_plugin::execute(THD*) sql_plugin.cc:3689
    #21 0x104a7973c in mysql_execute_command(THD*, bool) sql_parse.cc:4722
    #22 0x104a6d4cc in dispatch_sql_command(THD*, Parser_state*) sql_parse.cc:5371
    #23 0x104a581d4 in dispatch_command(THD*, COM_DATA const*, enum_server_command) sql_parse.cc:2055
    #24 0x104a6555c in do_command(THD*) sql_parse.cc:1440
    #25 0x105376408 in handle_connection(void*) connection_handler_per_thread.cc:303
    #26 0x109b97bcc in pfs_spawn_thread(void*) pfs.cc:3050
    #27 0x11edb1858 in asan_thread_start(void*)+0x40 (libclang_rt.asan_osx_dynamic.dylib:arm64e+0x51858)
    #28 0x18f8132e0 in _pthread_start+0x84 (libsystem_pthread.dylib:arm64e+0x72e0)
    #29 0x18f80e0f8 in thread_start+0x4 (libsystem_pthread.dylib:arm64e+0x20f8)

  [2]:
    #0 0x11ed756a0 in __asan_register_globals+0x9c (libclang_rt.asan_osx_dynamic.dylib:arm64e+0x156a0)
    #1 0x11edb3124 in __asan::AsanApplyToGlobals(void (*)(__asan_global*, unsigned long), void const*)+0x70 (libclang_rt.asan_osx_dynamic.dylib:arm64e+0x53124)
    #2 0x11ed755ec in __asan_register_image_globals+0x3c (libclang_rt.asan_osx_dynamic.dylib:arm64e+0x155ec)
    #3 0x1363d1bcc in asan.module_ctor+0x18 (ha_example.so:arm64+0xdbcc)
    #4 0x18f4a7b84 in invocation function for block in dyld4::Loader::findAndRunAllInitializers(dyld4::RuntimeState&) const+0x24c (dyld:arm64e+0xfffffffffff57b84)
    #5 0x18f4e63b8  (<unknown module>)
    #6 0x18f4d9b20  (<unknown module>)
    #7 0x18f48c2d8  (<unknown module>)
    #8 0x18f4d8ab4  (<unknown module>)
    #9 0x18f4e5ecc  (<unknown module>)
    #10 0x18f4a78a8 in dyld4::Loader::findAndRunAllInitializers(dyld4::RuntimeState&) const+0xac (dyld:arm64e+0xfffffffffff578a8)
    #11 0x18f4aee84  (<unknown module>)
    #12 0x18f4a7f64 in dyld4::Loader::runInitializersBottomUp(dyld4::RuntimeState&, dyld3::Array<dyld4::Loader const*>&, dyld3::Array<dyld4::Loader const*>&) const+0x134 (dyld:arm64e+0xfffffffffff57f64)
    #13 0x18f4ac254  (<unknown module>)
    #14 0x18f4a8154 in dyld4::Loader::runInitializersBottomUpPlusUpwardLinks(dyld4::RuntimeState&) const+0x198 (dyld:arm64e+0xfffffffffff58154)
    #15 0x18f4c0484  (<unknown module>)
    #16 0x11eda0d28 in dlopen+0x108 (libclang_rt.asan_osx_dynamic.dylib:arm64e+0x40d28)
    #17 0x104b659b8 in plugin_dl_add(MYSQL_LEX_STRING const*, int, bool) sql_plugin.cc:687
    #18 0x104b640b0 in plugin_add(MEM_ROOT*, MYSQL_LEX_CSTRING, MYSQL_LEX_STRING const*, int*, char**, int, bool) sql_plugin.cc:1047
    #19 0x104b516dc in mysql_install_plugin(THD*, MYSQL_LEX_CSTRING, MYSQL_LEX_STRING const*) sql_plugin.cc:2358
    #20 0x104b509f8 in Sql_cmd_install_plugin::execute(THD*) sql_plugin.cc:3689
    #21 0x104a7973c in mysql_execute_command(THD*, bool) sql_parse.cc:4722
    #22 0x104a6d4cc in dispatch_sql_command(THD*, Parser_state*) sql_parse.cc:5371
    #23 0x104a581d4 in dispatch_command(THD*, COM_DATA const*, enum_server_command) sql_parse.cc:2055
    #24 0x104a6555c in do_command(THD*) sql_parse.cc:1440
    #25 0x105376408 in handle_connection(void*) connection_handler_per_thread.cc:303
    #26 0x109b97bcc in pfs_spawn_thread(void*) pfs.cc:3050
    #27 0x11edb1858 in asan_thread_start(void*)+0x40 (libclang_rt.asan_osx_dynamic.dylib:arm64e+0x51858)
    #28 0x18f8132e0 in _pthread_start+0x84 (libsystem_pthread.dylib:arm64e+0x72e0)
    #29 0x18f80e0f8 in thread_start+0x4 (libsystem_pthread.dylib:arm64e+0x20f8)

==93375==HINT: if you don't care about these errors you may set ASAN_OPTIONS=detect_odr_violation=0
SUMMARY: AddressSanitizer: odr-violation: global 'example_hton' at /Users/laurynas/vilniusdb/mysql-8.0.40/storage/example/ha_example.cc
Thread T48 created by T0 here:
    #0 0x11edac1c8 in pthread_create+0x5c (libclang_rt.asan_osx_dynamic.dylib:arm64e+0x4c1c8)
    #1 0x109b97540 in pfs_spawn_thread_vc(unsigned int, unsigned int, my_thread_handle*, _opaque_pthread_attr_t const*, void* (*)(void*), void*) pfs.cc:3096
    #2 0x105375bd8 in Per_thread_connection_handler::add_connection(Channel_info*) connection_handler_per_thread.cc:415
    #3 0x102f8c124 in Connection_handler_manager::process_new_connection(Channel_info*) connection_handler_manager.cc:263
    #4 0x103f74010 in Connection_acceptor<Mysqld_socket_listener>::connection_event_loop() connection_acceptor.h:66
    #5 0x103f61618 in mysqld_main(int, char**) mysqld.cc:8286
    #6 0x18f490270  (<unknown module>)

==93375==ABORTING

How to repeat:
XCode 16
-DFORCE_UNSUPPORTED_COMPILER=ON -DCMAKE_BUILD_TYPE=Debug -DWITH_DEBUG=ON
-DMYSQL_MAINTAINER_MODE=ON -DWITH_SYSTEM_LIBS=ON
-DWITH_NDBCLUSTER_STORAGE_ENGINE=OFF -DDOWNLOAD_BOOST=ON
-DWITH_BOOST=<path> -DFORCE_COLORED_OUTPUT=ON -DCMAKE_CXX_FLAGS=-g
-DCMAKE_CXX_FLAGS_DEBUG=-g -DCMAKE_CXX_FLAGS_RELEASE=-O2 -DNDEBUG -g
-DWITH_ASAN=ON -DWITH_ASAN_SCOPE=ON -DWITH_UBSAN=ON
[16 Oct 11:49] Laurynas Biveinis
Same on main.plugin
[16 Oct 11:50] Laurynas Biveinis
Same on perfschema.show_plugin
[16 Oct 11:53] Laurynas Biveinis
Different variable and different plugin. Using the same bug, I guess it's not the variable itself what is at fault here.

./mtr auth_sec.keyring_udf
...
[ 50%] auth_sec.keyring_udf                      [ fail ]
...
mysqltest: At line 34: Query 'INSTALL PLUGIN keyring_udf SONAME '$KEYRING_UDF'' failed.
ERROR 2013 (HY000): Lost connection to MySQL server during query
...
==93877==ERROR: AddressSanitizer: odr-violation (0x000134570000):
  [1] size=4 'keyring_udf_decriptor' /Users/laurynas/vilniusdb/mysql-8.0.40/plugin/keyring_udf/keyring_udf.cc
  [2] size=4 'keyring_udf_decriptor' /Users/laurynas/vilniusdb/mysql-8.0.40/plugin/keyring_udf/keyring_udf.cc
These globals were registered at these points:
  [1]:
    #0 0x11e9496a0 in __asan_register_globals+0x9c (libclang_rt.asan_osx_dynamic.dylib:arm64e+0x156a0)
    #1 0x11e987124 in __asan::AsanApplyToGlobals(void (*)(__asan_global*, unsigned long), void const*)+0x70 (libclang_rt.asan_osx_dynamic.dylib:arm64e+0x53124)
    #2 0x11e9495ec in __asan_register_image_globals+0x3c (libclang_rt.asan_osx_dynamic.dylib:arm64e+0x155ec)
    #3 0x1345678d4 in asan.module_ctor+0x18 (keyring_udf.so:arm64+0xb8d4)
    #4 0x18f4a7b84 in invocation function for block in dyld4::Loader::findAndRunAllInitializers(dyld4::RuntimeState&) const+0x24c (dyld:arm64e+0xfffffffffff57b84)
    #5 0x18f4e63b8  (<unknown module>)
    #6 0x18f4d9b20  (<unknown module>)
    #7 0x18f48c2d8  (<unknown module>)
    #8 0x18f4d8ab4  (<unknown module>)
    #9 0x18f4e5ecc  (<unknown module>)
    #10 0x18f4a78a8 in dyld4::Loader::findAndRunAllInitializers(dyld4::RuntimeState&) const+0xac (dyld:arm64e+0xfffffffffff578a8)
    #11 0x18f4aee84  (<unknown module>)
    #12 0x18f4a7f64 in dyld4::Loader::runInitializersBottomUp(dyld4::RuntimeState&, dyld3::Array<dyld4::Loader const*>&, dyld3::Array<dyld4::Loader const*>&) const+0x134 (dyld:arm64e+0xfffffffffff57f64)
    #13 0x18f4ac254  (<unknown module>)
    #14 0x18f4a8154 in dyld4::Loader::runInitializersBottomUpPlusUpwardLinks(dyld4::RuntimeState&) const+0x198 (dyld:arm64e+0xfffffffffff58154)
    #15 0x18f4c0484  (<unknown module>)
    #16 0x11e974d28 in dlopen+0x108 (libclang_rt.asan_osx_dynamic.dylib:arm64e+0x40d28)
    #17 0x104b4dac0 in mysql_create_function(THD*, udf_func*, bool) sql_udf.cc:705
    #18 0x1046533cc in mysql_execute_command(THD*, bool) sql_parse.cc:3967
    #19 0x1046414cc in dispatch_sql_command(THD*, Parser_state*) sql_parse.cc:5371
    #20 0x10462c1d4 in dispatch_command(THD*, COM_DATA const*, enum_server_command) sql_parse.cc:2055
    #21 0x10463955c in do_command(THD*) sql_parse.cc:1440
    #22 0x104f4a408 in handle_connection(void*) connection_handler_per_thread.cc:303
    #23 0x10976bbcc in pfs_spawn_thread(void*) pfs.cc:3050
    #24 0x11e985858 in asan_thread_start(void*)+0x40 (libclang_rt.asan_osx_dynamic.dylib:arm64e+0x51858)
    #25 0x18f8132e0 in _pthread_start+0x84 (libsystem_pthread.dylib:arm64e+0x72e0)
    #26 0x18f80e0f8 in thread_start+0x4 (libsystem_pthread.dylib:arm64e+0x20f8)

  [2]:
    #0 0x11e9496a0 in __asan_register_globals+0x9c (libclang_rt.asan_osx_dynamic.dylib:arm64e+0x156a0)
    #1 0x11e987124 in __asan::AsanApplyToGlobals(void (*)(__asan_global*, unsigned long), void const*)+0x70 (libclang_rt.asan_osx_dynamic.dylib:arm64e+0x53124)
    #2 0x11e9495ec in __asan_register_image_globals+0x3c (libclang_rt.asan_osx_dynamic.dylib:arm64e+0x155ec)
    #3 0x1345678d4 in asan.module_ctor+0x18 (keyring_udf.so:arm64+0xb8d4)
    #4 0x18f4a7b84 in invocation function for block in dyld4::Loader::findAndRunAllInitializers(dyld4::RuntimeState&) const+0x24c (dyld:arm64e+0xfffffffffff57b84)
    #5 0x18f4e63b8  (<unknown module>)
    #6 0x18f4d9b20  (<unknown module>)
    #7 0x18f48c2d8  (<unknown module>)
    #8 0x18f4d8ab4  (<unknown module>)
    #9 0x18f4e5ecc  (<unknown module>)
    #10 0x18f4a78a8 in dyld4::Loader::findAndRunAllInitializers(dyld4::RuntimeState&) const+0xac (dyld:arm64e+0xfffffffffff578a8)
    #11 0x18f4aee84  (<unknown module>)
    #12 0x18f4a7f64 in dyld4::Loader::runInitializersBottomUp(dyld4::RuntimeState&, dyld3::Array<dyld4::Loader const*>&, dyld3::Array<dyld4::Loader const*>&) const+0x134 (dyld:arm64e+0xfffffffffff57f64)
    #13 0x18f4ac254  (<unknown module>)
    #14 0x18f4a8154 in dyld4::Loader::runInitializersBottomUpPlusUpwardLinks(dyld4::RuntimeState&) const+0x198 (dyld:arm64e+0xfffffffffff58154)
    #15 0x18f4c0484  (<unknown module>)
    #16 0x11e974d28 in dlopen+0x108 (libclang_rt.asan_osx_dynamic.dylib:arm64e+0x40d28)
    #17 0x104b4dac0 in mysql_create_function(THD*, udf_func*, bool) sql_udf.cc:705
    #18 0x1046533cc in mysql_execute_command(THD*, bool) sql_parse.cc:3967
    #19 0x1046414cc in dispatch_sql_command(THD*, Parser_state*) sql_parse.cc:5371
    #20 0x10462c1d4 in dispatch_command(THD*, COM_DATA const*, enum_server_command) sql_parse.cc:2055
    #21 0x10463955c in do_command(THD*) sql_parse.cc:1440
    #22 0x104f4a408 in handle_connection(void*) connection_handler_per_thread.cc:303
    #23 0x10976bbcc in pfs_spawn_thread(void*) pfs.cc:3050
    #24 0x11e985858 in asan_thread_start(void*)+0x40 (libclang_rt.asan_osx_dynamic.dylib:arm64e+0x51858)
    #25 0x18f8132e0 in _pthread_start+0x84 (libsystem_pthread.dylib:arm64e+0x72e0)
    #26 0x18f80e0f8 in thread_start+0x4 (libsystem_pthread.dylib:arm64e+0x20f8)

==93877==HINT: if you don't care about these errors you may set ASAN_OPTIONS=detect_odr_violation=0
SUMMARY: AddressSanitizer: odr-violation: global 'keyring_udf_decriptor' at /Users/laurynas/vilniusdb/mysql-8.0.40/plugin/keyring_udf/keyring_udf.cc
Thread T48 created by T0 here:
    #0 0x11e9801c8 in pthread_create+0x5c (libclang_rt.asan_osx_dynamic.dylib:arm64e+0x4c1c8)
    #1 0x10976b540 in pfs_spawn_thread_vc(unsigned int, unsigned int, my_thread_handle*, _opaque_pthread_attr_t const*, void* (*)(void*), void*) pfs.cc:3096
    #2 0x104f49bd8 in Per_thread_connection_handler::add_connection(Channel_info*) connection_handler_per_thread.cc:415
    #3 0x102b60124 in Connection_handler_manager::process_new_connection(Channel_info*) connection_handler_manager.cc:263
    #4 0x103b48010 in Connection_acceptor<Mysqld_socket_listener>::connection_event_loop() connection_acceptor.h:66
    #5 0x103b35618 in mysqld_main(int, char**) mysqld.cc:8286
    #6 0x18f490270  (<unknown module>)

==93877==ABORTING
[16 Oct 12:07] Laurynas Biveinis
test_services.test_udf_registration:
==95883==ERROR: AddressSanitizer: odr-violation (0x00013665c000):
  [1] size=4 '_mysql_plugin_interface_version_' /Users/laurynas/vilniusdb/mysql-8.0.40/plugin/udf_services/test_udf_services.cc
  [2] size=4 '_mysql_plugin_interface_version_' /Users/laurynas/vilniusdb/mysql-8.0.40/plugin/udf_services/test_udf_services.cc
[16 Oct 12:13] Laurynas Biveinis
clone.error_features:
==865==ERROR: AddressSanitizer: odr-violation (0x00013328c000):
  [1] size=8 'clone_plugin_name' /Users/laurynas/vilniusdb/mysql-8.0.40/plugin/clone/src/clone_plugin.cc
  [2] size=8 'clone_plugin_name' /Users/laurynas/vilniusdb/mysql-8.0.40/plugin/clone/src/clone_plugin.cc
[16 Oct 12:16] Laurynas Biveinis
Same for clone.local_basic and clone.remote_basic as in the previous comment.

main.persisted_variables_for_plugin:
==10814==ERROR: AddressSanitizer: odr-violation (0x000134904b60):
  [1] size=8 'log_bi' /Users/laurynas/vilniusdb/mysql-8.0.40/plugin/password_validation/validate_password.cc
  [2] size=8 'log_bi' /Users/laurynas/vilniusdb/mysql-8.0.40/plugin/password_validation/validate_password.cc
[16 Oct 12:31] Laurynas Biveinis
clone.remote_error_features, clone.remote_skip_validation:
==30534==ERROR: AddressSanitizer: odr-violation (0x000133e84000):
  [1] size=8 'clone_plugin_name' /Users/laurynas/vilniusdb/mysql-8.0.40/plugin/clone/src/clone_plugin.cc
  [2] size=8 'clone_plugin_name' /Users/laurynas/vilniusdb/mysql-8.0.40/plugin/clone/src/clone_plugin.cc

main.bug12969156:
==33295==ERROR: AddressSanitizer: odr-violation (0x000137decc80):
  [1] size=4 'key_memory_mysql_heartbeat_context' /Users/laurynas/vilniusdb/mysql-8.0.40/plugin/daemon_example/daemon_example.cc
  [2] size=4 'key_memory_mysql_heartbeat_context' /Users/laurynas/vilniusdb/mysql-8.0.40/plugin/daemon_example/daemon_example.cc
[16 Oct 12:35] Laurynas Biveinis
test_service_sql_api.test_sql_replication:
==38184==ERROR: AddressSanitizer: odr-violation (0x000135eac740):
  [1] size=8 'log_bi' /Users/laurynas/vilniusdb/mysql-8.0.40/plugin/test_service_sql_api/test_sql_replication.cc
  [2] size=8 'log_bi' /Users/laurynas/vilniusdb/mysql-8.0.40/plugin/test_service_sql_api/test_sql_replication.cc
[16 Oct 13:01] Laurynas Biveinis
Same on 8.4.3
[16 Oct 15:34] MySQL Verification Team
Hello Laurynas,

Thank you for the report and feedback!

regards,
Umesh
[17 Oct 11:57] Laurynas Biveinis
Same on 9.1.0
[17 Oct 12:16] Laurynas Biveinis
9.1.0-only test failure:

main.initialize-bug21335821:
==37101==ERROR: AddressSanitizer: odr-violation (0x00012f610b20):
  [1] size=8 'log_bi' /Users/laurynas/vilniusdb/mysql-9.1.0/plugin/password_validation/validate_password.cc
  [2] size=8 'log_bi' /Users/laurynas/vilniusdb/mysql-9.1.0/plugin/password_validation/validate_password.cc