OPENDAP / bes

The BES framework, which forms the basis for the Hyrax server
GNU Lesser General Public License v3.0
13 stars 19 forks source link

ASAN finds "misaligned address" problems in the fileout_netcdf module tests. #936

Open ndp-opendap opened 5 months ago

ndp-opendap commented 5 months ago

When compiled with --enable-asan the fileout_netcdf handler generates 4 test failures

207: bescmd/vdata_test.hdf.dmrpp.bescmd              FAILED (testsuite.at:320)
210: bescmd/vdata_packed_linked_blocks.hdf.dmrpp.bescmd FAILED (testsuite.at:323)
216: bescmd/PointFile.hdf.dmrpp.bescmd               FAILED (testsuite.at:329)
217: bescmd/vdata_test.hdf.bescmd                    FAILED (testsuite.at:333)
218: bescmd/vdata_packed_linked_blocks.hdf.bescmd    FAILED (testsuite.at:334)

These errors are all of the same nature: runtime error: load of misaligned address

Is this a design issue arising from using void * or is this a usage issue in the way that the fileout_netcdf is allocating memory?

Or is this problem caused by allocating variable memory as byte/char rather than unit32_t etc.??

Examine and fix if feasible.

Here is the verbose test output for the failed tests:

[-bash: ~/OPeNDAP/hyrax/bes/modules/fileout_netcdf/tests] ./testsuite -v 207 210 216 217 218
## -------------------------------------------------------------- ##
## bes 3.21.0 test suite: modules/fileout_netcdf/tests testsuite. ##
## -------------------------------------------------------------- ##
207. testsuite.at:320: testing bescmd/vdata_test.hdf.dmrpp.bescmd ...
COMMAND: besstandalone  -c bes.nc4.grp.conf -i bescmd/vdata_test.hdf.dmrpp.bescmd
./testsuite.at:320: besstandalone -c $abs_builddir/$bes_conf -i $input > test.nc
--- /dev/null   2024-05-30 11:28:15
+++ /Users/ndp/OPeNDAP/hyrax/bes/modules/fileout_netcdf/tests/testsuite.dir/at-groups/207/stderr    2024-05-30 11:28:16
@@ -0,0 +1,25 @@
+Float32.cc:187:13: runtime error: load of misaligned address 0x611000006a86 for type 'dods_float32' (aka 'float'), which requires 4 byte alignment
+0x611000006a86: note: pointer points here
+ 8e 3f 00 00 7b 14  8e 3f 41 61 30 3f 80 00  00 40 00 00 00 40 0e 14  7b 00 01 40 0e 14 7b 42  62 31
+             ^ 
+SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Float32.cc:187:13 in 
+DmrppStructure.cc:154:26: runtime error: load of misaligned address 0x611000006a99 for type 'dods_uint16' (aka 'unsigned short'), which requires 2 byte alignment
+0x611000006a99: note: pointer points here
+ 7b 14 0e  40 00 01 40 0e 14 7b 42  62 31 3f 80 00 00 40 00  00 00 40 55 1e b8 00 02  40 55 1e b8 43
+              ^ 
+SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior DmrppStructure.cc:154:26 in 
+DmrppStructure.cc:154:26: runtime error: load of misaligned address 0x611000006a99 for type 'dods_uint16' (aka 'unsigned short'), which requires 2 byte alignment
+0x611000006a99: note: pointer points here
+ 7b 14 0e  40 00 01 40 0e 14 7b 42  62 31 3f 80 00 00 40 00  00 00 40 55 1e b8 00 02  40 55 1e b8 43
+              ^ 
+SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior DmrppStructure.cc:154:26 in 
+DmrppStructure.cc:154:17: runtime error: store to misaligned address 0x611000006a99 for type 'dods_uint16' (aka 'unsigned short'), which requires 2 byte alignment
+0x611000006a99: note: pointer points here
+ 7b 14 0e  40 00 01 40 0e 14 7b 42  62 31 3f 80 00 00 40 00  00 00 40 55 1e b8 00 02  40 55 1e b8 43
+              ^ 
+SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior DmrppStructure.cc:154:17 in 
+Int16.cc:180:13: runtime error: load of misaligned address 0x611000006a99 for type 'dods_int16' (aka 'short'), which requires 2 byte alignment
+0x611000006a99: note: pointer points here
+ 7b 14 0e  40 01 00 40 0e 14 7b 42  62 31 3f 80 00 00 40 00  00 00 40 55 1e b8 00 02  40 55 1e b8 43
+              ^ 
+SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Int16.cc:180:13 in 
207. testsuite.at:320:  FAILED (testsuite.at:320)

210. testsuite.at:323: testing bescmd/vdata_packed_linked_blocks.hdf.dmrpp.bescmd ...
COMMAND: besstandalone  -c bes.nc4.grp.conf -i bescmd/vdata_packed_linked_blocks.hdf.dmrpp.bescmd
./testsuite.at:323: besstandalone -c $abs_builddir/$bes_conf -i $input > test.nc
--- /dev/null   2024-05-30 11:28:15
+++ /Users/ndp/OPeNDAP/hyrax/bes/modules/fileout_netcdf/tests/testsuite.dir/at-groups/210/stderr    2024-05-30 11:28:17
@@ -0,0 +1,5 @@
+Float32.cc:187:13: runtime error: load of misaligned address 0x60300002a0d6 for type 'dods_float32' (aka 'float'), which requires 4 byte alignment
+0x60300002a0d6: note: pointer points here
+ 8e 3f 00 00 7b 14  0e 40 00 01 3f 8e 14 7b  00 00 40 0e 14 7b 00 01  00 00 00 00 00 00 00 00  02 02
+             ^ 
+SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Float32.cc:187:13 in 
210. testsuite.at:323:  FAILED (testsuite.at:323)

216. testsuite.at:329: testing bescmd/PointFile.hdf.dmrpp.bescmd ...
COMMAND: besstandalone  -c bes.nc4.grp.conf -i bescmd/PointFile.hdf.dmrpp.bescmd
./testsuite.at:329: besstandalone -c $abs_builddir/$bes_conf -i $input > test.nc
--- /dev/null   2024-05-30 11:28:15
+++ /Users/ndp/OPeNDAP/hyrax/bes/modules/fileout_netcdf/tests/testsuite.dir/at-groups/216/stderr    2024-05-30 11:28:18
@@ -0,0 +1,5 @@
+Float64.cc:185:13: runtime error: load of misaligned address 0x61400000465c for type 'dods_float64' (aka 'double'), which requires 8 byte alignment
+0x61400000465c: note: pointer points here
+  43 4f 00 00 9a 99 99 25  1c 35 86 41 40 7f 5c 29  40 90 a3 d7 40 16 66 66  40 21 47 ae 43 4f 32 00
+              ^ 
+SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Float64.cc:185:13 in 
216. testsuite.at:329:  FAILED (testsuite.at:329)

217. testsuite.at:333: testing bescmd/vdata_test.hdf.bescmd ...
COMMAND: besstandalone  -c bes.nc4.grp.conf -i bescmd/vdata_test.hdf.bescmd
./testsuite.at:333: besstandalone -c $abs_builddir/$bes_conf -i $input > test.nc
--- /dev/null   2024-05-30 11:28:18
+++ /Users/ndp/OPeNDAP/hyrax/bes/modules/fileout_netcdf/tests/testsuite.dir/at-groups/217/stderr    2024-05-30 11:28:18
@@ -0,0 +1,10 @@
+Float32.cc:187:13: runtime error: load of misaligned address 0x611000006f86 for type 'dods_float32' (aka 'float'), which requires 4 byte alignment
+0x611000006f86: note: pointer points here
+ 8e 3f 00 00 7b 14  8e 3f 41 61 30 00 00 80  3f 00 00 00 40 7b 14 0e  40 01 00 7b 14 0e 40 42  62 31
+             ^ 
+SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Float32.cc:187:13 in 
+Int16.cc:180:13: runtime error: load of misaligned address 0x611000006f99 for type 'dods_int16' (aka 'short'), which requires 2 byte alignment
+0x611000006f99: note: pointer points here
+ 7b 14 0e  40 01 00 7b 14 0e 40 42  62 31 00 00 80 3f 00 00  00 40 b8 1e 55 40 02 00  b8 1e 55 40 43
+              ^ 
+SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Int16.cc:180:13 in 
217. testsuite.at:333:  FAILED (testsuite.at:333)

218. testsuite.at:334: testing bescmd/vdata_packed_linked_blocks.hdf.bescmd ...
COMMAND: besstandalone  -c bes.nc4.grp.conf -i bescmd/vdata_packed_linked_blocks.hdf.bescmd
./testsuite.at:334: besstandalone -c $abs_builddir/$bes_conf -i $input > test.nc
--- /dev/null   2024-05-30 11:28:19
+++ /Users/ndp/OPeNDAP/hyrax/bes/modules/fileout_netcdf/tests/testsuite.dir/at-groups/218/stderr    2024-05-30 11:28:19
@@ -0,0 +1,5 @@
+Float32.cc:187:13: runtime error: load of misaligned address 0x60300002a8e6 for type 'dods_float32' (aka 'float'), which requires 4 byte alignment
+0x60300002a8e6: note: pointer points here
+ 8e 3f 00 00 7b 14  0e 40 01 00 7b 14 8e 3f  00 00 7b 14 0e 40 01 00  00 00 00 00 00 00 00 00  03 02
+             ^ 
+SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Float32.cc:187:13 in 
218. testsuite.at:334:  FAILED (testsuite.at:334)

## ------------- ##
## Test results. ##
## ------------- ##

ERROR: All 5 tests were run,
5 failed unexpectedly.
## -------------------------- ##
## testsuite.log was created. ##
## -------------------------- ##

Please send `modules/fileout_netcdf/tests/testsuite.log' and all information you think might help:

   To: <support@opendap.org>
   Subject: [bes 3.21.0] testsuite: 207 210 216 217 218 failed

You may investigate any problem if you feel able to do so, in which
case the test suite provides a good starting point.  Its output may
be found below `modules/fileout_netcdf/tests/testsuite.dir'.

[-bash: ~/OPeNDAP/hyrax/bes/modules/fileout_netcdf/tests]