tensorflow: Build tensorflow 2.2.0 failed in '@upb//:upb' with the length argument in strncpy
System information
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Linux Ubuntu 18.04.4 LTS
- TensorFlow installed from (source or binary): source
- TensorFlow version: 2.2.0
- Python version: 3.7.7
- Bazel version (if compiling from source): 2.0.0
- GCC/Compiler version (if compiling from source): 10.1.0
Describe the problem
In file included from /usr/include/string.h:494,
from external/upb/upb/upb.h:16,
from external/upb/upb/upb.c:2:
In function 'strncpy',
inlined from 'upb_status_seterrmsg' at external/upb/upb/upb.c:40:3:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:10: error: '__builtin_strncpy' specified bound 127 equals destination size [-Werror=stringop-truncation]
106 | return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
Target //tensorflow/tools/pip_package:build_pip_package failed to build
Provide the exact sequence of commands / steps that you executed before running into the problem
Build with bazel following the documentation.
Any other info / logs
It’s a trivial misuse of strncpy. Here is a simple fix.
--- upb/upb/upb.c~ 2020-05-12 14:33:15.046048687 -0500
+++ upb/upb/upb.c 2020-05-12 14:33:30.281987830 -0500
@@ -37,7 +37,7 @@
void upb_status_seterrmsg(upb_status *status, const char *msg) {
if (!status) return;
status->ok = false;
- strncpy(status->msg, msg, sizeof(status->msg));
+ strncpy(status->msg, msg, sizeof(status->msg)-1);
nullz(status);
}
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 9
- Comments: 21 (9 by maintainers)
Commits related to this issue
- Add -Wno-stringop-truncation to build flags on Linux. Works around https://github.com/tensorflow/tensorflow/issues/39467 for gcc 10+ builds. — committed to hawkinsp/jax by hawkinsp 4 years ago
When can we compile TF 2.2.0 on Clear Linux without this bug ?
Annoying comment, but necessary I guess: Any update?
The current state of this is that tensorflow sadly still doesn’t work on gcc 10 which is especially annoying since even CUDA 11.1 now supports gcc 10. As a downstream packager, I’m not really sure what the proper way to address this problem would be but I’d appreciate it if a tensorflow team member could fix it.