public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug modula2/108404] New: M2RTS_Halt fails with a segv (it should emit a diagnostic and exit).
@ 2023-01-14  9:57 iains at gcc dot gnu.org
  2023-01-15 20:48 ` [Bug modula2/108404] " gaius at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: iains at gcc dot gnu.org @ 2023-01-14  9:57 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 108404
           Summary: M2RTS_Halt fails with a segv (it should emit a
                    diagnostic and exit).
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: modula2
          Assignee: gaius at gcc dot gnu.org
          Reporter: iains at gcc dot gnu.org
  Target Milestone: ---

On Darwin several tests fail because there is an invalid stack size set (that
is a separate bug).

The fault should have been reported by M2RTS_Halt (it is detected correctly in
Rico.cc).

Setting a break point on the entry to M2RTS_Halt :

* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
    frame #0: 0x00000001000054f0 concurrentstore.x0`M2RTS_Halt at
M2RTS.mod:296:1
   293  
   294  PROCEDURE Halt (file: ARRAY OF CHAR; line: CARDINAL;
   295                  function: ARRAY OF CHAR; description: ARRAY OF CHAR) ;
-> 296  BEGIN
   297     ErrorMessage (description, file, line, function) ;
   298     HALT
   299  END Halt ;

examining the registers:

(lldb) reg read
General Purpose Registers:
       rax = 0x0000000000000016
       rbx = 0x0000600002c08118
       rcx = 0x0000000100014c00  "failed to set stack size attribute"
       rdx = 0x0000000100014bf2  "initThread"
       rdi = 0x0000000100014b00 
"/src-local/gcc-master/libgm2/libm2iso/RTco.cc"
       rsi = 0x0000000000000172

this is correct ABI - RDI - file, RSI = line number, RDX = function, RCX =
message.
(four integer/pointer arguments).

---- however if we continue from this point ...

* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS
(code=2, address=0x3014e7178)
    frame #0: 0x000000010000554f concurrentstore.x0`M2RTS_Halt at
M2RTS.mod:296:1
   293  
   294  PROCEDURE Halt (file: ARRAY OF CHAR; line: CARDINAL;
   295                  function: ARRAY OF CHAR; description: ARRAY OF CHAR) ;
-> 296  BEGIN
   297     ErrorMessage (description, file, line, function) ;

I cannot (at present) debug this further since I do not have an installed
debugger that supports Module-2 (but it might  well repeat on Linux - the ABI
is basically the same).  In any case, it seems likely that the problem is in
the prologue or very early in the function since the break line is on BEGIN in
both cases.

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

* [Bug modula2/108404] M2RTS_Halt fails with a segv (it should emit a diagnostic and exit).
  2023-01-14  9:57 [Bug modula2/108404] New: M2RTS_Halt fails with a segv (it should emit a diagnostic and exit) iains at gcc dot gnu.org
@ 2023-01-15 20:48 ` gaius at gcc dot gnu.org
  2023-01-16  8:32 ` gaius at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: gaius at gcc dot gnu.org @ 2023-01-15 20:48 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Gaius Mulley <gaius at gcc dot gnu.org> ---
Ah the ARRAY OF CHAR is passed as:  struct { char *contents; unsigned int high
}.
(Even if VAR or non VAR).  The effect of non VAR is for the callee to take a
copy.
Essentially if RTco calls halt it should:

struct { char *contents, unsigned int high } file_aoc, desc_aoc, func_aoc ;
file_aoc.contents = __FILE__;
file_aoc.high = strlen (file_aoc.contents) -1;  /* the last legal indice of the
array.  */

/* same for desc_aoc, func_aoc.  */

Halt (file_aoc, __LINE__, desc_aoc, func_aoc)

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

* [Bug modula2/108404] M2RTS_Halt fails with a segv (it should emit a diagnostic and exit).
  2023-01-14  9:57 [Bug modula2/108404] New: M2RTS_Halt fails with a segv (it should emit a diagnostic and exit) iains at gcc dot gnu.org
  2023-01-15 20:48 ` [Bug modula2/108404] " gaius at gcc dot gnu.org
@ 2023-01-16  8:32 ` gaius at gcc dot gnu.org
  2023-01-16 18:25 ` gaius at gcc dot gnu.org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: gaius at gcc dot gnu.org @ 2023-01-16  8:32 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Gaius Mulley <gaius at gcc dot gnu.org> ---
For completeness if Modula-2 calls a C function defined in a DEFINITION FOR "C"
module then it will pass a "hello world" as a pointer to a null terminated
character sequence.  All strings gm2 generate are null terminated provided
there is enough space.

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

* [Bug modula2/108404] M2RTS_Halt fails with a segv (it should emit a diagnostic and exit).
  2023-01-14  9:57 [Bug modula2/108404] New: M2RTS_Halt fails with a segv (it should emit a diagnostic and exit) iains at gcc dot gnu.org
  2023-01-15 20:48 ` [Bug modula2/108404] " gaius at gcc dot gnu.org
  2023-01-16  8:32 ` gaius at gcc dot gnu.org
@ 2023-01-16 18:25 ` gaius at gcc dot gnu.org
  2023-01-16 23:05 ` iains at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: gaius at gcc dot gnu.org @ 2023-01-16 18:25 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |gaius at gcc dot gnu.org

--- Comment #3 from Gaius Mulley <gaius at gcc dot gnu.org> ---
Created attachment 54283
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54283&action=edit
Potential fix to allow RTco (and others) to call M2RTS_HaltC

This patch contains a new procedure exported from M2RTS HaltC which passes the
address of nul terminated strings to be passed without requiring conversion to
Modula-2 strings.

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

* [Bug modula2/108404] M2RTS_Halt fails with a segv (it should emit a diagnostic and exit).
  2023-01-14  9:57 [Bug modula2/108404] New: M2RTS_Halt fails with a segv (it should emit a diagnostic and exit) iains at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2023-01-16 18:25 ` gaius at gcc dot gnu.org
@ 2023-01-16 23:05 ` iains at gcc dot gnu.org
  2023-01-17 16:15 ` gaius at gcc dot gnu.org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: iains at gcc dot gnu.org @ 2023-01-16 23:05 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Iain Sandoe <iains at gcc dot gnu.org> ---

Works for me - now the failing test cases produce a diagnostic;

/src-local/gcc-master/libgm2/libm2iso/RTco.cc:373:in initThread has caused
failed to set stack size attribute

Although it does not seem to exit the failed program (is that because Halt
eventually does a loop-forever?)

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

* [Bug modula2/108404] M2RTS_Halt fails with a segv (it should emit a diagnostic and exit).
  2023-01-14  9:57 [Bug modula2/108404] New: M2RTS_Halt fails with a segv (it should emit a diagnostic and exit) iains at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2023-01-16 23:05 ` iains at gcc dot gnu.org
@ 2023-01-17 16:15 ` gaius at gcc dot gnu.org
  2023-01-17 19:52 ` iains at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: gaius at gcc dot gnu.org @ 2023-01-17 16:15 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Gaius Mulley <gaius at gcc dot gnu.org> ---
I've committed the patch above - since the source tree without it definitely
has a  mismatched prototype.  The exit issue needs to be resolved before this
PR can close.

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

* [Bug modula2/108404] M2RTS_Halt fails with a segv (it should emit a diagnostic and exit).
  2023-01-14  9:57 [Bug modula2/108404] New: M2RTS_Halt fails with a segv (it should emit a diagnostic and exit) iains at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2023-01-17 16:15 ` gaius at gcc dot gnu.org
@ 2023-01-17 19:52 ` iains at gcc dot gnu.org
  2023-08-05 17:35 ` gaius at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: iains at gcc dot gnu.org @ 2023-01-17 19:52 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Iain Sandoe <iains at gcc dot gnu.org> ---
(In reply to Gaius Mulley from comment #5)
> I've committed the patch above - since the source tree without it definitely
> has a  mismatched prototype.  The exit issue needs to be resolved before
> this PR can close.

thanks,
of course, it is not clear what the cause of hanging tests is - so it might be
unrelated now (but too early to say).

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

* [Bug modula2/108404] M2RTS_Halt fails with a segv (it should emit a diagnostic and exit).
  2023-01-14  9:57 [Bug modula2/108404] New: M2RTS_Halt fails with a segv (it should emit a diagnostic and exit) iains at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2023-01-17 19:52 ` iains at gcc dot gnu.org
@ 2023-08-05 17:35 ` gaius at gcc dot gnu.org
  2023-08-10 12:21 ` iains at gcc dot gnu.org
  2023-08-10 12:49 ` gaius at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: gaius at gcc dot gnu.org @ 2023-08-05 17:35 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Gaius Mulley <gaius at gcc dot gnu.org> ---
I wonder if this bug has now been fixed via the other PR fixes.  Specifically
the rewrite of RTco.cc, the defensive use of select, bugfixes to HIGH and
FIO.mod (memcpy parameters)?  It might be worth a re-run just to explore the
effect of these fixes.

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

* [Bug modula2/108404] M2RTS_Halt fails with a segv (it should emit a diagnostic and exit).
  2023-01-14  9:57 [Bug modula2/108404] New: M2RTS_Halt fails with a segv (it should emit a diagnostic and exit) iains at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2023-08-05 17:35 ` gaius at gcc dot gnu.org
@ 2023-08-10 12:21 ` iains at gcc dot gnu.org
  2023-08-10 12:49 ` gaius at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: iains at gcc dot gnu.org @ 2023-08-10 12:21 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Iain Sandoe <iains at gcc dot gnu.org> ---
(In reply to Gaius Mulley from comment #7)
> I wonder if this bug has now been fixed via the other PR fixes. 
> Specifically the rewrite of RTco.cc, the defensive use of select, bugfixes
> to HIGH and FIO.mod (memcpy parameters)?  It might be worth a re-run just to
> explore the effect of these fixes.

I guess we can say this bug is fixed, indeed.
...the other hanging tests have been 'fixed' by a more defensive implementation
of the select functionality (although it remains unclear why select is failing
in the first place).

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

* [Bug modula2/108404] M2RTS_Halt fails with a segv (it should emit a diagnostic and exit).
  2023-01-14  9:57 [Bug modula2/108404] New: M2RTS_Halt fails with a segv (it should emit a diagnostic and exit) iains at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2023-08-10 12:21 ` iains at gcc dot gnu.org
@ 2023-08-10 12:49 ` gaius at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: gaius at gcc dot gnu.org @ 2023-08-10 12:49 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #9 from Gaius Mulley <gaius at gcc dot gnu.org> ---
Thanks!  Closing now that the bug has disappeared.

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

end of thread, other threads:[~2023-08-10 12:49 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-14  9:57 [Bug modula2/108404] New: M2RTS_Halt fails with a segv (it should emit a diagnostic and exit) iains at gcc dot gnu.org
2023-01-15 20:48 ` [Bug modula2/108404] " gaius at gcc dot gnu.org
2023-01-16  8:32 ` gaius at gcc dot gnu.org
2023-01-16 18:25 ` gaius at gcc dot gnu.org
2023-01-16 23:05 ` iains at gcc dot gnu.org
2023-01-17 16:15 ` gaius at gcc dot gnu.org
2023-01-17 19:52 ` iains at gcc dot gnu.org
2023-08-05 17:35 ` gaius at gcc dot gnu.org
2023-08-10 12:21 ` iains at gcc dot gnu.org
2023-08-10 12:49 ` 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).