issue-#192 Kernel.Call does not work with ANYREC-parameters

issue-#192 Kernel.Call does not work with ANYREC-parameters

Postby Zinn » Fri Nov 23, 2018 3:22 pm

Kernel.Call does not work with ANYREC-parameters
Reported by Eugene Temirgaleev

The following sample program produce a TRAP 0, because the stack does not pass the actual ANYREC parameter.

Code: Select all
MODULE PrivTest;
   IMPORT Meta, Services, Log, Files;
   
   PROCEDURE LogTypeName* (IN rec: ANYREC);
      VAR   name: ARRAY 256 OF CHAR;
   BEGIN
      Services.GetTypeName(rec, name); Log.String(name); Log.Ln
   END LogTypeName;

   PROCEDURE Call*;
      VAR   i, res: Meta.Item; par: ARRAY 10 OF Meta.Item; ok: BOOLEAN;
   BEGIN
      Meta.LookupPath("PrivTest.LogTypeName", i); ASSERT(i.Valid());
      Meta.GetItem(Files.dir, par[0]);
      i.ParamCall(par, res, ok);
   END Call;

   PROCEDURE LogTypeName2* (IN rec1, rec2: ANYREC);
      VAR   name: ARRAY 256 OF CHAR;
   BEGIN
      Services.GetTypeName(rec1, name); Log.String(name); Log.Ln;
      Services.GetTypeName(rec2, name); Log.String(name); Log.Ln
   END LogTypeName2;

   PROCEDURE Call2*;
      VAR   i, res: Meta.Item; par: ARRAY 10 OF Meta.Item; ok: BOOLEAN;
   BEGIN
      Meta.LookupPath("PrivTest.LogTypeName2", i); ASSERT(i.Valid());
      Meta.GetItem(Files.dir, par[0]); Meta.GetItem(Files.dir, par[1]);
      i.ParamCall(par, res, ok);
   END Call2;

END PrivTest.   (!)PrivTest.Call   (!)PrivTest.Call2


Eugene propose the following solution

Code: Select all
   PROCEDURE Call* (adr: INTEGER; sig: Signature; IN par: ARRAY OF INTEGER; n: INTEGER): LONGINT;
      VAR p, kind, sp, size: INTEGER; typ: Type; r: REAL;
   BEGIN
      p := sig.num;
      WHILE p > 0 DO   (* push parameters from right to left *)
         DEC(p);
         typ := sig.par[p].struct;
         kind := sig.par[p].id MOD 16;
         IF (S.VAL(INTEGER, typ) DIV 256 = 0) OR (typ.id MOD 4 IN {0, 3}) THEN   (* scalar *)
            IF (kind = 10) & ((S.VAL(INTEGER, typ) = 8) OR (S.VAL(INTEGER, typ) = 10)) THEN   (* 64 bit *)
               DEC(n); PUSH(par[n])   (* push hi word *)
(* adding this lines here ---------------------*)
            ELSIF S.VAL(INTEGER, typ) = 11 THEN   (* ANYREC *)
               ASSERT(kind # 10);
               DEC(n); PUSH(par[n])   (* push tag *)
(* end adding --------------------------- *)
            END;
            DEC(n); PUSH(par[n])   (* push value/address *)
         ELSIF typ.id MOD 4 = 1 THEN   (* record *)


You have to link BlackBox with the changed KERNEL before you testing it.
- Helmut
Zinn
 
Posts: 472
Joined: Tue Mar 25, 2014 5:56 pm
Location: Frankfurt am Main

Re: issue-#192 Kernel.Call does not work with ANYREC-paramet

Postby Josef Templ » Fri Nov 23, 2018 5:33 pm

Excellent analysis by Eugene Temirgaleev.

I have added an issue for that in redmine.
See https://redmine.blackboxframework.org/issues/192.

- Josef
User avatar
Josef Templ
 
Posts: 2038
Joined: Tue Sep 17, 2013 6:50 am


Re: issue-#192 Kernel.Call does not work with ANYREC-paramet

Postby Zinn » Sat Nov 24, 2018 7:03 am

In the diff


In this change list the line
- 20181111, center #190, add comment about stack and heap memory configuration
is missing.
- Helmut
Zinn
 
Posts: 472
Joined: Tue Mar 25, 2014 5:56 pm
Location: Frankfurt am Main

Re: issue-#192 Kernel.Call does not work with ANYREC-paramet

Postby Josef Templ » Sat Nov 24, 2018 7:43 am

This because the previous issue has not yet been merged with master.
After that I can resolve the merge conflict with this issue.

- Josef
User avatar
Josef Templ
 
Posts: 2038
Joined: Tue Sep 17, 2013 6:50 am

Re: issue-#192 Kernel.Call does not work with ANYREC-paramet

Postby Robert » Fri Nov 30, 2018 11:33 am

Is this now ready for voting; is the current diff complete?
User avatar
Robert
 
Posts: 1023
Joined: Sat Sep 28, 2013 11:04 am
Location: Edinburgh, Scotland

Re: issue-#192 Kernel.Call does not work with ANYREC-paramet

Postby Josef Templ » Sat Dec 01, 2018 8:22 am

I have to remove the merge conflict first.
User avatar
Josef Templ
 
Posts: 2038
Joined: Tue Sep 17, 2013 6:50 am



Return to Resolved (Bugs)

Who is online

Users browsing this forum: No registered users and 1 guest

cron