public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-7842] PR modula2/111510 runtime ICE findChildAndParent has caused internal runtime error
@ 2023-09-26 18:43 Gaius Mulley
  0 siblings, 0 replies; only message in thread
From: Gaius Mulley @ 2023-09-26 18:43 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:b92cddb94874df4b9451d9cea3efa88f0654981b

commit r13-7842-gb92cddb94874df4b9451d9cea3efa88f0654981b
Author: Gaius Mulley <gaiusmod2@gmail.com>
Date:   Tue Sep 26 19:39:59 2023 +0100

    PR modula2/111510 runtime ICE findChildAndParent has caused internal runtime error
    
    This patch fixes the runtime bug above.  The full runtime message is:
    findChildAndParent has caused internal runtime error, RTentity is either
    corrupt or the module storage has not been initialized yet.  The bug is
    due to a non nul terminated string determining the module initialization order.
    This results in modules being uninitialized and the above crash.  The bug
    manifests itself on 32 bit systems - but obviously is latent on all
    targets and the fix should be applied to both gcc-14 and gcc-13.
    
    gcc/m2/ChangeLog:
    
            PR modula2/111510
            * gm2-compiler/M2GenGCC.mod (IsExportedGcc): Minor spacing changes.
            (BuildTrashTreeFromInterface): Minor spacing changes.
            * gm2-compiler/M2Options.mod (GetRuntimeModuleOverride): Call
            string to generate a nul terminated C style string.
            * gm2-compiler/M2Quads.mod (BuildStringAdrParam): New procedure.
            (BuildM2InitFunction): Replace inline parameter generation with
            calls to BuildStringAdrParam.
    
    (cherry picked from commit 53daf67fd55e005e37cb3ab33ac0783a71761de9)
    
    Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>

Diff:
---
 gcc/m2/gm2-compiler/M2GenGCC.mod  |  4 ++--
 gcc/m2/gm2-compiler/M2Options.mod |  2 +-
 gcc/m2/gm2-compiler/M2Quads.mod   | 36 ++++++++++++++++++++----------------
 3 files changed, 23 insertions(+), 19 deletions(-)

diff --git a/gcc/m2/gm2-compiler/M2GenGCC.mod b/gcc/m2/gm2-compiler/M2GenGCC.mod
index bcef4e70c40..dc58f23247b 100644
--- a/gcc/m2/gm2-compiler/M2GenGCC.mod
+++ b/gcc/m2/gm2-compiler/M2GenGCC.mod
@@ -388,7 +388,7 @@ BEGIN
    IF WholeProgram
    THEN
       scope := GetScope (sym) ;
-      WHILE scope#NulSym DO
+      WHILE scope # NulSym DO
          IF IsDefImp (scope)
          THEN
             RETURN IsExported (scope, sym)
@@ -766,7 +766,7 @@ VAR
    tree: Tree ;
 BEGIN
    tree := Tree (NIL) ;
-   IF sym#NulSym
+   IF sym # NulSym
    THEN
       i := 1 ;
       REPEAT
diff --git a/gcc/m2/gm2-compiler/M2Options.mod b/gcc/m2/gm2-compiler/M2Options.mod
index f265aa5da2b..75c2ad0ae72 100644
--- a/gcc/m2/gm2-compiler/M2Options.mod
+++ b/gcc/m2/gm2-compiler/M2Options.mod
@@ -1326,7 +1326,7 @@ END SetRuntimeModuleOverride ;
 
 PROCEDURE GetRuntimeModuleOverride () : ADDRESS ;
 BEGIN
-   RETURN RuntimeModuleOverride
+   RETURN string (RuntimeModuleOverride)
 END GetRuntimeModuleOverride ;
 
 
diff --git a/gcc/m2/gm2-compiler/M2Quads.mod b/gcc/m2/gm2-compiler/M2Quads.mod
index be837b328e5..9d4616ae6e6 100644
--- a/gcc/m2/gm2-compiler/M2Quads.mod
+++ b/gcc/m2/gm2-compiler/M2Quads.mod
@@ -2579,6 +2579,23 @@ BEGIN
 END BuildM2MainFunction ;
 
 
+(*
+   BuildStringAdrParam - push the address of a nul terminated string onto the quad stack.
+*)
+
+PROCEDURE BuildStringAdrParam (tok: CARDINAL; name: Name);
+VAR
+   str, m2strnul: CARDINAL ;
+BEGIN
+   PushTF (Adr, Address) ;
+   str := MakeConstLitString (tok, name) ;
+   m2strnul := MakeConstStringM2nul (tok, str) ;
+   PushTtok (m2strnul, tok) ;
+   PushT (1) ;
+   BuildAdrFunction
+END BuildAdrFunction ;
+
+
 (*
    BuildM2InitFunction -
 *)
@@ -2619,22 +2636,9 @@ BEGIN
             (* ConstructModules (module_name, argc, argv, envp);  *)
             PushTtok (constructModules, tok) ;
 
-            PushTF(Adr, Address) ;
-            PushTtok (MakeConstLitString (tok, GetSymName (moduleSym)), tok) ;
-            PushT(1) ;
-            BuildAdrFunction ;
-
-            PushTF(Adr, Address) ;
-            PushTtok (MakeConstLitString (tok, GetLibName (moduleSym)), tok) ;
-            PushT(1) ;
-            BuildAdrFunction ;
-
-            PushTF(Adr, Address) ;
-            PushTtok (MakeConstLitString (tok,
-                                          makekey (GetRuntimeModuleOverride ())),
-                      tok) ;
-            PushT(1) ;
-            BuildAdrFunction ;
+	    BuildStringAdrParam (tok, GetSymName (moduleSym)) ;
+	    BuildStringAdrParam (tok, GetLibName (moduleSym)) ;
+	    BuildStringAdrParam (tok, makekey (GetRuntimeModuleOverride ())) ;
 
             PushTtok (SafeRequestSym (tok, MakeKey ("argc")), tok) ;
             PushTtok (SafeRequestSym (tok, MakeKey ("argv")), tok) ;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-09-26 18:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-26 18:43 [gcc r13-7842] PR modula2/111510 runtime ICE findChildAndParent has caused internal runtime error Gaius Mulley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).