Subject: Daemon does not honor “useSubstitutes”on armhf

From: Timothy Sample <[email-masked]>
Date: Wed, 11 Sep 2019 14:51:07 -0400

Currently, the “guix” package cannot build on armhf due to test
failures: <https://ci.guix.gnu.org/build/1705321/details>.  (I can
confirm this on my local machine, too.)

It looks like there is some confusion about the layout of the “Settings”
struct.  At least, if I add some print statements in the code to print
the address of the “useSubstitutes” flag:

    printMsg(lvlError, format("XXX: %1%") % &settings.useSubstitutes);

it gives me different addresses depending on whether I’m printing from
the main daemon loop or from the “querySubstitutablePathInfos” method.
The addresses suspiciously differ by eight.

I can confirm that the addresses are the same on x86_64.

My guess is that this bug was revealed by the changes made in commit
f6919ebdc6b0ce0286814cc6ab0564b1a4c67f5f (making the daemon assume a
single substituter).  Before this commit, it looks like the daemon would
give up because there were no substituters.  Now it relies on checking
“useSubstitutes”, which is not in fact reliable.  I’ve tested everything
from before this commit, and the addresses are still different.

Weirdly, in GDB, I can be right before the following line:

    if (!settings.useSubstitutes) return;

run “p settings.useSubstitutes” and see “false”, and then continue
running through the method without hitting that “return”.  It seems GDB
is not confused about the flag, just the actual code.

Looking at the disassembly was no use to me, since I don’t know much
about ARM, and it was not simple enough for me to guess what it was
doing.

-- Tim