Menu

#35 Berkeley db module configure error

None
closed-rejected
None
5
2017-12-07
2012-09-27
Jerry James
No

The berkeley-db module's configure script adds -Werror to CFLAGS. With recent versions of GCC, this code triggers a warning (and therefore an error) about the use of an uninitialized variable:

DB_ENV dbe; dbe.set_errcall(&dbe,&my_callback);

There are multiple possible fixes. I chose to also add -Wno-uninitialized to CFLAGS in this patch. Not adding -Werror is another option.

Discussion

  • Jerry James

    Jerry James - 2012-09-27

    Patch to add -Wno-uninitialized to CFLAGS

     
  • Sam Steingold

    Sam Steingold - 2017-12-06
    • status: open --> closed-rejected
    • assigned_to: Sam Steingold
    • Group: -->
     
  • Sam Steingold

    Sam Steingold - 2017-12-06

    the configure check is there for a good reason.
    this works fine with clang-900.0.38 on x86_64-apple-darwin16.7.0,

     
  • Jerry James

    Jerry James - 2017-12-07

    I'm not sure what "works fine" means, as this depends on which warning flags you pass to the compiler. With the default flags used by Fedora, namely "-Wall", the configure script incorrectly says:

    checking whether DB_ENV->set_errcall() accepts DBE... no

    It does, in fact, accept DBE. In config.log I see:

    configure:5749: checking whether DB_ENV->set_errcall() accepts DBE
    configure:5769: gcc -c -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -Wa,--noexecstack -Werror -I/usr/include/libsvm conftest.c >&5
    conftest.c: In function 'main':
    conftest.c:51:16: error: 'dbe.set_errcall' is used uninitialized in this function [-Werror=uninitialized]
    DB_ENV dbe; dbe.set_errcall(&dbe,&my_callback);
    ~~~^~~~~~~~~~~~
    cc1: all warnings being treated as errors
    configure:5769: $? = 1
    configure: failed program was:
    | / confdefs.h /
    ...

    When building with clang, do you have -Wall in CFLAGS? Is DB_ENV->set_errcall() detected as accepting DBE?

     
  • Sam Steingold

    Sam Steingold - 2017-12-07

    Yes, DB_ENV->set_errcall() is correctly detected:

    configure:5749: checking whether DB_ENV->set_errcall() accepts DBE
    configure:5769: gcc -c -g -O2 -Werror -I/usr/local/include conftest.c >&5
    configure:5769: $? = 0
    configure:5777: result: yes
    

    if your system passes "unusual" options to gcc, this is probably not the right place to discuss this.
    Either autoconf should handle this, or the system should not modify gcc command line options.
    At any rate, please discuss this with the autoconf maintainers and bring back their verdict on how this issue is to be handled.
    Thanks.

     

Log in to post a comment.

MongoDB Logo MongoDB