Hi! I recently added unit tests upstream for explicit_bzero() to libbsd, and when uploading that into Debian, it strangely failed only on the Hurd.
https://buildd.debian.org/status/package.php?p=libbsd I've been trying to check what's happening on and off, with the temptation to simply disable the failing test on the Hurd, but not doing so due to the suspicion that there's something insidiously broken here, but I cannot see anything wrong in the unit tests itself. With the attached patch it works. Removing the second print_hex() call it stops working again. I've made the diff so that disassembled output is minimal. And I cannot see anything obviously missing from the disassembled output that would explain the misbehavior, or I'm failing to see the obvious. :/ I'm also attaching the «objdump -d» output for the broken and working unit tests. Which I compared with: $ wdiff dis.broken dis.working | colordiff | less Thanks, Guillem
diff --git i/test/explicit_bzero.c w/test/explicit_bzero.c index 74993c2..686d417 100644 --- i/test/explicit_bzero.c +++ w/test/explicit_bzero.c @@ -44,6 +44,19 @@ enum { static char *altstack; #define ALTSTACK_SIZE (SIGSTKSZ + SECRETBYTES) +static void __attribute__((__noinline__)) +print_hex(char *buf, size_t size) +{ + size_t i = 0; + + while (i < size) { + for (size_t j = 0; j < 16 && i < size; j++, i++) + printf(" %02x", (unsigned char)buf[i]); + printf("\n"); + } + fflush(stdout); +} + static void setup_stack(void) { @@ -154,7 +167,9 @@ test_with_bzero(void) char buf[SECRETBYTES]; char *res; assert_on_stack(); + print_hex(altstack, ALTSTACK_SIZE); populate_secret(buf, sizeof(buf)); + print_hex(altstack, ALTSTACK_SIZE); res = memmem(altstack, ALTSTACK_SIZE, buf, sizeof(buf)); ASSERT_NE(NULL, res); explicit_bzero(buf, sizeof(buf));
dis.broken.gz
Description: application/gzip
dis.working.gz
Description: application/gzip