Uploaded image for project: 'MariaDB Connector/C'
  1. MariaDB Connector/C
  2. CONC-553

SIGBUS when calling mysql_real_connect_start on ARM64 macOS

Details

    • Bug
    • Status: Closed (View Workflow)
    • Critical
    • Resolution: Fixed
    • 3.1.12
    • 3.1.17
    • API
    • None
    • 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

      Attachments

        Activity

          kotori kotori created issue -
          kotori kotori made changes -
          Field Original Value New Value
          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 https://jira.mariadb.org/browse/MDEV-9112
          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 https://jira.mariadb.org/browse/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
          serg Sergei Golubchik made changes -
          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 https://jira.mariadb.org/browse/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
          A simple program like this will cause SIGBUS:
          {code:c}
              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);
          {code}
          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 https://jira.mariadb.org/browse/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
          serg Sergei Golubchik made changes -
          Description A simple program like this will cause SIGBUS:
          {code:c}
              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);
          {code}
          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 https://jira.mariadb.org/browse/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
          A simple program like this will cause SIGBUS:
          {code:c}
              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);
          {code}
          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 https://jira.mariadb.org/browse/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
          serg Sergei Golubchik made changes -
          Description A simple program like this will cause SIGBUS:
          {code:c}
              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);
          {code}
          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 https://jira.mariadb.org/browse/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
          A simple program like this will cause SIGBUS:
          {code:c}
              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);
          {code}
          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
          serg Sergei Golubchik made changes -
          Priority Major [ 3 ] Critical [ 2 ]
          serg Sergei Golubchik made changes -
          Fix Version/s 3.1.14 [ 25817 ]
          ralf.gebhardt Ralf Gebhardt made changes -
          Fix Version/s 3.1 [ 23223 ]
          Fix Version/s 3.1.14 [ 25817 ]
          julien.fritsch Julien Fritsch made changes -
          Workflow MariaDB connectors [ 122482 ] MariaDB v4 [ 160881 ]
          serg Sergei Golubchik made changes -
          Fix Version/s 3.1.17 [ 27520 ]
          Fix Version/s 3.1 [ 23223 ]
          Resolution Fixed [ 1 ]
          Status Open [ 1 ] Closed [ 6 ]

          People

            georg Georg Richter
            kotori kotori
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.