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

Rainer Orth <ro at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |NEW

--- Comment #4 from Rainer Orth <ro at gcc dot gnu.org> ---
When I tried the 32-bit Solaris/SPARC build again as of 20221103, I still got
the same SEGV:

Starting program: /var/gcc/modula-2/11.4-gcc-modula-2-g3/gcc/cc1gm2 -quiet
-mcpu=v9 -fpim -fno-scaffold-main -fno-scaffold-dynamic -fno-scaffold-static
-fno-m2-plugin -fdump-system-exports -c
-I/vol/gcc/src/hg/master/modula-2/gcc/m2/gm2-libs
-I/usr/local/lib/gcc/sparc-sun-solaris2.11/13.0.0/m2/m2pim
/vol/gcc/src/hg/master/modula-2/gcc/m2/gm2-libs/SYSTEM.mod -o SYSTEM.s
[Thread debugging using libthread_db enabled]
[New Thread 1 (LWP 1)]
SYSTEM module creates type: LOC
SYSTEM module creates type: WORD
SYSTEM module creates type: BYTE
SYSTEM module creates type: ADDRESS
SYSTEM module creates type: INTEGER8
SYSTEM module creates type: INTEGER16
SYSTEM module creates type: INTEGER32
SYSTEM module creates type: INTEGER64
SYSTEM module creates type: CARDINAL8
SYSTEM module creates type: CARDINAL16
SYSTEM module creates type: CARDINAL32
SYSTEM module creates type: CARDINAL64
SYSTEM module creates type: WORD16
SYSTEM module creates type: WORD32
SYSTEM module creates type: WORD64
SYSTEM module creates type: BITSET8
SYSTEM module creates type: BITSET16
SYSTEM module creates type: BITSET32
SYSTEM module creates type: REAL32
SYSTEM module creates type: REAL64
SYSTEM module creates type: REAL128
SYSTEM module creates type: COMPLEX32
SYSTEM module creates type: COMPLEX64
SYSTEM module creates type: COMPLEX128
SYSTEM module creates type: CSIZE_T
SYSTEM module creates type: CSSIZE_T

Thread 2 received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1 (LWP 1)]
0xffbfe00c in ?? ()
(gdb) bt
#0  0xffbfe00c in ?? ()
#1  0x00d20d1c in m2expr_BuildBinarySetDo (location=1338176, settype=<type_decl
0xfa820630 BITSET>, op1=<var_decl 0xfa856948 _T75>, op2=<var_decl 0xfa8568f0
_T74>, op3=<var_decl 0xfa856898 _T73>, binop=0xffbfe00c, is_op1lvalue=0,
is_op2lvalue=0, is_op3lvalue=0, nBits=<integer_cst 0xfa839350>,
unbounded=<record_type 0xfa8321e0>, varproc=<function_decl 0xfa841e80
ShiftVal>, leftproc=<function_decl 0xfa841f00 ShiftLeft>,
rightproc=<function_decl 0xfa841f80 ShiftRight>) at
/vol/gcc/src/hg/master/modula-2/gcc/m2/gm2-gcc/m2expr.cc:839
#2  0x00d957e0 in CodeBinarySetShift (binop=..., doOp=..., var=242, left=247,
right=248, quad=248, op1=1114, op2=1113, op3=1112) at
m2/gm2-compiler-boot/M2GenGCC.c:5908
#3  0x00d95910 in CodeSetShift (quad=248, op1=1114, op2=1113, op3=1112) at
m2/gm2-compiler-boot/M2GenGCC.c:5929
#4  0x00d8940c in CodeStatement (q=248) at m2/gm2-compiler-boot/M2GenGCC.c:1819
#5  0x00d9f144 in M2GenGCC_ConvertQuadsToTree (Start=248, End=340) at
m2/gm2-compiler-boot/M2GenGCC.c:8454
#6  0x00de2f68 in M2Scope_ForeachScopeBlockDo (sb=0x38cbdd8, p=...) at
m2/gm2-compiler-boot/M2Scope.c:651
#7  0x00d720e0 in M2Code_CodeBlock (scope=163) at
m2/gm2-compiler-boot/M2Code.c:511
#8  0x00d54c70 in Lists_ForeachItemInListDo (l=0x37794c8, P=...) at
m2/gm2-compiler-boot/Lists.c:393
#9  0x00e0bb78 in SymbolTable_ForeachProcedureDo (Sym=42, P=...) at
m2/gm2-compiler-boot/SymbolTable.c:14044
#10 0x00d722e4 in M2Code_CodeBlock (scope=42) at
m2/gm2-compiler-boot/M2Code.c:543
#11 0x00d71660 in DoCodeBlock () at m2/gm2-compiler-boot/M2Code.c:274
#12 0x00d71f20 in M2Code_Code () at m2/gm2-compiler-boot/M2Code.c:474
#13 0x00d72574 in Compile (s=0x37929e8) at m2/gm2-compiler-boot/M2Comp.c:211
#14 0x00d73a84 in M2Comp_compile (filename=0xffbfeb65) at
m2/gm2-compiler-boot/M2Comp.c:768
#15 0x00d3a638 in init_PerCompilationInit (filename=0xffbfeb65
"/vol/gcc/src/hg/master/modula-2/gcc/m2/gm2-libs/SYSTEM.mod") at
/vol/gcc/src/hg/master/modula-2/gcc/m2/gm2-gcc/init.cc:198
#16 0x00ce1c0c in gm2_parse_input_files (filenames=0x372d698, filename_count=1)
at /vol/gcc/src/hg/master/modula-2/gcc/m2/gm2-lang.cc:461
#17 0x00ce1c68 in gm2_langhook_parse_file () at
/vol/gcc/src/hg/master/modula-2/gcc/m2/gm2-lang.cc:468
#18 0x019063bc in compile_file () at
/vol/gcc/src/hg/master/modula-2/gcc/toplev.cc:444
#19 0x0190b1fc in do_compile (no_backend=false) at
/vol/gcc/src/hg/master/modula-2/gcc/toplev.cc:2125
#20 0x0190b7c4 in toplev::main (this=0xffbfe84a, argc=15, argv=0xffbfe8b4) at
/vol/gcc/src/hg/master/modula-2/gcc/toplev.cc:2277
#21 0x02e05368 in main (argc=15, argv=0xffbfe8b4) at
/vol/gcc/src/hg/master/modula-2/gcc/main.cc:39
(gdb) up
#1  0x00d20d1c in m2expr_BuildBinarySetDo (location=1338176, settype=<type_decl
0xfa820630 BITSET>, op1=<var_decl 0xfa856948 _T75>, op2=<var_decl 0xfa8568f0
_T74>, op3=<var_decl 0xfa856898 _T73>, binop=0xffbfe00c, is_op1lvalue=0,
is_op2lvalue=0, is_op3lvalue=0, nBits=<integer_cst 0xfa839350>,
unbounded=<record_type 0xfa8321e0>, varproc=<function_decl 0xfa841e80
ShiftVal>, leftproc=<function_decl 0xfa841f00 ShiftLeft>,
rightproc=<function_decl 0xfa841f80 ShiftRight>) at
/vol/gcc/src/hg/master/modula-2/gcc/m2/gm2-gcc/m2expr.cc:839
839         (*binop) (location,
(gdb) p binop
$4 = (void (*)(location_t, tree, tree, tree, tree, int)) 0xffbfe00c
(gdb) x/10i binop
   0xffbfe00c:  unknown
   0xffbfe010:  unknown
   0xffbfe014:  unknown
   0xffbfe018:  lda  [ %sp + %l0 ] (154), %i5
   0xffbfe01c:  lda  [ %o4 + 0x1e0 ] %asi, %i5
   0xffbfe020:  lda  [ %l0 ] (252), %i5
   0xffbfe024:  lda  [ %l0 ] #ASI_BLK_PL, %i5
   0xffbfe028:  lda  [ %l0 ] (244), %i5
   0xffbfe02c:  illtrap  0x146b40
   0xffbfe030:  illtrap  0
(gdb) ptype binop
type = void (*)(location_t, tree, tree, tree, tree, int)
(gdb) up
#2  0x00d957e0 in CodeBinarySetShift (binop=..., doOp=..., var=242, left=247,
right=248, quad=248, op1=1114, op2=1113, op3=1112) at
m2/gm2-compiler-boot/M2GenGCC.c:5908
5908          m2expr_BuildBinarySetDo (location, SymbolConversion_Mod2Gcc
(SymbolTable_SkipType (SymbolTable_GetType (op1))), SymbolConversion_Mod2Gcc
(op1), SymbolConversion_Mod2Gcc (op2), SymbolConversion_Mod2Gcc (op3), binop,
(SymbolTable_GetMode (op1)) == SymbolTable_LeftValue, (SymbolTable_GetMode
(op2)) == SymbolTable_LeftValue, (SymbolTable_GetMode (op3)) ==
SymbolTable_LeftValue, nBits, unbounded, varproc, leftproc, rightproc);
(gdb) ptype binop
type = struct m2expr_BuildSetProcedure_p {
    m2expr_BuildSetProcedure_t proc;
}
(gdb) ptype m2expr_BuildSetProcedure_t
type = void (*)(m2linemap_location_t, m2tree_Tree, m2tree_Tree, m2tree_Tree,
m2tree_Tree, unsigned int)

There's an inconsistency here, which might well explain the SEGV:

* When m2expr_BuildBinarySetDo calls binop, it expects an
  void (*)(location_t, tree, tree, tree, tree, int)

* However, in the caller (CodeBinarySetShift), binop is passed in as a struct
m2expr.

I suspect that m2expr_BuildBinarySetDo should instead be called with
binop.proc instead.  Because m2/gm2-compiler-boot/M2GenGCC.c is a generated
file, I didn't try to correct this.

Reply via email to