public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "ks1322 at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/109064] New: Maximum recursion depth exceeded in std::shared_ptr xmethod
Date: Wed, 08 Mar 2023 12:04:27 +0000	[thread overview]
Message-ID: <bug-109064-4@http.gcc.gnu.org/bugzilla/> (raw)

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
```

             reply	other threads:[~2023-03-08 12:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-08 12:04 ks1322 at gmail dot com [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-109064-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).