public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/109064] New: Maximum recursion depth exceeded in std::shared_ptr xmethod
@ 2023-03-08 12:04 ks1322 at gmail dot com
  2023-03-08 16:17 ` [Bug libstdc++/109064] " ks1322 at gmail dot com
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: ks1322 at gmail dot com @ 2023-03-08 12:04 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 109064
           Summary: Maximum recursion depth exceeded in std::shared_ptr
                    xmethod
           Product: gcc
           Version: 12.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ks1322 at gmail dot com
  Target Milestone: ---

Based on
https://stackoverflow.com/questions/75652764/gdb-fails-with-python-exception-class-recursionerror-maximum-recursion-dep

Seems that trying to print unique() and use_count() in GDB for std::shared_ptr
causes infinite recursion in Python xmethods.

For this code:
```
#include <iostream>
#include <memory>

int main() {
    auto ptr = std::make_shared<int>(0);
    std::cout << ptr.use_count() << "\n";
    return 0;
}
```

Buid with:
```
g++ -g main.cc
```

Results in "maximum recursion depth exceeded" error
```
$ gdb -batch -ex "b 7" -ex r -ex "p ptr.use_count()" -ex "p ptr.unique()" a.out
Breakpoint 1 at 0x40122f: file /tmp/main.cc, line 7.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
1

Breakpoint 1, main () at /tmp/main.cc:7
7           return 0;
Python Exception <class 'RecursionError'>: maximum recursion depth exceeded
Error while looking for matching xmethod workers defined in Python.
Python Exception <class 'RecursionError'>: maximum recursion depth exceeded
Error while looking for matching xmethod workers defined in Python.
```

As a workaround xmethods can be disabled with
```
(gdb) disable xmethod
```

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

* [Bug libstdc++/109064] Maximum recursion depth exceeded in std::shared_ptr xmethod
  2023-03-08 12:04 [Bug libstdc++/109064] New: Maximum recursion depth exceeded in std::shared_ptr xmethod ks1322 at gmail dot com
@ 2023-03-08 16:17 ` ks1322 at gmail dot com
  2023-03-10 10:37 ` redi at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: ks1322 at gmail dot com @ 2023-03-08 16:17 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from ks1322 at gmail dot com ---
Looks like infinite recursion is here, SharedPtrUseCountWorker.__init__ calls
itself
```
class SharedPtrUseCountWorker(gdb.xmethod.XMethodWorker):
    "Implements std::shared_ptr<T>::use_count()"

    def __init__(self, elem_type):
        SharedPtrUseCountWorker.__init__(self, elem_type)
```

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

* [Bug libstdc++/109064] Maximum recursion depth exceeded in std::shared_ptr xmethod
  2023-03-08 12:04 [Bug libstdc++/109064] New: Maximum recursion depth exceeded in std::shared_ptr xmethod ks1322 at gmail dot com
  2023-03-08 16:17 ` [Bug libstdc++/109064] " ks1322 at gmail dot com
@ 2023-03-10 10:37 ` redi at gcc dot gnu.org
  2023-03-10 11:36 ` redi at gcc dot gnu.org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2023-03-10 10:37 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2023-03-10
           Assignee|unassigned at gcc dot gnu.org      |redi at gcc dot gnu.org
             Status|UNCONFIRMED                 |ASSIGNED

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

* [Bug libstdc++/109064] Maximum recursion depth exceeded in std::shared_ptr xmethod
  2023-03-08 12:04 [Bug libstdc++/109064] New: Maximum recursion depth exceeded in std::shared_ptr xmethod ks1322 at gmail dot com
  2023-03-08 16:17 ` [Bug libstdc++/109064] " ks1322 at gmail dot com
  2023-03-10 10:37 ` redi at gcc dot gnu.org
@ 2023-03-10 11:36 ` redi at gcc dot gnu.org
  2023-03-10 11:36 ` cvs-commit at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2023-03-10 11:36 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Unfortunately in the testsuite those errors cause the test to be ignored as
UNSUPPORTED, instead of making it FAIL:

Python Exception <class 'RecursionError'>: maximum recursion depth exceeded^M
skipping: Python Exception <class 'RecursionError'>: maximum recursion depth
exceeded^M
shared_ptr.gdb:32: Error in sourced command file:
Error while looking for matching xmethod workers defined in Python.
skipping: shared_ptr.gdb:32: Error in sourced command file:
skipping: Error while looking for matching xmethod workers defined in Python.
UNSUPPORTED: libstdc++-xmethods/shared_ptr.cc

There's a second problem in that SharedPtrUseCountWorker class as well.

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

* [Bug libstdc++/109064] Maximum recursion depth exceeded in std::shared_ptr xmethod
  2023-03-08 12:04 [Bug libstdc++/109064] New: Maximum recursion depth exceeded in std::shared_ptr xmethod ks1322 at gmail dot com
                   ` (2 preceding siblings ...)
  2023-03-10 11:36 ` redi at gcc dot gnu.org
@ 2023-03-10 11:36 ` cvs-commit at gcc dot gnu.org
  2023-03-10 11:37 ` redi at gcc dot gnu.org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-03-10 11:36 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>:

https://gcc.gnu.org/g:37c8a083d44f8123ad81a3cd411389b0b7b42ae6

commit r13-6579-g37c8a083d44f8123ad81a3cd411389b0b7b42ae6
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Fri Mar 10 11:06:25 2023 +0000

    libstdc++: Fix GDB Xmethod for std::shared_ptr::use_count() [PR109064]

    libstdc++-v3/ChangeLog:

            PR libstdc++/109064
            * python/libstdcxx/v6/xmethods.py (SharedPtrUseCountWorker):
            Remove self-recursion in __init__. Add missing _supports.
            * testsuite/libstdc++-xmethods/shared_ptr.cc: Check use_count()
            and unique().

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

* [Bug libstdc++/109064] Maximum recursion depth exceeded in std::shared_ptr xmethod
  2023-03-08 12:04 [Bug libstdc++/109064] New: Maximum recursion depth exceeded in std::shared_ptr xmethod ks1322 at gmail dot com
                   ` (3 preceding siblings ...)
  2023-03-10 11:36 ` cvs-commit at gcc dot gnu.org
@ 2023-03-10 11:37 ` redi at gcc dot gnu.org
  2023-03-20 11:54 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2023-03-10 11:37 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Fixed on trunk for now but backports to follow.

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

* [Bug libstdc++/109064] Maximum recursion depth exceeded in std::shared_ptr xmethod
  2023-03-08 12:04 [Bug libstdc++/109064] New: Maximum recursion depth exceeded in std::shared_ptr xmethod ks1322 at gmail dot com
                   ` (4 preceding siblings ...)
  2023-03-10 11:37 ` redi at gcc dot gnu.org
@ 2023-03-20 11:54 ` cvs-commit at gcc dot gnu.org
  2023-04-27 22:01 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-03-20 11:54 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Jonathan Wakely
<redi@gcc.gnu.org>:

https://gcc.gnu.org/g:07246eee2393312c187dcb4fa70d0e0785d75ae6

commit r12-9298-g07246eee2393312c187dcb4fa70d0e0785d75ae6
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Fri Mar 10 11:06:25 2023 +0000

    libstdc++: Fix GDB Xmethod for std::shared_ptr::use_count() [PR109064]

    libstdc++-v3/ChangeLog:

            PR libstdc++/109064
            * python/libstdcxx/v6/xmethods.py (SharedPtrUseCountWorker):
            Remove self-recursion in __init__. Add missing _supports.
            * testsuite/libstdc++-xmethods/shared_ptr.cc: Check use_count()
            and unique().

    (cherry picked from commit 37c8a083d44f8123ad81a3cd411389b0b7b42ae6)

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

* [Bug libstdc++/109064] Maximum recursion depth exceeded in std::shared_ptr xmethod
  2023-03-08 12:04 [Bug libstdc++/109064] New: Maximum recursion depth exceeded in std::shared_ptr xmethod ks1322 at gmail dot com
                   ` (5 preceding siblings ...)
  2023-03-20 11:54 ` cvs-commit at gcc dot gnu.org
@ 2023-04-27 22:01 ` cvs-commit at gcc dot gnu.org
  2023-04-27 23:04 ` cvs-commit at gcc dot gnu.org
  2023-04-27 23:05 ` redi at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-04-27 22:01 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Jonathan Wakely
<redi@gcc.gnu.org>:

https://gcc.gnu.org/g:3ca17b2b6be8e9bab2ee06636826d92604104475

commit r11-10657-g3ca17b2b6be8e9bab2ee06636826d92604104475
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Fri Mar 10 11:06:25 2023 +0000

    libstdc++: Fix GDB Xmethod for std::shared_ptr::use_count() [PR109064]

    libstdc++-v3/ChangeLog:

            PR libstdc++/109064
            * python/libstdcxx/v6/xmethods.py (SharedPtrUseCountWorker):
            Remove self-recursion in __init__. Add missing _supports.
            * testsuite/libstdc++-xmethods/shared_ptr.cc: Check use_count()
            and unique().

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

* [Bug libstdc++/109064] Maximum recursion depth exceeded in std::shared_ptr xmethod
  2023-03-08 12:04 [Bug libstdc++/109064] New: Maximum recursion depth exceeded in std::shared_ptr xmethod ks1322 at gmail dot com
                   ` (6 preceding siblings ...)
  2023-04-27 22:01 ` cvs-commit at gcc dot gnu.org
@ 2023-04-27 23:04 ` cvs-commit at gcc dot gnu.org
  2023-04-27 23:05 ` redi at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-04-27 23:04 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Jonathan Wakely
<redi@gcc.gnu.org>:

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

commit r10-11320-gcc75195ee8811d6c48f05727c170916c0adc227b
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Fri Mar 10 11:06:25 2023 +0000

    libstdc++: Fix GDB Xmethod for std::shared_ptr::use_count() [PR109064]

    libstdc++-v3/ChangeLog:

            PR libstdc++/109064
            * python/libstdcxx/v6/xmethods.py (SharedPtrUseCountWorker):
            Remove self-recursion in __init__. Add missing _supports.
            * testsuite/libstdc++-xmethods/shared_ptr.cc: Check use_count()
            and unique().

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

* [Bug libstdc++/109064] Maximum recursion depth exceeded in std::shared_ptr xmethod
  2023-03-08 12:04 [Bug libstdc++/109064] New: Maximum recursion depth exceeded in std::shared_ptr xmethod ks1322 at gmail dot com
                   ` (7 preceding siblings ...)
  2023-04-27 23:04 ` cvs-commit at gcc dot gnu.org
@ 2023-04-27 23:05 ` redi at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2023-04-27 23:05 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |10.5
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Fixed for 12.3, 11.4 and 10.5

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

end of thread, other threads:[~2023-04-27 23:05 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-08 12:04 [Bug libstdc++/109064] New: Maximum recursion depth exceeded in std::shared_ptr xmethod ks1322 at gmail dot com
2023-03-08 16:17 ` [Bug libstdc++/109064] " ks1322 at gmail dot com
2023-03-10 10:37 ` redi at gcc dot gnu.org
2023-03-10 11:36 ` redi at gcc dot gnu.org
2023-03-10 11:36 ` cvs-commit at gcc dot gnu.org
2023-03-10 11:37 ` redi at gcc dot gnu.org
2023-03-20 11:54 ` cvs-commit at gcc dot gnu.org
2023-04-27 22:01 ` cvs-commit at gcc dot gnu.org
2023-04-27 23:04 ` cvs-commit at gcc dot gnu.org
2023-04-27 23:05 ` redi 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).