Skip to content

Commit

Permalink
Testing: Set MALLOC_PERTURB_ to 1
Browse files Browse the repository at this point in the history
The MALLOC_PERTURB_ parameter was used to initialize allocated arrays to
unphysical values.  Previously, we had set this to 256 which would
initialize bytes to 0xff, and indirectly set all floats to NaN.

However, MALLOC_PERTURB_ was undocumnted for values greater than 255,
and we were relying on undefined behavior.  In newer versions of glibc,
a value of 256 does nothing and is equivalent to a value of 0.

This patch changes the MALLOC_PERTURB_ value to 1, which sets bytes to
0xfe and tends to initialize them to an unphysically large value.

Unfortunately we have temporarily lost the ability to initialize to NaN,
but for now this is probably the best we can do.

(Note that other compilers like Intel can explicitly initialize
allocatables to NaN, so this update is more specific to the GCC
configuration of our GitHub Actions setup than the test suite.)
  • Loading branch information
marshallward committed Aug 31, 2021
1 parent df97d4f commit 91383e3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion .testing/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ $(eval $(call STAT_RULE,repro,repro,,,,1))
$(eval $(call STAT_RULE,openmp,openmp,,,GOMP_CPU_AFFINITY=0,1))
$(eval $(call STAT_RULE,layout,symmetric,,LAYOUT=2$(,)1,,2))
$(eval $(call STAT_RULE,rotate,symmetric,,ROTATE_INDEX=True\nINDEX_TURNS=1,,1))
$(eval $(call STAT_RULE,nan,symmetric,,,MALLOC_PERTURB_=256,1))
$(eval $(call STAT_RULE,nan,symmetric,,,MALLOC_PERTURB_=1,1))
$(eval $(call STAT_RULE,dim.t,symmetric,,T_RESCALE_POWER=11,,1))
$(eval $(call STAT_RULE,dim.l,symmetric,,L_RESCALE_POWER=11,,1))
$(eval $(call STAT_RULE,dim.h,symmetric,,H_RESCALE_POWER=11,,1))
Expand Down

0 comments on commit 91383e3

Please sign in to comment.