Skip to content
This repository has been archived by the owner on Jun 23, 2022. It is now read-only.

fix: compile error of zookeeper 3.4.10 on gcc9 #667

Closed
wants to merge 0 commits into from

Conversation

neverchanje
Copy link
Contributor

@neverchanje neverchanje commented Nov 11, 2020

compilation error

src/zookeeper.c: In function 'format_endpoint_info':
src/zookeeper.c:3469:21: error: '%d' directive writing between 1 and 5 bytes into a region of size between 0 and 127 [-Werror=format-overflow=]
 3469 |     sprintf(buf,"%s:%d",addrstr,ntohs(port));
      |                     ^~
src/zookeeper.c:3469:17: note: directive argument in the range [0, 65535]
 3469 |     sprintf(buf,"%s:%d",addrstr,ntohs(port));
      |                 ^~~~~~~
In file included from /usr/include/stdio.h:867,
                 from ./include/zookeeper.h:29,
                 from src/zookeeper.c:27:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:36:10: note: '__builtin___sprintf_chk' output between 3 and 134 bytes into a destination of size 128
   36 |   return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   37 |       __bos (__s), __fmt, __va_arg_pack ());
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

GCC9 generates errors on the zookeeper c client 3.4.10. So I try to upgrade it to 3.5.8, and it produces no error then.
One potential risk 3.5.8 clients could be minor incompatibilities towards 3.4.x zk-servers.

Some threads had related discussions:

@neverchanje neverchanje added the thirdparty-modified If this PR modified some thirdparties that need to be entirely rebuilt. label Nov 11, 2020
@neverchanje neverchanje marked this pull request as draft November 11, 2020 15:15
@neverchanje neverchanje marked this pull request as ready for review November 25, 2020 02:17
@neverchanje
Copy link
Contributor Author

Well, zk-ruby/zookeeper#85 (comment) there's also an approach that could simply fix this problem.

- ./configure --enable-static=yes --enable-shared=no --prefix=${TP_OUTPUT} --with-pic=yes
+ CFLAGS=-Wno-error=format-overflow ./configure --enable-static=yes --enable-shared=no --prefix=${TP_OUTPUT} --with-pic=yes

Suppressing the error so that compilation will pass. I would prefer fixing with minimum modifications though it seems tricky.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
thirdparty-modified If this PR modified some thirdparties that need to be entirely rebuilt.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants