On Thu, Mar 11, 2004 at 10:33:24PM +0100, Leopold Toetsch wrote:
> Nicholas Clark <[EMAIL PROTECTED]> wrote:
> 
> > If parrot's garbage collector is changed from the default (compacting, IIRC)
> > to the either libc or malloc, then ponie only fails 6 tests.
> 
> > As I understand it parrot's default garbage collector will move data blocks
> > owned by PMCs. However, all of the PMCs ponie generates do not have gc-owned
> > data attached to them, so there should be no difference.
> 
> Sure?
> No PerlHash, PerlArray, PerlString?
> No pointers to string's data?
> ...
> All PMCs are anchored properly?

Yes. Arthur and I got it down to the appended test case, which is pure C
embedding and extending parrot.

> Anyway, to sort out this kind of bugs please provide for ponie two
> command line options with these equivalents in imcc/main.c:
> 
>     "    -G --no-gc\n"
>     "       --gc-debug\n"
> 
> Please UTSL for details. The first turns off DOD & GC, the second enables
> a switch GC_DEBUG (for which there is an envirnonment setting too:
> 
>     if (is_env_var_set("PARROT_GC_DEBUG"))
> 
> Turning off DOD/GC normally shows, if the error is related to that.
> Turning on GC_DEBUG does more DODs, e.g. in each string_compare that is
> anywhere, where a hash is searched for example.

I hacked this into the ponie source directly for testing. With GC disabled
on the default GC ponie only fails 4 tests (two related to exit codes of ``)

However, the appended test program will segfault (by default) eg:

$ valgrind ./stress_parrot 5000
==9478== Memcheck, a memory error detector for x86-linux.
==9478== Copyright (C) 2002-2003, and GNU GPL'd, by Julian Seward.
==9478== Using valgrind-2.1.0, a program supervision framework for x86-linux.
==9478== Copyright (C) 2000-2003, and GNU GPL'd, by Julian Seward.
==9478== Estimated CPU clock rate is 2802 MHz
==9478== For more details, rerun with: -v
==9478== 
==9478== warning: Valgrind's pthread_attr_destroy does nothing
==9478==          your program may misbehave as a result
==9478== warning: Valgrind's pthread_attr_destroy does nothing
==9478==          your program may misbehave as a result
Hello world
==9478== Conditional jump or move depends on uninitialised value(s)
==9478==    at 0x805A17F: compact_pool (src/resources.c:301)
==9478==    by 0x8059F64: mem_allocate (src/resources.c:149)
==9478==    by 0x805A61E: Parrot_reallocate (src/resources.c:500)
==9478==    by 0x807227B: expand_hash (src/hash.c:529)
==9478== 
==9478== Conditional jump or move depends on uninitialised value(s)
==9478==    at 0x805A17F: compact_pool (src/resources.c:301)
==9478==    by 0x8059F64: mem_allocate (src/resources.c:149)
==9478==    by 0x805A848: Parrot_allocate_string (src/resources.c:634)
==9478==    by 0x806B694: string_make (src/string.c:379)
==9478== 
==9478== Invalid read of size 4
==9478==    at 0x80A2D8C: get_free_object (src/smallobject.c:226)
==9478==    by 0x8050A43: get_free_buffer (src/headers.c:87)
==9478==    by 0x8050E11: new_string_header (src/headers.c:330)
==9478==    by 0x806B645: string_make (src/string.c:367)
==9478==  Address 0x44DF0BEC is not stack'd, malloc'd or free'd
==9478== 
==9478== Process terminating with default action of signal 11 (SIGSEGV): dumping core
==9478==  Address not mapped to object at address 0x44DF0BEC
==9478==    at 0x80A2D8C: get_free_object (src/smallobject.c:226)
==9478==    by 0x8050A43: get_free_buffer (src/headers.c:87)
==9478==    by 0x8050E11: new_string_header (src/headers.c:330)
==9478==    by 0x806B645: string_make (src/string.c:367)
==9478== 
==9478== ERROR SUMMARY: 6177 errors from 3 contexts (suppressed: 0 from 0)
==9478== malloc/free: in use at exit: 4704588 bytes in 129 blocks.
==9478== malloc/free: 135 allocs, 6 frees, 5087348 bytes allocated.
==9478== For a detailed leak analysis,  rerun with: --leak-check=yes
==9478== For counts of detected errors, rerun with: -v
Segmentation fault


It crashes sooner (need less PMCs) with GC debugging turned on (quelle
surprise), and doesn't crash with GC disabled.

Neither Arthur nor myself know where to start in debugging parrot's GC.

Nicholas Clark


/* Needed to turn off GC */
#if 0
#include "parrot/parrot.h"
#endif

#include "parrot/embed.h"
#include "parrot/extend.h"
#include <stdio.h>
#include <stdlib.h>


Parrot_PMC make_a_pmc(Parrot_Interp interpreter) {
  Parrot_Int  type = Parrot_PMC_typenum(interpreter, "Integer");
  Parrot_PMC  p;

  p = Parrot_PMC_new(interpreter, type);
  Parrot_register_pmc(interpreter, p);
  return p;
}

int main (int argc, char**argv) {
  int count;
  Parrot_Interp interpreter = Parrot_new(0);
  Parrot_init(interpreter);

#if 0
  /* Turn off GC  */
  interpreter->DOD_block_level++;
  interpreter->GC_block_level++;
#endif

  if (argc > 1) {
    count = atoi(argv[1]);
  } else {
    count = 1000000;
  }
  printf ("Hello world\n");
  while (count--) {
    make_a_pmc(interpreter);
  }

  printf ("Goodbye world\n");

  return 0;
}

/* Compile with
  gcc -Iinclude -Wall -o stress_parrot stress_parrot.c blib/lib/libparrot.a
  -lm -ldl -lpthread # Don't need these on *BSD :-)
*/

Reply via email to