Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation issues on gcc 9.1.1 [-Werror=stringop-truncation] #6720

Closed
monetdb-team opened this issue Nov 30, 2020 · 0 comments
Closed

Compilation issues on gcc 9.1.1 [-Werror=stringop-truncation] #6720

monetdb-team opened this issue Nov 30, 2020 · 0 comments
Labels
bug Something isn't working normal SQL

Comments

@monetdb-team
Copy link

Date: 2019-06-26 10:10:35 +0200
From: @swingbit
To: SQL devs <>
Version: 11.33.3 (Apr2019)
CC: @PedroTadim

Last updated: 2019-09-02 16:05:27 +0200

Comment 27086

Date: 2019-06-26 10:10:35 +0200
From: @swingbit

User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36
Build Identifier:

Compiling Apr2019 tip on FC30, gcc (GCC) 9.1.1 20190503
configure : --disable-debug --disable-developer --disable-assert --enable-optimize

In file included from /usr/include/string.h:494,
from src/monetdb5/mal/../../gdk/gdk.h:316,
from src/monetdb5/mal/mal.h:17,
from src/monetdb5/mal/mal_type.h:11,
from src/monetdb5/mal/mal_instruction.h:12,
from src/monetdb5/mal/mal_exception.h:11,
from src/monetdb5/mal/mal_import.h:12,
from src/monetdb5/mal/mal_import.c:28:
In function ‘strncpy’,
inlined from ‘mal_cmdline’ at src/monetdb5/mal/mal_import.c:305:3,
inlined from ‘compileString’ at src/monetdb5/mal/mal_import.c:326:6:
/usr/include/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ output truncated before terminating nul copying as many bytes from a string as its length [-Werror=stringop-truncation]
106 | return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/monetdb5/mal/mal_import.c: In function ‘compileString’:
src/monetdb5/mal/mal_import.c:318:18: note: length computed here
318 | int len = (int) strlen(s);
| ^~~~~~~~~
In file included from /usr/include/string.h:494,
from src/monetdb5/mal/../../gdk/gdk.h:316,
from src/monetdb5/mal/mal.h:17,
from src/monetdb5/mal/mal_type.h:11,
from src/monetdb5/mal/mal_instruction.h:12,
from src/monetdb5/mal/mal_exception.h:11,
from src/monetdb5/mal/mal_import.h:12,
from src/monetdb5/mal/mal_import.c:28:
In function ‘strncpy’,
inlined from ‘mal_cmdline’ at src/monetdb5/mal/mal_import.c:305:3,
inlined from ‘callString’ at src/monetdb5/mal/mal_import.c:400:6:
/usr/include/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ output truncated before terminating nul copying as many bytes from a string as its length [-Werror=stringop-truncation]
106 | return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/monetdb5/mal/mal_import.c: In function ‘callString’:
src/monetdb5/mal/mal_import.c:394:21: note: length computed here
394 | int i, len = (int) strlen(s);
| ^~~~~~~~~
cc1: all warnings being treated as errors
make[6]: *** [Makefile:795: libmal_la-mal_import.lo] Error 1
make[6]: *** Waiting for unfinished jobs....
make[5]: *** [Makefile:493: all] Error 2
make[4]: *** [Makefile:532: all-recursive] Error 1
make[3]: *** [Makefile:486: all] Error 2
make[2]: *** [Makefile:594: all-recursive] Error 1
make[1]: *** [Makefile:524: all] Error 2
make: *** [Makefile:175: compile] Error 2

Reproducible: Always

Comment 27088

Date: 2019-06-26 15:03:02 +0200
From: MonetDB Mercurial Repository <>

Changeset c15ea2e68434 made by Pedro Ferreira pedro.ferreira@monetdbsolutions.com in the MonetDB repo, refers to this bug.

For complete details, see https//devmonetdborg/hg/MonetDB?cmd=changeset;node=c15ea2e68434

Changeset description:

Compilation fixes for bug #6720.

Comment 27091

Date: 2019-06-26 17:09:38 +0200
From: @swingbit

Pedro,

There is one more strncpy (which triggers the same compilation issue) at monetdb5/modules/mal/mdb.c:703

Fixing this on top of your previous commit makes it compile correctly.

Comment 27093

Date: 2019-06-26 18:10:54 +0200
From: @PedroTadim

I didn't get that error. However if I fix it in mdb.c:703, the error will be thrown elsewhere, because we use strncpy in many places.

Comment 27094

Date: 2019-06-26 18:40:41 +0200
From: @swingbit

Mh, strange. I got only an error on that one and after fixing it I got no more errors.

Are you using gcc 9?

In any case, isn't it a good idea to change all occurrences of strncp into memcpy? strncpy will keep giving compilation errors. As far as I know, the only advantage of strncpy is that it pads the destination with 0s if the string is shorter than n. But in most cases that's not needed.

Comment 27137

Date: 2019-07-15 10:44:45 +0200
From: @sjoerdmullender

Changing all strncpy calls to memcpy is not a priority. What is a priority is making sure the system compiles cleanly on as many environments as is reasonable (which includes the latest gcc).
I myself use the latest Fedora release on my laptop (which has gcc 9.1.1), but don't always compile an optimized version there (which was needed to trigger the message).

@monetdb-team monetdb-team added bug Something isn't working normal SQL labels Nov 30, 2020
@sjoerdmullender sjoerdmullender added this to the Ancient Release milestone Feb 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working normal SQL
Projects
None yet
Development

No branches or pull requests

2 participants