#986575 mdbtools ftbfs with -O3

#986575#5
Date:
2021-04-07 15:13:32 UTC
From:
To:
The first one is seen with glib2.0 from experimental.

mdbtools ftbfs when building with -O3.  The second error here isn't seen because
of the libtool redirection to /dev/null.


In file included from /usr/include/stdio.h:866,
                 from ../../include/mdbtools.h:24,
                 from catalog.c:19:
In function ‘printf’,
    inlined from ‘mdb_dump_catalog’ at catalog.c:195:4:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:112:10: error: ‘%-12s’ directive
argument is null [-Werror=format-overflow=]
  112 |   return __printf_chk (__USE_FORTIFY_LEVEL - 1, __fmt, __va_arg_pack ());
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors



To work around these failure, build with

  * Fix ftbfs, build with -Wno-error=deprecated-declarations.
  * Fix ftbfs, build with -Wno-error=format-overflow=.

I didn't look for a fix.

#986575#10
Date:
2021-04-07 18:03:37 UTC
From:
To:
Hello Matthias

This looks like another problem with the compiler (I had no feedback from you regarding #984230)

Here's the code:
mdb_get_objtype_string(int obj_type)
{
    static const char *type_name[] = {"Form",
                        "Table",
                        "Macro",
                        "System Table",
                        "Report",
                        "Query",
                        "Linked Table",
                        "Module",
                        "Relationship",
                        "Unknown 0x09",
                        "User Info",
                        "Database"
                };

        if (obj_type >= (int)(sizeof(type_name)/sizeof(type_name[0]))) {
                return NULL;
        } else {
                return type_name[obj_type];
        }
}

(...)
for (i=0;i<mdb->num_catalog;i++) {
                entry = g_ptr_array_index(mdb->catalog,i);
                printf("Type: %-12s", mdb_get_objtype_string(entry->object_type));
}

Yelding:
error: ‘%-12s’ directive argument is null

But the mdb is read from a file, and I can't see why and how the compiler would decide/know the entry is out of range in g_ptr_array_index and assume mdb_get_objtype_string would return NULL anyway...

Regarding the second issue, I can't see errors being redirected to null.
Are you building the package with a tool such as debuild?

#986575#15
Date:
2021-04-07 19:52:17 UTC
From:
To:
could you recheck that with the recent gcc-11 from experimental?

yes, just plain dpkg-buildpackage,

https://launchpadlibrarian.net/532289912/buildlog_ubuntu-hirsute-ppc64el.mdbtools_0.9.2-2ubuntu1_BUILDING.txt.gz

... and I see that -flto=auto -ffat-lto-objects is also needed in CFLAGS and
LDFLAGS to trigger the issue.

#986575#20
Date:
2021-04-09 07:17:49 UTC
From:
To:
https://github.com/mdbtools/mdbtools/commit/fe0175aa6398a8fbde051cdce5d69de1de2d4489
that will be released soonish.

Regarding the error: ‘%-12s’ directive argument is null
I can confirm this is not a gcc-11 specific issue as it also occurs with gcc-10 (4:10.2.1-1 from bullseye) when you modify the d/rules to include "export DEB_CFLAGS_MAINT_APPEND=-O3" like you did.
I still think this is a compiler issue. Don't you share that point of view?

#986575#25
Date:
2021-09-29 13:33:02 UTC
From:
To:
Hi,
I've seen the same issue and think I found the root cause.
I filed it upstream at
https://github.com/mdbtools/mdbtools/issues/352

TL;DR the problem is the "potential" not the actual NULL that is
passed to printf.
This triggers the new error case detection in the newer toolchain and
breaks the build.

The upstream report also contains a suggestion to fix it that worked
in a local try on ppc64.
Hope that helps to resolve this.