public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug d/101692] New: Program crushes at unpredictable moment of time
@ 2021-07-30 10:56 zed at lab127 dot karelia.ru
  2021-07-31  7:18 ` [Bug d/101692] " zed at lab127 dot karelia.ru
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: zed at lab127 dot karelia.ru @ 2021-07-30 10:56 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 101692
           Summary: Program crushes at unpredictable moment of time
           Product: gcc
           Version: 8.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: d
          Assignee: ibuclaw at gdcproject dot org
          Reporter: zed at lab127 dot karelia.ru
  Target Milestone: ---

I am not sure this is really a gdc issue,
but a program behaves very strange -
it works normally for some time, and
then receives SIGSEGV at unpredictable moment
(but always at the same place of code).

Here is code snippet, where the crush occurs

    struct EpollEvent
    {
        align(1):
        uint event_mask;
        EventSource es;     // EventSource is a class
        /* just do not want to use that union, epoll_data_t */
    }

    bool wait()
    {
        EpollEvent event;

        if (done)
            return false;

        int n = epoll_wait(id, &event, 1, -1);
        if (-1 == n)
            return false;

        writefln("%s, n = %d", __FUNCTION__, n);
        writefln("%s", event); // <<< crashes here

        EventSource s = event.es;
        ulong ecode = s.eventCode(event.event_mask);
        mq.putMsg(null, s.owner, ecode, s);

        return true;
    }

Crush occurs when program is accessing 'event' variable
after return from epoll_wait().

And it does not depend on the type of this variable - 
I tried dynamic array EpollEvent[], static array EpollEvent[MAX],
no matter, after some period of normal functioning
program gets SIGSEGV at the indicated line.

gdb says the following:

Core was generated by `./echod'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00007f312ed79380 in ?? ()
(gdb) bt
#0  0x00007f312ed79380 in ?? ()
#1  0x0000555f33107071 in
std.format.formatObject!(std.stdio.File.LockingTextWriter, esrc.EventSource,
char).formatObject(ref std.stdio.File.LockingTextWriter, ref esrc.EventSource,
ref const(std.format.FormatSpec!(char).FormatSpec)) (w=...,
val=@0x7ffec19ab610: 0x7f312edb6300, f=...)
    at /usr/lib/gcc/x86_64-linux-gnu/8/include/d/std/format.d:3353
#2  0x0000555f33106fc9 in
std.format.formatValue!(std.stdio.File.LockingTextWriter, esrc.EventSource,
char).formatValue(ref std.stdio.File.LockingTextWriter, esrc.EventSource, ref
const(std.format.FormatSpec!(char).FormatSpec)) (w=..., val=0x7f312edb6300,
f=...)
    at /usr/lib/gcc/x86_64-linux-gnu/8/include/d/std/format.d:3450
#3  0x0000555f33106f39 in
std.format.formatElement!(std.stdio.File.LockingTextWriter, esrc.EventSource,
char).formatElement(ref std.stdio.File.LockingTextWriter, ref esrc.EventSource,
ref const(std.format.FormatSpec!(char).FormatSpec)) (w=...,
val=@0x7ffec19ab6b0: 0x7f312edb6300, f=...)
    at /usr/lib/gcc/x86_64-linux-gnu/8/include/d/std/format.d:3180
#4  0x0000555f3310683a in
std.format.formatValue!(std.stdio.File.LockingTextWriter, ecap.EpollEvent,
char).formatValue(ref std.stdio.File.LockingTextWriter, ref ecap.EpollEvent,
ref const(std.format.FormatSpec!(char).FormatSpec)) (w=..., val=..., f=...)
    at /usr/lib/gcc/x86_64-linux-gnu/8/include/d/std/format.d:3702
#5  0x0000555f3310634b in
std.format.formattedWrite!(std.stdio.File.LockingTextWriter, char,
ecap.EpollEvent).formattedWrite(ref std.stdio.File.LockingTextWriter,
const(char[]), ecap.EpollEvent) (w=..., fmt=..., _param_2=...) at
/usr/lib/gcc/x86_64-linux-gnu/8/include/d/std/format.d:568
#6  0x0000555f33105dc5 in std.stdio.File.writefln!(char,
ecap.EpollEvent).writefln(const(char[]), ecap.EpollEvent) (this=..., fmt=...,
_param_1=...)
    at /usr/lib/gcc/x86_64-linux-gnu/8/include/d/std/stdio.d:1496
#7  0x0000555f330f49ad in std.stdio.writefln!(char,
ecap.EpollEvent).writefln(const(char[]), ecap.EpollEvent) (fmt=...,
_param_1=...)
    at /usr/lib/gcc/x86_64-linux-gnu/8/include/d/std/stdio.d:3797
#8  0x0000555f330eca63 in ecap.EventQueue.wait() (this=0x7f312ed76000) at
engine/ecap.d:113
#9  0x0000555f330f472a in D main (args=...) at echod.d:46

engine/ecap.d:113 is that 'writefln("%s", event);'

Also it seemed to me, that crash is more probable when compiling with -Os.
Also 2, i tried dmd instead of gdc - crushes also occurs, but much less
frequently.

gdc --version
gdc (Ubuntu 8.4.0-1ubuntu1~18.04) 8.4.0
(Linux Mint 19.1 actually)

uname -a
Linux HP-Laptop 4.15.0-151-generic #157-Ubuntu SMP Fri Jul 9 23:07:57 UTC 2021
x86_64 x86_64 x86_64 GNU/Linux

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

end of thread, other threads:[~2021-08-03 15:21 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-30 10:56 [Bug d/101692] New: Program crushes at unpredictable moment of time zed at lab127 dot karelia.ru
2021-07-31  7:18 ` [Bug d/101692] " zed at lab127 dot karelia.ru
2021-07-31  7:22 ` zed at lab127 dot karelia.ru
2021-07-31 11:50 ` zed at lab127 dot karelia.ru
2021-07-31 14:54 ` zed at lab127 dot karelia.ru
2021-07-31 16:09 ` zed at lab127 dot karelia.ru
2021-07-31 19:20 ` [Bug d/101692] Referenses in Slist are not counted by GC zed at lab127 dot karelia.ru
2021-08-01  7:58 ` zed at lab127 dot karelia.ru
2021-08-03 15:20 ` zed at lab127 dot karelia.ru
2021-08-03 15:21 ` zed at lab127 dot karelia.ru

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