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

ma_context.c error: 'u.a[1]' may be used uninitialized

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • 3.4.1
    • None
    • Non blocking API
    • None
    • OpenWrt, ARM Cortex-A9, GCC 14.2

    Description

      Since mariadb-connector-c is compiled with "-Werror" turned on, on 32-bit systems with ucontext it produces an error:

      libmariadb/ma_context.c:106:3: error: 'u.a[1]' may be used uninitialized [-Werror=maybe-uninitialized]
        106 |   makecontext(&c->spawned_context, (uc_func_t)my_context_spawn_internal, 2,
            |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        107 |               u.a[0], u.a[1]);
            |               ~~~~~~~~~~~~~~~
      libmariadb/ma_context.c:94:32: note: 'u.a[1]' was declared here
         94 |   union pass_void_ptr_as_2_int u;
            |                                ^
      cc1: all warnings being treated as errors
      

      When I initialized this field right after its declaration, the error disappeared:

      my_context_spawn(struct my_context *c, void (*f)(void *), void *d)
      {
        int err;
        union pass_void_ptr_as_2_int u;
        u.a[1] = 0; // the fix
      

      Attachments

        Activity

          People

            georg Georg Richter
            krant Aleksey Vasilenko
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Git Integration

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