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

Version 5.9.0 will not build as x86 system #3179

Closed
Roland-F opened this issue Jun 18, 2019 · 12 comments · Fixed by #3245
Closed

Version 5.9.0 will not build as x86 system #3179

Roland-F opened this issue Jun 18, 2019 · 12 comments · Fixed by #3245

Comments

@Roland-F
Copy link

By building collect 5.9.0 with cross-compiling (Buildroot), it works for an x86_64 system.
But when i try this for an x86 system i will get during the build the following faults:
src/daemon/plugin.c: In function 'plugin_init_all':
src/daemon/plugin.c:838:34: error: '%llu' directive output may be truncated writing between 1 and 10 bytes into a region of size 9 [-Werror=format-truncation=]
snprintf(name, sizeof(name), "writer#%" PRIu64,
^~~~~~~~~~
src/daemon/plugin.c:838:42: note: format string is defined here
snprintf(name, sizeof(name), "writer#%" PRIu64,
src/daemon/plugin.c:838:34: note: directive argument in the range [0, 4294967295]
snprintf(name, sizeof(name), "writer#%" PRIu64,
^~~~~~~~~~
src/daemon/plugin.c:838:5: note: 'snprintf' output between 9 and 18 bytes into a destination of size 16
snprintf(name, sizeof(name), "writer#%" PRIu64,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(uint64_t)write_threads_num);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/daemon/plugin.c:649:34: error: '%llu' directive output may be truncated writing between 1 and 10 bytes into a region of size 9 [-Werror=format-truncation=]
snprintf(name, sizeof(name), "reader#%" PRIu64, (uint64_t)read_threads_num);
^~~~~~~~~~
src/daemon/plugin.c:649:42: note: format string is defined here
snprintf(name, sizeof(name), "reader#%" PRIu64, (uint64_t)read_threads_num);
src/daemon/plugin.c:649:34: note: directive argument in the range [0, 4294967295]
snprintf(name, sizeof(name), "reader#%" PRIu64, (uint64_t)read_threads_num);
^~~~~~~~~~
src/daemon/plugin.c:649:5: note: 'snprintf' output between 9 and 18 bytes into a destination of size 16
snprintf(name, sizeof(name), "reader#%" PRIu64, (uint64_t)read_threads_num);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I suggest that this problem come up as by the src/daemon/plugin.c now will be set some parts for pure x86_64 system (PRIu64; unit64_t) and they will be not available as x86 system.

Best regards,
Roland Franke

@mrunge
Copy link
Member

mrunge commented Jun 18, 2019

Hi,

what do you mean here: does it work or doesn't it? Are you cross-compiling on non x86 systems?

Please also add info in the used c-compiler, as I suspect that to be the issue here.

@Roland-F
Copy link
Author

My builder is an x86_64 system.
Buildroot works with uclibc and gcc/g++ as compiler.
During the build, i be getting the shown fault-messages and so the compile is stopped.
But i will be at the test with an other solution, as the kernel-modules be not build at the moment.
And this may be a point, why the x86 build gone fault.
Will inform here what happened when i restart the build from collectd, after the kernel-modules be build ready.

@Roland-F
Copy link
Author

My build will stuck at the same errors as informed at my first information.
More as this is not known from me.
Only as hint: With the same cross-compile system, but with target as x86_64 system the build will work.
Additional was the version V5.8.1 working for me also at the same system. Only after updating the version to 5.9.0, the build stock in the x86 variant.

@mrunge
Copy link
Member

mrunge commented Jun 18, 2019

Hmm, it works on or koji-type builder https://review.rdoproject.org/r/#/c/21124/

I assume, you're running into an incarnation of #3038

@Roland-F
Copy link
Author

Please get the information, that gcc is in version 7.3.0.
Will just try to update gcc to version 7.4.0 and look then what happend.
An feedback can be given tomorrow (06/18/2019) here.

@Roland-F
Copy link
Author

Sorry. No change. Building still leaks with identical messages from my first post here.

@Roland-F
Copy link
Author

Roland-F commented Jun 20, 2019

Hello,
with the following patch the build will work for me for an x86_64 and x86 system

diff -purN collectd-5.9.0_org/src/daemon/plugin.c collectd-5.9.0/src/daemon/plugin.c
--- collectd-5.9.0_org/src/daemon/plugin.c	2019-06-13 11:13:42.551364463 +0200
+++ collectd-5.9.0/src/daemon/plugin.c	2019-06-19 23:03:00.111842000 +0200
@@ -645,7 +645,7 @@ static void start_read_threads(size_t nu
       return;
     }
 
-    char name[THREAD_NAME_MAX];
+    char name[THREAD_NAME_MAX + 2];
     snprintf(name, sizeof(name), "reader#%" PRIu64, (uint64_t)read_threads_num);
     set_thread_name(read_threads[read_threads_num], name);
 
@@ -834,7 +834,7 @@ static void start_write_threads(size_t n
       return;
     }
 
-    char name[THREAD_NAME_MAX];
+    char name[THREAD_NAME_MAX + 2];
     snprintf(name, sizeof(name), "writer#%" PRIu64,
              (uint64_t)write_threads_num);
     set_thread_name(write_threads[write_threads_num], name);

@LeSpocky
Copy link

FWIW,

Hmm, it works on or koji-type builder https://review.rdoproject.org/r/#/c/21124/

I assume, you're running into an incarnation of #3038

What happens here is running a new compiler with better "analysis power". It's independent from architecture. If THREAD_NAME_MAX is e.g. 16 and you want to write "writer#12345" to it, and 12345 is supposed to be an unsigned 64 integer, the maximum theoretical possible value would be "writer#18446744073709551615" with 7 + 20 digits (without null termination), which is clearly longer than the provided string buffer. snprintf() would truncate the resulting string and that's what the warning is about.

@LeSpocky
Copy link

However I would not cast write_threads_num from size_t to uint64_t, but use the '%zu' format specifier instead or tweak THREAD_NAME_MAX or both.

@LeSpocky
Copy link

The other question here is, who sets -Werror. Is it collectd, buildroot or the modified buildroot of fli4l? 😉

@LeSpocky
Copy link

LeSpocky commented Jul 14, 2019

I saw commit abaa1c8 from #3153 in master which seems not to be part of the 5.9 branch, which "solves" that problem by introducing a wrapper around snprintf() … 😲

@Roland-F
Copy link
Author

Roland-F commented Aug 8, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants