[M3devel] small bug report

Rodney M. Bates rodney_bates at lcwb.coop
Sat Jul 26 18:04:21 CEST 2014


I can't reproduce this with cm3, AMD64_LINUX. The ASSERT does not fail,
and I get:

Breakpoint 1, P (el=11) at ../src/Main.m3:34
34	      <*ASSERT nd.ns = 0 *>
Current language:  auto; currently Modula-3
(m3gdb) p nd.ns
$1 = 0
(m3gdb)


The only things I did were to declare Elem and TStamp as CARDINAL,
and put the allocator and ASSERT in a procedure, with el passed in.

On 07/26/2014 06:20 AM, mika at async.caltech.edu wrote:
> Hi m3devel,
>
> So I realized that the reason my program runs slowly is not that there
> are a lot of range checks, etc.
>
> (BTW, changing M3_FRONT_FLAGS in cm3.cfg did manage to turn off these
> checks as far as I can see, thanks!)
>
> The problem is that the garbage collector involves procedure calls
> whenever loading references.  This is no good if you are running a tight
> inner loop that chases pointers all over the heap.
>
> My attempt at fixing this is to change the code to use UNTRACED REF for this
> particular chunk, with DISPOSE.  It's a small, simple part of the code, so this
> is a good use case for the UNSAFE Modula-3 features.
>
> I found a bug, though:
>
> consider:
>
> TYPE
>    Node = UNTRACED ROOT OBJECT
>      id   : Elem;
>
>      np : CARDINAL := 0;
>      pred : UNTRACED REF ARRAY OF Node;
>
>      ns : CARDINAL := 0;
>      succ : UNTRACED REF ARRAY OF Node;
>      sDly : UNTRACED REF ARRAY OF TStamp;
>
>      when : TStamp;    (* max of all fanins observed *)
>      whch : Node;      (* which fanin was critical   *)
>
>      gen  : CARDINAL := 0; (* generation of cnt *)
>      cnt  : CARDINAL;  (* how many fanins are left   *)
>    END;
>
> ...
>
>        nd := NEW(Node,
>                   id := el,
>                   pred := NEW(UNTRACED REF ARRAY OF Node, 1),
>                   succ := NEW(UNTRACED REF ARRAY OF Node, 1),
>                   sDly := NEW(UNTRACED REF ARRAY OF TStamp, 1),
>                   cnt := 0);
>        <*ASSERT nd.ns = 0 *>
>
> That ASSERT fails.
>
> The code works on PM3 (FreeBSD4), as expected.  (It works fine with
> everything being traced, and I haven't changed any code at all, no DISPOSE
> yet, so there "can't" be a bug in my code, at least not an unsafe one.)
>
> Basically I think the implied initializers (from the :=... in the type definition)
> aren't being run for UNTRACED ROOT OBJECTs.
>
>      Mika
>

-- 
Rodney Bates
rodney.m.bates at acm.org



More information about the M3devel mailing list