[CONC-553] SIGBUS when calling mysql_real_connect_start on ARM64 macOS Created: 2021-06-06  Updated: 2022-07-25  Resolved: 2022-07-25

Status: Closed
Project: MariaDB Connector/C
Component/s: API
Affects Version/s: 3.1.12
Fix Version/s: 3.1.17

Type: Bug Priority: Critical
Reporter: kotori Assignee: Georg Richter
Resolution: Fixed Votes: 0
Labels: None
Environment:

macOS 11.4 on M1, libmariadb installed with Vcpkg, clang-1205.0.22.9



 Description   

A simple program like this will cause SIGBUS:

    MYSQL mysql;
    mysql_init(&mysql);
    auto r = mysql_options(&mysql, MYSQL_OPT_NONBLOCK, nullptr);
    MYSQL *ret = nullptr;
    mysql_real_connect_start(&ret,
                             &mysql,
                             "127.0.0.1",
                             "root",
                             "root",
                             "mysql",
                             3306,
                             nullptr,
                             0);

It actually won't produce any stack trace but with single step in IDE, the crash actually produced at swapcontext in my_context_continue.
Might related to MDEV-9112

Update: It's because _XOPEN_SOURCE macro caused stack struct change in macOS. But someone defined _XOPEN_SOURCE in the source file instead of in CMakefile.txt.
Ref: https://stackoverflow.com/questions/23852522/swapcontext-segfaults-when-swapping-to-a-ucontext-ts-uc-link



 Comments   
Comment by kotori [ 2021-06-06 ]

PR sent at https://github.com/mariadb-corporation/mariadb-connector-c/pull/172

Generated at Thu Feb 08 03:06:08 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.