On Mon, Dec 16, 2013 at 07:58:06PM +0100, Tobias Leich wrote:
> I don't think they can move...
> 
> value_obj is only used from its assignment to before an allocation. Same
> goes for base_obj.

[reply below because I think that it makes more sense]

> Am 15.12.2013 21:50, schrieb Nicholas Clark:
> > On Sun, Dec 15, 2013 at 05:56:40PM +0000, Nicholas Clark wrote:
> >
> >> With this, all NQP tests pass I can build the Rakudo setting, with a 
> >> nursery
> >> size of 2048K.
> >>
> >> I have now written a script that will attempt to repeatedly recompile that
> >> far, each time dropping the nursery size by 1K, until something breaks.
> >> I shall nice it appropriately, and if it still going tomorrow, try again
> >> with a larger decrement, until something does fail.
> > Hit at 2047.
> >
> > (gdb) where
> > #0  0x00007ffff7a3360b in mp_copy (a=0x7fffffffd2e0, b=0x7ffff6a91ba8)
> >     at 3rdparty/libtommath/bn_mp_copy.c:30
> > #1  0x00007ffff7a2f111 in MVM_bigint_radix (tc=0x6023f0, radix=10, 
> >     str=0x7ffff6a983c0, offset=1, flag=2, type=0x1588110)
> >     at src/math/bigintops.c:396
> > #2  0x00007ffff79a35ff in MVM_interp_run (tc=0x6023f0, 
> >     initial_invoke=0x7ffff7a2fac3 <toplevel_initial_invoke>, 
> >     invoke_data=0x6676c0) at src/core/interp.c:1891
> > #3  0x00007ffff7a2fbf0 in MVM_vm_run_file (instance=0x602010, 
> >     filename=0x7fffffffe7c0 "perl6.moarvm") at src/moar.c:157
> > #4  0x0000000000400d2e in main (argc=9, argv=0x7fffffffe4d8) at 
> > src/main.c:137
> >
> > b is in fromspace
> >
> > Lines 367 onwards of bigintops.c:
> >
> >     value_obj = MVM_repr_alloc_init(tc, type);
> >     MVM_repr_push_o(tc, result, value_obj);
> >
> >     value = get_bigint(tc, value_obj);
> >
> >     base_obj = MVM_repr_alloc_init(tc, type);
> >     MVM_repr_push_o(tc, result, base_obj);
> >
> >     base = get_bigint(tc, base_obj);
> >
> >
> >
> > I think that value_obj is getting moved.
> > I presume that base_obj could get moved too.

Here is my single-stepping in gdb. It shows that `value` is pointing to
memory within the nursery, and that the call to MVM_repr_alloc_init() is
another allocation from the nursery. Hence that allocation call could
trigger a nursery collection between when `value` is assigned, and when it
is used. Yes, agree, `value_obj` isn't used again. But it's not the problem
here. Sorry if I wasn't clear before.


Stage start      :   0.000

Breakpoint 1, MVM_bigint_radix (tc=0x6023f0, radix=10, str=0x7ffff6beaae0, 
    offset=0, flag=2, type=0x1589ea0) at src/math/bigintops.c:370
370         value = get_bigint(tc, value_obj);
Missing separate debuginfos, use: debuginfo-install glibc-2.12-1.107.el6.x86_64
(gdb) p tc->nursery_tospace
$1 = (void *) 0x7ffff6a92010
(gdb) p tc->nursery_fromspace
$2 = (void *) 0x7ffff6891010
(gdb) p tc->nursery_alloc
$3 = (void *) 0x7ffff6beb040
(gdb) p value_obj
$4 = (MVMObject *) 0x7ffff6beb000
(gdb) p sizeof(*value_obj)
$5 = 32
(gdb) n
372         base_obj = MVM_repr_alloc_init(tc, type);
(gdb) p value
$6 = (mp_int *) 0x7ffff6beb028
(gdb) p tc->nursery_alloc-(void *)value_obj
$7 = 64
(gdb) p tc->nursery_alloc-(void *)type
$8 = 140737310495136
(gdb) p tc->nursery_alloc-(void *)value
$9 = 24
(gdb) s
MVM_repr_alloc_init (tc=0x6023f0, type=0x1589ea0) at src/6model/reprconv.c:13
13          MVMObject *obj = REPR(type)->allocate(tc, STABLE(type));
(gdb) s
allocate (tc=0x6023f0, st=0x156be80) at src/6model/reprs/P6opaque.c:110
110         if (st->size)
(gdb) s
111             return MVM_gc_allocate_object(tc, st);
(gdb) s
MVM_gc_allocate_object (tc=0x6023f0, st=0x156be80) at src/gc/allocation.c:85
85          MVMROOT(tc, st, {
(gdb) s
MVM_gc_root_temp_push (tc=0x6023f0, obj_ref=0x7fffffffd200)
    at src/gc/roots.c:91
91          if (obj_ref == NULL)
(gdb) 
95          if (tc->num_temproots == tc->alloc_temproots) {
(gdb) 
102         tc->temproots[tc->num_temproots] = obj_ref;
(gdb) 
103         tc->num_temproots++;
(gdb) 
104     }
(gdb) 
MVM_gc_allocate_zeroed (tc=0x6023f0, size=64) at src/gc/allocation.c:49
49          return MVM_gc_allocate(tc, size);
(gdb) 
MVM_gc_allocate_nursery (tc=0x6023f0, size=64) at src/gc/allocation.c:17
17          if (tc->gc_status)
(gdb) 
21          if (size > 0) {
(gdb) 
29              while ((char *)tc->nursery_alloc + size >= (char 
*)tc->nursery_alloc_limit) {

Nicholas Clark

Reply via email to