I've seen inexplicable nondeterminism like this before, and quite often it's turned out to be controlled by the total size of the command line argument area (that is, argv + environ + ELF auxv). Changes in how big that is change the initial stack pointer address, and while that *shouldn't* matter to anything, sometimes it does.
A shell loop of the form
export X=
i=0
while [ i -lt 8192 ]; do
perform test
X=${X}x
i=$((i+1))
done
should catch it if this is the cause.
