nasa-jpl / ION-DTN

NASA Open Source ION Software implementation of Delay Tolerant Networking. ION development is managed by the Jet Propulsion Lab; regression testing and code management are provided by Ohio University.
https://nasa-jpl.github.io/ION-DTN/
Other
22 stars 5 forks source link

SF: SJ: Memory related bugs found by gcc-12 #2

Closed iondev33 closed 6 months ago

iondev33 commented 9 months ago

Two bugs, one in ici/library/memmgr.c and one in ici/sdr/sdrxn.c became apparent during regression testing for IONe-1.0.0 and IONe-1.0.1. These bugs prevent compilation with gcc-12 using autotools for build configuration on Debian Bookworm. Attached are error outputs from the compilation process, and the associated fixes in code snippets showing comparison between existing ION-DTN-4.1.2 code and patched IONe-1.0.1 code.

/bin/bash ./libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I./ici/library -I./ici/crypto -I./bpv7/library -I./ltp/library -I./ici/test -I./ici/sdr -I./ici/libbloom-master -I./ici/libbloom-master/murmur2 -Dlinux -DSPACE_ORDER=3 -fno-strict-aliasing -DVNAME=ION-OPEN-SOURCE-4.1.2 -DBUILD_BPv7 -DENABLE_IMC -DENABLE_MANPAGES -g -include config.h -I./ici/include -I./ltp/include -I./dgr/include -I./bpv7/include -I./tc/include -I./bss/include -I./dtpc/include -I./bssp/include -DSBSP -I./ams/include -I./cfdp/include -Wall -fPIC -Werror -g -O2 -DNOEXPAT -MT ici/library/libici_la-memmgr.lo -MD -MP -MF ici/library/.deps/libici_la-memmgr.Tpo -c -o ici/library/libici_la-memmgr.lo test -f 'ici/library/memmgr.c' || echo './'ici/library/memmgr.c
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I./ici/library -I./ici/crypto -I./bpv7/library -I./ltp/library -I./ici/test -I./ici/sdr -I./ici/libbloom-master -I./ici/libbloom-master/murmur2 -Dlinux -DSPACE_ORDER=3 -fno-strict-aliasing -DVNAME=ION-OPEN-SOURCE-4.1.2 -DBUILD_BPv7 -DENABLE_IMC -DENABLE_MANPAGES -g -include config.h -I./ici/include -I./ltp/include -I./dgr/include -I./bpv7/include -I./tc/include -I./bss/include -I./dtpc/include -I./bssp/include -DSBSP -I./ams/include -I./cfdp/include -Wall -fPIC -Werror -g -O2 -DNOEXPAT -MT ici/library/libici_la-memmgr.lo -MD -MP -MF ici/library/.deps/libici_la-memmgr.Tpo -c ici/library/memmgr.c -fPIC -DPIC -o ici/library/.libs/libici_la-memmgr.o
In function '_mem_mgrs',
inlined from 'memmgr_name' at ici/library/memmgr.c:235:6:
ici/library/memmgr.c:115:29: error: argument 2 null where non-null expected [-Werror=nonnull]
115 | if (strcmp(mgr->name, name) != 0)
| ^~~~~~~~~~~~~~~~~~~~~~~
In file included from ./ici/include/platform.h:232,
from ici/library/memmgr.c:18:
/usr/include/string.h: In function 'memmgr_name':
/usr/include/string.h:156:12: note: in a call to function 'strcmp' declared 'nonnull'
156 | extern int strcmp (const char __s1, const char __s2)
| ^~~~~~
In function '_mem_mgrs',
inlined from 'memmgr_take' at ici/library/memmgr.c:248:6:
ici/library/memmgr.c:115:29: error: argument 2 null where non-null expected [-Werror=nonnull]
115 | if (strcmp(mgr->name, name) != 0)
| ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/string.h: In function 'memmgr_take':
/usr/include/string.h:156:12: note: in a call to function 'strcmp' declared 'nonnull'
156 | extern int strcmp (const char __s1, const char __s2)
| ^~~~~~
In function '_mem_mgrs',
inlined from 'memmgr_release' at ici/library/memmgr.c:261:6:
ici/library/memmgr.c:115:29: error: argument 2 null where non-null expected [-Werror=nonnull]
115 | if (strcmp(mgr->name, name) != 0)
| ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/string.h: In function 'memmgr_release':
/usr/include/string.h:156:12: note: in a call to function 'strcmp' declared 'nonnull'
156 | extern int strcmp (const char __s1, const char __s2)
| ^~~~~~
In function '_mem_mgrs',
inlined from 'memmgr_AtoP' at ici/library/memmgr.c:274:6:
ici/library/memmgr.c:115:29: error: argument 2 null where non-null expected [-Werror=nonnull]
115 | if (strcmp(mgr->name, name) != 0)
| ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/string.h: In function 'memmgr_AtoP':
/usr/include/string.h:156:12: note: in a call to function 'strcmp' declared 'nonnull'
156 | extern int strcmp (const char __s1, const char __s2)
| ^~~~~~
In function '_mem_mgrs',
inlined from 'memmgr_PtoA' at ici/library/memmgr.c:287:6:
ici/library/memmgr.c:115:29: error: argument 2 null where non-null expected [-Werror=nonnull]
115 | if (strcmp(mgr->name, name) != 0)
| ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/string.h: In function 'memmgr_PtoA':
/usr/include/string.h:156:12: note: in a call to function 'strcmp' declared 'nonnull'
156 | extern int strcmp (const char __s1, const char __s2)
| ^~~~~~
cc1: all warnings being treated as errors
make[2]: *** [Makefile:11853: ici/library/libici_la-memmgr.lo] Error 1
make[2]: Leaving directory '/home/scott/ion-4.1.2-error-reporting'
make[1]: *** [Makefile:17506: all-recursive] Error 1
make[1]: Leaving directory '/home/scott/ion-4.1.2-error-reporting'
make: *** [Makefile:6423: all] Error 2

ION-DTN-4.1.2 ici/library/memmgr.c

115 if (strcmp(mgr->name, name) != 0)
116 {
117 continue;
118 }
119
120 / Found the named memory manager. /
121

IONe-1.0.1 ici/library/memmgr.c

115 if (name == NULL)
116 {
117 name = "0";
118 }
119
120 if (strcmp(mgr->name, name) != 0)
121 {
122 continue;
123 }
124
125 / Found the named memory manager. /
126

/bin/bash ./libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I./ici/library -I./ici/crypto -I./bpv7/library -I./ltp/library -I./ici/test -I./ici/sdr -I./ici/libbloom-master -I./ici/libbloom-master/murmur2 -Dlinux -DSPACE_ORDER=3 -fno-strict-aliasing -DVNAME=ION-OPEN-SOURCE-4.1.2 -DBUILD_BPv7 -DENABLE_IMC -DENABLE_MANPAGES -g -include config.h -I./ici/include -I./ltp/include -I./dgr/include -I./bpv7/include -I./tc/include -I./bss/include -I./dtpc/include -I./bssp/include -DSBSP -I./ams/include -I./cfdp/include -Wall -fPIC -Werror -g -O2 -DNOEXPAT -MT ici/sdr/libici_la-sdrxn.lo -MD -MP -MF ici/sdr/.deps/libici_la-sdrxn.Tpo -c -o ici/sdr/libici_la-sdrxn.lo test -f 'ici/sdr/sdrxn.c' || echo './'ici/sdr/sdrxn.c
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I./ici/library -I./ici/crypto -I./bpv7/library -I./ltp/library -I./ici/test -I./ici/sdr -I./ici/libbloom-master -I./ici/libbloom-master/murmur2 -Dlinux -DSPACE_ORDER=3 -fno-strict-aliasing -DVNAME=ION-OPEN-SOURCE-4.1.2 -DBUILD_BPv7 -DENABLE_IMC -DENABLE_MANPAGES -g -include config.h -I./ici/include -I./ltp/include -I./dgr/include -I./bpv7/include -I./tc/include -I./bss/include -I./dtpc/include -I./bssp/include -DSBSP -I./ams/include -I./cfdp/include -Wall -fPIC -Werror -g -O2 -DNOEXPAT -MT ici/sdr/libici_la-sdrxn.lo -MD -MP -MF ici/sdr/.deps/libici_la-sdrxn.Tpo -c ici/sdr/sdrxn.c -fPIC -DPIC -o ici/sdr/.libs/libici_la-sdrxn.o
In function '_sdrwm',
inlined from 'sdr_shutdown' at ici/sdr/sdrxn.c:533:3:
ici/sdr/sdrxn.c:305:26: error: 'wmparms.wmKey' may be used uninitialized [-Werror=maybe-uninitialized]
305 | if (parms->wmKey == -11111 )
| ~~~~~^~~~~~~
ici/sdr/sdrxn.c: In function 'sdr_shutdown':
ici/sdr/sdrxn.c:528:25: note: 'wmparms' declared here
528 | sm_WmParms wmparms;
| ^~~~~~~
cc1: all warnings being treated as errors
make[2]: *** [Makefile:11965: ici/sdr/libici_la-sdrxn.lo] Error 1
make[2]: Leaving directory '/home/scott/ion-4.1.2-error-reporting'
make[1]: *** [Makefile:17506: all-recursive] Error 1
make[1]: Leaving directory '/home/scott/ion-4.1.2-error-reporting'
make: *** [Makefile:6423: all] Error 2

ION-DTN-4.1.2

526 void sdr_shutdown() / Ends SDR service on machine. /
527 {
528 sm_WmParms wmparms;
529
530 if (_sdrwm(NULL) != NULL)
531 {
532 wmparms.wmName = NULL;
533 oK(_sdrwm(&wmparms));
534 }

IONe-1.0.1

526 void sdr_shutdown() / Ends SDR service on machine. /
527 {
528 sm_WmParms wmparms;
529
530 if (_sdrwm(NULL) != NULL)
531 {
532 wmparms.wmkey = 0;
533 wmparms.wmSize = 0;
534 wmparms.wmAddress = NULL;
535 wmparms.wmName = NULL;
536 oK(_sdrwm(&wmparms));
537 }
type6six commented 6 months ago

Thank you for posting these issues and the recommended fixes.

They will be released as part of ION 4.1.3. Thank you!