[LU-16980] format-truncation errors Created: 25/Jul/23  Updated: 07/Aug/23  Resolved: 07/Aug/23

Status: Resolved
Project: Lustre
Component/s: None
Affects Version/s: Lustre 2.16.0
Fix Version/s: Lustre 2.16.0

Type: Bug Priority: Minor
Reporter: Jian Yu Assignee: Jian Yu
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Related
Severity: 3
Rank (Obsolete): 9223372036854775807

 Description   

While building master branch against kernel 6.2.0-26-generic with gcc 12.2.0, the following errors occurred:

liblnetconfig.c: In function 'open_sysfs_file':
liblnetconfig.c:106:49: error: '%s' directive output may be truncated writing up to 127 bytes into a region of size between 1 and 128 [-Werror=format-truncation=]
  106 |         snprintf(filename, sizeof(filename), "%s%s",
      |                                                 ^~
lfs_project.c: In function ‘lfs_project_handle_dir’:
lfs_project.c:324:50: error: ‘%s’ directive output may be truncated writing up to 255 bytes into a region of size between 1 and 4095 [-Werror=format-truncation=]
  324 |                 snprintf(fullname, PATH_MAX, "%s/%s", pathname,
      |                                                  ^~
statx.c: In function ‘do_dir_list’:
statx.c:1427:58: error: ‘%s’ directive output may be truncated writing up to 255 bytes into a region of size between 1 and 4095 [-Werror=format-truncation=]
 1427 |                         snprintf(fullname, PATH_MAX, "%s/%s",
      |                                                          ^~


 Comments   
Comment by Jian Yu [ 25/Jul/23 ]

More build errors:

/root/lustre-release/libcfs/include/libcfs/util/list.h:481:42: error: pointer ‘tmp’ used after ‘free’ [-Werror=use-after-free]
  481 |              pos = list_entry(pos->member.next, typeof(*pos), member),  \
      |                                          ^
/root/lustre-release/libcfs/include/libcfs/util/list.h:239:28: note: in definition of macro ‘list_entry’
  239 |         ((type *)((char *)(ptr)-(char *)(&((type *)0)->member)))
      |                            ^~~
obd.c:5118:9: note: in expansion of macro ‘list_for_each_entry’
 5118 |         list_for_each_entry(tmp, head, lpn_list) {
      |         ^~~~~~~~~~~~~~~~~~~
obd.c:5124:17: note: call to ‘free’ here
 5124 |                 free(tmp);
      |                 ^~~~~~~~~
cc1: all warnings being treated as errors
lutf_python.c: In function ‘python_init’:
lutf_python.c:216:9: error: ‘Py_SetProgramName’ is deprecated [-Werror=deprecated-declarations]
  216 |         Py_SetProgramName(program);
      |         ^~~~~~~~~~~~~~~~~
In file included from /usr/include/python3.11/Python.h:94,
                 from lutf_python.c:1:
/usr/include/python3.11/pylifecycle.h:37:38: note: declared here
   37 | Py_DEPRECATED(3.11) PyAPI_FUNC(void) Py_SetProgramName(const wchar_t *);
      |                                      ^~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[5]: *** [Makefile:600: lutf-lutf_python.o] Error 1
test_brw.c: In function ‘main’:
test_brw.c:227:22: error: ‘write’ specified size between 9223372036854775808 and 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Werror=stringop-overflow=]
  227 |                 rc = write(fd, buf, len);
      |                      ^~~~~~~~~~~~~~~~~~~
In file included from test_brw.c:40:
/usr/include/unistd.h:378:16: note: in a call to function ‘write’ declared with attribute ‘access (read_only, 2, 3)’
  378 | extern ssize_t write (int __fd, const void *__buf, size_t __n) __wur
      |                ^~~~~
cc1: all warnings being treated as errors
Comment by Gerrit Updater [ 26/Jul/23 ]

"Jian Yu <yujian@whamcloud.com>" uploaded a new patch: https://review.whamcloud.com/c/fs/lustre-release/+/51765
Subject: LU-16980 build: fix gcc-12 [-Werror=format-truncation=] error
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: a50522f3aab56a98a9a76e47e87e92671a2c089a

Comment by Gerrit Updater [ 31/Jul/23 ]

"Jian Yu <yujian@whamcloud.com>" uploaded a new patch: https://review.whamcloud.com/c/fs/lustre-release/+/51819
Subject: LU-16980 build: fix gcc-12 [-Werror=use-after-free] error
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: 8fa48300347ac3c7dffb361d1686c434127fe3e1

Comment by Gerrit Updater [ 07/Aug/23 ]

"Oleg Drokin <green@whamcloud.com>" merged in patch https://review.whamcloud.com/c/fs/lustre-release/+/51765/
Subject: LU-16980 build: fix gcc-12 [-Werror=format-truncation=] error
Project: fs/lustre-release
Branch: master
Current Patch Set:
Commit: 347cf32326a5be282e311f140cdc850bde46176b

Comment by Gerrit Updater [ 07/Aug/23 ]

"Oleg Drokin <green@whamcloud.com>" merged in patch https://review.whamcloud.com/c/fs/lustre-release/+/51819/
Subject: LU-16980 build: fix gcc-12 [-Werror=use-after-free] error
Project: fs/lustre-release
Branch: master
Current Patch Set:
Commit: c13d919564cf6692a794fe1ceb1875971f8cde03

Comment by Peter Jones [ 07/Aug/23 ]

Landed for 2.16

Generated at Sat Feb 10 03:31:36 UTC 2024 using Jira 9.4.14#940014-sha1:734e6822bbf0d45eff9af51f82432957f73aa32c.