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)