On Mon 2015-09-14 12:24:45 -0400, Kurt Roeckx wrote:
> On Mon, Sep 14, 2015 at 09:47:25AM -0400, Daniel Kahn Gillmor wrote:
>> On Sun 2015-09-13 17:23:01 -0400, Kurt Roeckx wrote:
>> > On Sun, Sep 13, 2015 at 05:08:52PM -0400, Daniel Kahn Gillmor wrote:
>> >> In the meantime, is it possible to give gnupg2 2.1.8-1 back to a
>> >> different amd64 buildd (brahms and x86-grnet-01 both have worked in the
>> >> past) so that the package can propagate through the archive?
>> >
>> > Given back, but I don't control on which buildd it's going to end
>> > up.
>> 
>> Thanks, this resolved it by building 2.1.8-1 cleanly on x86-grnet-01.
>> 
>> It's not clear to me what the problem is with x86-csail-01 -- is there
>> some way that we can diagnose this buildd better?  it seems to be
>> repeatable over time :/
>
> I can run tests on it if needed.

It looks to me like the hang is happening in the code that calibrates
the s2k count in the agent. (from agent/protect.c)

I've tried to extract the logic from this code and make a simple
executable that just does it (without invoking gcrypt or anything else
-- it's just calibrating cpu cycles and walltime clocks.

Running it locally for me looks like this:

0 dkg@alice:~/src/pkg-gnupg/bugs/789246$ make
gcc -Wall -Werror --pedantic -o test-csail test-csail.c
0 dkg@alice:~/src/pkg-gnupg/bugs/789246$ ./test-csail 
S2K calibration: 2 -> 20ms
S2K calibration: 4 -> 30ms
S2K calibration: 8 -> 40ms
S2K calibration: 16 -> 70ms
S2K calibration: 32 -> 100ms
S2K calibration: 64 -> 180ms
S2K calibration: 35 -> 80ms
x: 35
0 dkg@alice:~/src/pkg-gnupg/bugs/789246$

I'm attaching it here.  Can you try compiling and running it on
x86-csail-01 and letting me know what happens?

Thanks,

        --dkg

#include <time.h>
#include <sys/times.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>

/* Daniel Kahn Gillmor <d...@fifthhorseman.net>

   Code extracted for testing from calibration routines in GnuPG's
   agent/protect.c 

   see https://bugs.debian.org/789246 
*/

struct calibrate_time_s
{
  clock_t ticks;
};

static void BUG()
{
  exit(2);
}

static void
calibrate_get_time (struct calibrate_time_s *data)
{
  struct tms tmp;

  times (&tmp);
  data->ticks = tmp.tms_utime;
}


static unsigned long
calibrate_elapsed_time (struct calibrate_time_s *starttime)
{
  struct calibrate_time_s stoptime;

  calibrate_get_time (&stoptime);

  return (unsigned long)((((double) (stoptime.ticks - starttime->ticks))
                          /CLOCKS_PER_SEC)*10000000);
}

static int
burn_cycles(unsigned long count)
{
  int i, a = 0;
  while (count--) {
    for (i = 0; i < 1000000; i++) {
      a = a + i;
    }
  }
  return 0;
}

/* Run a test hashing for COUNT and return the time required in
   milliseconds.  */
static unsigned long
calibrate_s2k_count_one (unsigned long count)
{
  int rc;
  struct calibrate_time_s starttime;

  calibrate_get_time (&starttime);

  rc = burn_cycles(count);
  if (rc)
    BUG ();
  return calibrate_elapsed_time (&starttime);
}

/* Measure the time we need to do the hash operations and deduce an
   S2K count which requires about 100ms of time.  */
static unsigned long
calibrate_s2k_count (void)
{
  unsigned long count;
  unsigned long ms;

  for (count = 2; count; count *= 2)
    {
      ms = calibrate_s2k_count_one (count);
      printf ("S2K calibration: %lu -> %lums\n", count, ms);
      if (ms > 100)
        break;
    }

  count = (unsigned long)(((double)count / ms) * 100);

  ms = calibrate_s2k_count_one (count);
  printf ("S2K calibration: %lu -> %lums\n", count, ms);

  return count;
}


int main(int argc, const char* argv[])
{
  unsigned long x = 0;
  x = calibrate_s2k_count();
  printf("x: %lu\n", x);
  return 0;
}

Attachment: signature.asc
Description: PGP signature

Reply via email to