public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/107965] New: libstdc++ Python Pretty-Printers: Many Exceptions From Uninitialized Structures
@ 2022-12-04 19:46 gustaf.waldemarson at gmail dot com
  2022-12-04 20:04 ` [Bug libstdc++/107965] " pinskia at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: gustaf.waldemarson at gmail dot com @ 2022-12-04 19:46 UTC (permalink / raw)
  To: gcc-bugs

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)

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

end of thread, other threads:[~2023-01-17 20:25 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-04 19:46 [Bug libstdc++/107965] New: libstdc++ Python Pretty-Printers: Many Exceptions From Uninitialized Structures gustaf.waldemarson at gmail dot com
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

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