public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug modula2/112920] New: gm2 hangs in the type resolver
@ 2023-12-08 13:54 gaius at gcc dot gnu.org
  2023-12-08 13:58 ` [Bug modula2/112920] " gaius at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: gaius at gcc dot gnu.org @ 2023-12-08 13:54 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112920

            Bug ID: 112920
           Summary: gm2 hangs in the type resolver
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: modula2
          Assignee: gaius at gcc dot gnu.org
          Reporter: gaius at gcc dot gnu.org
  Target Milestone: ---

Created attachment 56834
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56834&action=edit
test case showing bug

A large program with many data types causes gm2 to hang in the type resolver.

Forwarded from the gm2 mailing list to track bug progress etc:

"""
I could generate dynamic
or static binaries but now with version 191 gm2 seems to go into an
endless loop. Perhaps you can see what's going wrong?

BTW for staring a compilation one may simply enter

./mach_squash1

for a dynamic binary or

./mach_squash1_static

for a static binary in the relevant directory.
"""

It hangs in the dist_gm2_191 directory when invoked with:

$ gm2 -fiso -fsoft-check-all squash1.mod Ctv2.o unix.o -o squash1 -lc -lcrypt
-lm

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug modula2/112920] gm2 hangs in the type resolver
  2023-12-08 13:54 [Bug modula2/112920] New: gm2 hangs in the type resolver gaius at gcc dot gnu.org
@ 2023-12-08 13:58 ` gaius at gcc dot gnu.org
  2024-01-08 23:46 ` gaius at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: gaius at gcc dot gnu.org @ 2023-12-08 13:58 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112920

Gaius Mulley <gaius at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2023-12-08
             Status|UNCONFIRMED                 |ASSIGNED
     Ever confirmed|0                           |1

--- Comment #1 from Gaius Mulley <gaius at gcc dot gnu.org> ---
Confirmed - in directory 191:

$ gm2 -fiso -fsoft-check-all squash1.mod Ctv2.o unix.o -o squash1 -lc -lcrypt
-lm -wrapper gdb,--args
(gdb) run
^C
(gdb) where
#0  __udivmodti4 (rp=0x0, d=<optimized out>, n=<optimized out>) at
../../../libgcc/libgcc2.c:1203
#1  __divti3 (u=704, v=<optimized out>) at ../../../libgcc/libgcc2.c:1225
#2  0x0000000000ac3683 in findPos (pb=0xa1ba320, i=719) at
../../gcc/m2/gm2-compiler/Sets.mod:145
#3  0x0000000000ac2e25 in Sets_IsElementInSet (s=0x3362d30, i=719) at
../../gcc/m2/gm2-compiler/Sets.mod:254
#4  0x0000000000a2fc3b in TraverseDependantsInner (sym=719) at
../../gcc/m2/gm2-compiler/M2GCCDeclare.mod:2087
#5  0x0000000000a3bd99 in WalkArrayDependants (sym=7430, p=0x7fffffffd8e0) at
../../gcc/m2/gm2-compiler/M2GCCDeclare.mod:5981
#6  0x0000000000a2fb07 in WalkDependants (sym=7430, p=0x7fffffffd920) at
../../gcc/m2/gm2-compiler/M2GCCDeclare.mod:2055
#7  0x0000000000a2fca4 in TraverseDependantsInner (sym=7430) at
../../gcc/m2/gm2-compiler/M2GCCDeclare.mod:2095
#8  0x0000000000a2f300 in WalkConst (sym=14448, p=0x7fffffffd960) at
../../gcc/m2/gm2-compiler/M2GCCDeclare.mod:1690
#9  0x0000000000a2fbcc in WalkDependants (sym=14448, p=0x7fffffffd990) at
../../gcc/m2/gm2-compiler/M2GCCDeclare.mod:2070
#10 0x0000000000a2fca4 in TraverseDependantsInner (sym=14448) at
../../gcc/m2/gm2-compiler/M2GCCDeclare.mod:2095
#11 0x0000000000a2fcef in TraverseDependants (sym=14448) at
../../gcc/m2/gm2-compiler/M2GCCDeclare.mod:2111
#12 0x0000000000a2bcf5 in M2GCCDeclare_TryDeclareConstant (tokenno=8668,
sym=14448) at ../../gcc/m2/gm2-compiler/M2GCCDeclare.mod:1738
#13 0x0000000000a42961 in FoldBecomes (tokenno=8668, p=0x7fffffffda30,
quad=1125, op1=7458, op3=14448) at ../../gcc/m2/gm2-compiler/M2GenGCC.mod:2667
#14 0x0000000000a3cb7c in M2GenGCC_ResolveConstantExpressions
(p=0x7fffffffda88, start=700, end=1129) at
../../gcc/m2/gm2-compiler/M2GenGCC.mod:600
#15 0x0000000000a30a17 in DeclareTypesConstantsProceduresInRange (scope=178,
start=700, end=1129) at ../../gcc/m2/gm2-compiler/M2GCCDeclare.mod:2573
#16 0x0000000000a9f2ba in M2Scope_ForeachScopeBlockDo (sb=0xa1b9df0,
p=0x7fffffffdb10) at ../../gcc/m2/gm2-compiler/M2Scope.mod:431
#17 0x0000000000a30bb9 in DeclareTypesConstantsProcedures (scope=178) at
../../gcc/m2/gm2-compiler/M2GCCDeclare.mod:2649
#18 0x0000000000a30df3 in StartDeclareModuleScopeSeparate (scope=178) at
../../gcc/m2/gm2-compiler/M2GCCDeclare.mod:2734
#19 0x0000000000a30fcc in StartDeclareModuleScope (scope=178) at
../../gcc/m2/gm2-compiler/M2GCCDeclare.mod:2806
#20 0x0000000000a2baaa in M2GCCDeclare_StartDeclareScope (scope=178) at
../../gcc/m2/gm2-compiler/M2GCCDeclare.mod:2863



type resolver is spinning in an infinite loop.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug modula2/112920] gm2 hangs in the type resolver
  2023-12-08 13:54 [Bug modula2/112920] New: gm2 hangs in the type resolver gaius at gcc dot gnu.org
  2023-12-08 13:58 ` [Bug modula2/112920] " gaius at gcc dot gnu.org
@ 2024-01-08 23:46 ` gaius at gcc dot gnu.org
  2024-01-09 13:37 ` cvs-commit at gcc dot gnu.org
  2024-01-09 14:01 ` gaius at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: gaius at gcc dot gnu.org @ 2024-01-08 23:46 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112920

--- Comment #2 from Gaius Mulley <gaius at gcc dot gnu.org> ---
Created attachment 57011
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57011&action=edit
Proposed fix

Here is a proposed fix which compiles the previous attached test cases and
causes no extra regression test failures.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug modula2/112920] gm2 hangs in the type resolver
  2023-12-08 13:54 [Bug modula2/112920] New: gm2 hangs in the type resolver gaius at gcc dot gnu.org
  2023-12-08 13:58 ` [Bug modula2/112920] " gaius at gcc dot gnu.org
  2024-01-08 23:46 ` gaius at gcc dot gnu.org
@ 2024-01-09 13:37 ` cvs-commit at gcc dot gnu.org
  2024-01-09 14:01 ` gaius at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-01-09 13:37 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112920

--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Gaius Mulley <gaius@gcc.gnu.org>:

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

commit r14-7064-ge3632a18d1e0b94b4c7b99a512b19c830ed3b228
Author: Gaius Mulley <gaiusmod2@gmail.com>
Date:   Tue Jan 9 13:36:44 2024 +0000

    PR modula2/112920 cc1gm2 hangs in the type resolver

    This patch contains a fix to gcc/m2/gm2-compiler/M2GCCDeclare.mod.
    The fix introduces a group of sets which can be compared.  The resolver
    will loop until there is no change in all sets within the group.
    Since symbols migrate from set to set without ever looping this
    will never hang.  Previously only the number of elements in a set
    were compared which resulted in a infinite spin.

    gcc/m2/ChangeLog:

            PR modula2/112920
            * gm2-compiler/M2GCCDeclare.mod (Group): New declaration.
            Import MakeSubrange, MakeConstVar, MakeConstLit and DivTrunc.
            (FreeGroup): New declaration.
            (GlobalGroup): New declaration.
            (ToBeSolvedByQuads): Remove.
            (NilTypedArrays): Remove.
            (PartiallyDeclared): Remove.
            (HeldByAlignment): Remove.
            (FinishedAlignment): Remove.
            (ToDoList): Remove.
            (DebugSet): Re-format.
            (DebugNumber): Re-format.
            (DebugSetNumbers): Reference sets using GlobalGroup.
            (AddSymToWatch): Re-format.
            (WatchIncludeList): Reference sets using GlobalGroup.
            (WatchRemoveList): Reference sets using GlobalGroup.
            (NewGroup): New procedure.
            (DisposeGroup): New procedure.
            (InitGroup): New procedure.
            (KillGroup): New procedure.
            (DupGroup): New procedure.
            (EqualGroup): New procedure.
            (LookupSet): New procedure.
            (CanDeclareTypePartially): Reference sets using GlobalGroup.
            (CompletelyResolved): Reference sets using GlobalGroup.
            (IsNilTypedArrays): Reference sets using GlobalGroup.
            (IsFullyDeclared): Reference sets using GlobalGroup.
            (IsPartiallyDeclared): Reference sets using GlobalGroup.
            (IsPartiallyOrFullyDeclared): Reference sets using GlobalGroup.
            (DeclareTypeConstFully): Reference sets using GlobalGroup.
            (bodyl): Remove.
            (Body): Use bodyt and to lookup the required set.
            (ForeachTryDeclare): Remove parameter l.  Lookup set instead.
            (DeclareOutstandingTypes): Add new rules setarraynul and setfully.
            Reference sets using GlobalGroup.
            (ActivateWatch): New procedure.
            (DeclareTypesConstantsProceduresInRange): Re-written to check
            group change.
            (DeclareTypesConstantsProcedures): Re-written to check
            group change.
            (DeclareBoolean): Reference sets using GlobalGroup.
            (DeclarePackedBoolean): Ditto.
            (DeclareDefaultConstants): Ditto.
            (FreeGroup): Initialized.
            (GlobalGroup): Ditto.
            * gm2-compiler/Sets.def (EqualSet): New procedure function.
            Remove export qualified list of identifiers.
            * gm2-compiler/Sets.mod (EqualSet): New procedure function.

    Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug modula2/112920] gm2 hangs in the type resolver
  2023-12-08 13:54 [Bug modula2/112920] New: gm2 hangs in the type resolver gaius at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2024-01-09 13:37 ` cvs-commit at gcc dot gnu.org
@ 2024-01-09 14:01 ` gaius at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: gaius at gcc dot gnu.org @ 2024-01-09 14:01 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112920

Gaius Mulley <gaius at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #4 from Gaius Mulley <gaius at gcc dot gnu.org> ---
Closing now that the patch has been applied.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-01-09 14:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-08 13:54 [Bug modula2/112920] New: gm2 hangs in the type resolver gaius at gcc dot gnu.org
2023-12-08 13:58 ` [Bug modula2/112920] " gaius at gcc dot gnu.org
2024-01-08 23:46 ` gaius at gcc dot gnu.org
2024-01-09 13:37 ` cvs-commit at gcc dot gnu.org
2024-01-09 14:01 ` gaius at gcc dot gnu.org

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).