From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 215763847827; Sun, 1 Aug 2021 07:58:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 215763847827 From: "zed at lab127 dot karelia.ru" To: gcc-bugs@gcc.gnu.org Subject: [Bug d/101692] Referenses in Slist are not counted by GC Date: Sun, 01 Aug 2021 07:58:14 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: d X-Bugzilla-Version: 8.4.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: zed at lab127 dot karelia.ru X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: ibuclaw at gdcproject dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 01 Aug 2021 07:58:15 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D101692 --- Comment #7 from Eugene Zhiganov --- (In reply to Eugene Zhiganov from comment #5) > This rxMachines array is just for the purpose of holding references, > since references in linked list are not counted at all by GC. Maybe I am not right here... Things a little bit more complicated. Initially objects were created like this: auto rxPool =3D new RestRoom(); for (int k =3D 0; k < maxClients; k++) { auto sm =3D new RxSm(rxPool); sm.run(); } After the the loop 'sm' is out of scope and all these just created instances are marked for deletion I guess. RxSm has 3 states, INIT, IDLE and WORK. run() method calls enter function for INIT state. In this function rx do some initalization and send a message to self (message means 'now go to IDLE state'). A little bit later, when program enters event loop and starts processing messages, that message is processed, machine enters IDLE state, where it puts itself into a pool like this: void rxIdleEnter() { rR.put(this); // adds 'this' pointer to Slist } But at this moment the instance is already marked for deletion... and hence reference in the list is not counted either because of * object was marked for deletion or because of * references in Slist are not counted at all (???)=