public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "gustaf.waldemarson at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/107965] New: libstdc++ Python Pretty-Printers: Many Exceptions From Uninitialized Structures
Date: Sun, 04 Dec 2022 19:46:39 +0000	[thread overview]
Message-ID: <bug-107965-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 107965
           Summary: libstdc++ Python Pretty-Printers: Many Exceptions From
                    Uninitialized Structures
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gustaf.waldemarson at gmail dot com
  Target Milestone: ---

Created attachment 54008
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54008&action=edit
Python stack-traces and memory errors

Hello,

I've been having a bit of an odd issue with Python pretty-printers
bundled together with libstdc++(-v3). Truthfully though, I'm not really
sure if this is a bug, but anyways:

Given the following simple `gdbinit` that only initializes the pretty
printers and enables Python stack-traces:

```
python
import os
import re
import sys
import os.path
import textwrap
import gdb
import gdb.types
import gdb.printing

home          = os.environ.get("HOME", "~")
default_path  = os.path.join(home, "git", "installs")
objects_dir   = os.environ.get("objects_dir", default_path)
python_addons = os.path.join(objects_dir, "gcc", "libstdc++-v3", "python")

if os.path.isdir(python_addons):
  print("Installing libstdcxx printers...")
  sys.path.insert(0, python_addons)
  from libstdcxx.v6.printers import register_libstdcxx_printers
  register_libstdcxx_printers(None)
end

set python print-stack full
```

and this simple C++ file:

    #include <vector>
    #include <string>
    #include <iostream>

    using namespace std;

    int main(void)
    {
        vector<string> test{"test", "test2"};
        string blabla = "hello";
        int b = 2;

        std::cout << blabla << " "
                  << b << " "
                  << test[0] << " " << test[1] << std::endl;

        return 0;
    }

Compile it and start debugging:

```
g++ -g3 test.cpp
gdb -q a.out
(gdb) start
(gdb) info locals
```

At `info locals` I get a lot of memory related errors, presumably
because none of the local variables have been initialized, but I
also get a large number of Python exceptions; following the Python
print-stack-trace reveals a possible error here:

```
  File
"/home/xaldew/git/installs/gcc/libstdc++-v3/python/libstdcxx/v6/printers.py",
line 971, in to_string
    return ptr.lazy_string (length = length)
OverflowError: int too big to convert
```

I had a look at that file but could not find any obvious errors. Is this
behavior intended for uninitialized local variables?

(The complete log-file of the error is attached)

             reply	other threads:[~2022-12-04 19:46 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-04 19:46 gustaf.waldemarson at gmail dot com [this message]
2022-12-04 20:04 ` [Bug libstdc++/107965] " pinskia at gcc dot gnu.org
2022-12-05  8:24 ` redi at gcc dot gnu.org
2022-12-05  8:45 ` rguenth at gcc dot gnu.org
2022-12-05  8:48 ` rguenth at gcc dot gnu.org
2022-12-05  9:42 ` [Bug debug/107965] " redi at gcc dot gnu.org
2022-12-05 10:37 ` redi at gcc dot gnu.org
2023-01-17 19:37 ` gustaf.waldemarson at gmail dot com
2023-01-17 20:25 ` jason 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-107965-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).