gcl-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gcl-devel] Stratified Garbage Collection


From: Camm Maguire
Subject: Re: [Gcl-devel] Stratified Garbage Collection
Date: 21 Jun 2002 18:53:49 -0400

Greetings!  OK, just to follow up on this a bit.  I have a little
program which can be run at compile time to detect whether SGC can be
enabled, and if so, how to find the fault address in the signal
handler.  I've appended a sample at the end of this note.  Here are
the results on some of the machines I have access to:

Machine kernel arch arg offset pass
===================================
auric 2.4.19-pre7 sparc 0 44 passed
lully 2.4.17 alpha 0 27 passed
vore 2.4.18 sparc 0 44 passed
caballero 2.4.9-itanium-smp ia64 0 2 passed
tippett 2.4.17 i386 0 3 passed
satie 2.4.18 i386 0 3 passed
merulo 2.4.18-itanium-smp ia64 0 2 passed
escher 2.4.17 alpha 0 27 passed
klecker 2.2.20 i386 0 48 passed
master 2.2.19 i386 0 48 passed
sarti 2.4.16-64 hppa 0 5 passed
faure 2.2.17 alpha 0 27 passed
gluck 2.4.17 i386 0 3 passed
debussy 2.4.18-rmk1 arm 0 3 passed
voltaire 2.4.18-powerpc-smp powerpc 0 3 passed
pandora 2.2.19ext3 i386 0 16 passed
repeat.rfc822.org 2.4.17 mipsel 0 3 passed
rameau 2.2.19 arm Cannot find matching offset : Success
paer 2.4.18-64 hppa 0 5 passed
kullervo 2.2.10 m68k 0 30 passed

The program can also search multiple offsets, and we find that there
are several that pass:

lully 2.4.17 alpha 0 27 passed 0 30 passed 0 97 passed 1 30 passed 1 33 passed 
2 28 passed 2 31 passed 2 98 passed
voltaire 2.4.18-powerpc-smp powerpc 0 3 passed 0 56 passed 0 88 passed 1 28 
passed 1 81 passed 2 26 passed 2 79 passed
vore 2.4.18 sparc 0 44 passed
tippett 2.4.17 i386 0 3 passed 0 48 passed 0 58 passed 1 16 passed 1 26 passed
caballero 2.4.9-itanium-smp ia64 0 2 passed 0 56 passed 1 10 passed 1 64 passed 
2 8 passed 2 62 passed
satie 2.4.18 i386 0 3 passed 0 48 passed 0 58 passed 1 16 passed 1 26 passed
escher 2.4.17 alpha 0 27 passed 0 30 passed 0 97 passed 1 30 passed 1 33 passed 
2 28 passed 2 31 passed 2 98 passed
faure 2.2.17 alpha 0 27 passed 0 30 passed 0 97 passed 1 30 passed 1 33 passed 
2 28 passed 2 31 passed 2 98 passed
klecker 2.2.20 i386 0 48 passed 0 58 passed 1 16 passed 1 26 passed
merulo 2.4.18-itanium-smp ia64 0 2 passed 0 55 passed 1 9 passed 1 62 passed 2 
7 passed 2 60 passed
sarti 2.4.16-64 hppa 0 5 passed 0 85 passed
repeat.rfc822.org 2.4.17 mipsel 0 3 passed 0 46 passed
debussy 2.4.18-rmk1 arm 0 3 passed 0 43 passed 0 57 passed
auric 2.4.19-pre7 sparc
master 2.2.19 i386 0 48 passed 0 58 passed 1 16 passed 1 26 passed
pandora 2.2.19ext3 i386 0 16 passed 0 48 passed 0 58 passed 1 16 passed 1 26 
passed
gluck 2.4.17 i386 0 3 passed 0 48 passed 0 58 passed 1 16 passed 1 26 passed
rameau 2.2.19 arm Cannot find matching offset : Success
kullervo 2.2.10 m68k 0 30 passed 0 46 passed 1 14 passed

This is either systematic or accidental, I'm not sure.  I've tried
adding randomness to the code to mix up any struct sigcontext members
that might point to registers, but the results are the same.  (Add to
this the earlier mentioned mprotect discrepancy with s390 kernel
version/)

So here are the questions:

1) Is it worth installing a program like this in configure to set the
   GET_FAULT_ADDRESS macro and SGC at compile-time?  -- I think yes,
   with the ability to override in the .h files for now.  The
   alternative is to dig into the sigcontext struct of each arch that
   we port to and write the macro by hand.

2) As these vary slightly with kernel version within a given arch, we
   probably need a runtime check too.  I do wonder about startup time
   delays, though.  I'll try to measure the impact when I get time.
   Luckily, there is already the sgc-on function that can toggle the
   behavior based on the test results.  The questions remain of how
   thorough any test need be, how large an array, how many segfaults,
   whether the array should be static or take the hit of an initial
   malloc, etc.  


Any thoughts on this whole idea and its possible implementation are
much appreciated.

Take care,

=============================================================================
#include <errno.h>
#include <unistd.h>
#include <sys/mman.h>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <signal.h>

#define NP 1024

long i,j,k,ps;
char *b1,*b;
int o1=0,o1e=3,o2=-1,o2e=100;

void
fo(int sig,char **v1) {

/*    char ***c1=(char ***)(&sig+1),***c; */

/*    if ((unsigned long)c1%sizeof(*c1)) */
/*      c1=(void *)c1+sizeof(&sig); */
  char ***c1=&v1,***c;

  for (c=c1+o1;c-c1<o1e;o2=-1,c++,o1=c-c1) {
    for (;++o2<o2e && (*c)[o2]!=b+j;);
  
    if (o2<o2e) {
      if (mprotect(b+(j&~(ps-1)),1+(j&(ps-1)),PROT_READ|PROT_WRITE)) {
        perror("cannot mprotect");
        exit(errno);
      }
      return;
    }

  }

  perror("Cannot find matching offset\n");
  exit(1);

}


void
co(int sig,char **v1) {

/*    char ***c1=(char ***)(&sig+1),***c; */

/*    if ((unsigned long)c1%sizeof(*c1)) */
/*      c1=(void *)c1+sizeof(&sig); */

  char ***c1=&v1,***c;

  c=c1+o1;

  i++;
  if ((*c)[o2]!=(b+j)) {
    printf("Mismatch: %p %p\n",(*c)[o2],(b+j));
/*      exit(1); */
    k=1;
  }

  if (mprotect(b+(j&~(ps-1)),1+(j&(ps-1)),PROT_READ|PROT_WRITE)) {
    perror("cannot mprotect");
    exit(errno);
  }

}


int
main(int argc,char * argv[]) {

  struct sigaction sa={0};
  time_t tt;
  int ii;

  if (!(ps=getpagesize())) {
    perror("Cannot get pagesize");
    return errno;
  }

  if (!(b1=malloc(ps*NP+ps-1))) {
    perror("Cannot malloc");
    return errno;
  }

  b=(char *)(((long)b1+ps-1) & ~(ps-1));

  if (mprotect(b,ps*NP,PROT_READ)) {
    perror("cannot mprotect");
    exit(errno);
  }

  srand(time(&tt));
  
  for (;;) {

    sa.sa_handler=fo;
    sa.sa_flags=SA_RESTART|SA_SIGINFO;
    sigaction(SIGSEGV,&sa,NULL);
    
    j=ps*NP*(float)rand()/RAND_MAX;

    b[j]=0;

    if (mprotect(b,ps*NP,PROT_READ)) {
      perror("cannot mprotect");
      exit(errno);
    }

    k=0;

    sa.sa_handler=co;
    sa.sa_flags=SA_RESTART|SA_SIGINFO;
    sigaction(SIGSEGV,&sa,NULL);
    
    for (i=0;i<100;) {
      
      int q;

      j=ps*NP*(float)rand()/RAND_MAX;
      
      {
        register int r1=rand();
        register int r2=rand();
        register int r3=rand();
        register int r4=rand();
        register int r5=rand();
        register int r6=rand();
        register int r7=rand();
        register int r8=rand();

        b[j]=0;

      }
      
      if (mprotect(b,ps*NP,PROT_READ)) {
        perror("cannot mprotect");
        exit(errno);
      }
      
    }

    if (!k) {
      printf("%u %u passed\n",o1,o2);
/*        return 0; */
    }

  }

  return k;

}

=============================================================================

-- 
Camm Maguire                                            address@hidden
==========================================================================
"The earth is but one country, and mankind its citizens."  --  Baha'u'llah



reply via email to

[Prev in Thread] Current Thread [Next in Thread]