public inbox for gdb-prs@sourceware.org help / color / mirror / Atom feed
From: "pmuldoon at redhat dot com" <sourceware-bugzilla@sourceware.org> To: gdb-prs@sourceware.org Subject: [Bug python/10344] Pretty printers that call into inferior could crash GDB Date: Thu, 24 Sep 2009 16:15:00 -0000 [thread overview] Message-ID: <20090924161542.27392.qmail@sourceware.org> (raw) In-Reply-To: <20090629213421.10344.ppluzhnikov@google.com> ------- Additional Comments From pmuldoon at redhat dot com 2009-09-24 16:15 ------- Increasing the MAX_UI_OUT_LEVELS will fix the bug as reported, but it will not help when a situation occurs where the the printers can end up recursing (and gobbling up the ui levels). Example. --- cut --- t2.cc --- #include <stdio.h> struct Foo; struct Recurse; struct Foo { Foo() : p(0) { } const char *print(Recurse b) const; char **p; }; struct Recurse { Recurse (): p (0) { } const char *crash(Foo f) const; char **p; }; const char *Recurse::crash(Foo f) const { return *p; // crash as well } const char *Foo::print(Recurse b) const { return *p; // crash! } char **bar(Foo f) { return f.p; } int main() { Foo f; Recurse b; bar(f); return 0; } --- cut --- t2.py --- # Pretty printer for Foo, which calls into inferior import gdb class FooPrinter: def __init__(self, val): self.val = val def to_string(self): x = self.val.address return gdb.parse_and_eval('Foo::print(%s,f)' % str(x)) class RecursePrinter: def __init__(self, val): self.val = val def to_string(self): x = self.val.address return gdb.parse_and_eval('Recurse::crash(%s,b)' % str(x)) def lookup(val): if str(val.type) == "Foo": return FooPrinter(val) else: if str(val.type) == "Recurse": return RecursePrinter(val) else: return None gdb.pretty_printers = [ lookup ] I also increased the max MAX_UI_OUT_LEVELS to 15. But it does not matter, it can be 1000, the result is the same. -- Test case ./gdb -ex 'source /home/pmuldoon/pp/t.py' -ex 'break bar' -ex 'run' /home/pmuldoon/pp/t2 Output Breakpoint 1, bar (f= Program received signal SIGSEGV, Segmentation fault. 0x000000000040057f in Foo::print (this=0x7fffffffe170, b= Program received signal SIGSEGV, Segmentation fault. 0x0000000000400567 in Recurse::crash (this=0x7fffffffe0e0, f= Program received signal SIGSEGV, Segmentation fault. 0x000000000040057f in Foo::print (this=0x7fffffffe050, b= Program received signal SIGSEGV, Segmentation fault. 0x0000000000400567 in Recurse::crash ( ../../archer/gdb/ui-out.c:129: internal-error: push_level: Assertion `uiout->level >= 0 && uiout->level < MAX_UI_OUT_LEVELS' failed. A problem internal to GDB has been detected, further debugging may prove unreliable. Quit this debugging session? (y or n) q -- http://sourceware.org/bugzilla/show_bug.cgi?id=10344 ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is.
next prev parent reply other threads:[~2009-09-24 16:15 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2009-06-29 21:34 [Bug c++/10344] New: " ppluzhnikov at google dot com 2009-06-29 21:41 ` [Bug c++/10344] " ppluzhnikov at google dot com 2009-08-26 13:47 ` pmuldoon at redhat dot com 2009-08-26 13:48 ` pmuldoon at redhat dot com 2009-09-22 10:44 ` [Bug python/10344] " pmuldoon at redhat dot com 2009-09-22 19:47 ` pmuldoon at redhat dot com 2009-09-24 16:15 ` pmuldoon at redhat dot com [this message] 2009-11-02 17:27 ` pmuldoon at redhat dot com [not found] <bug-10344-4717@http.sourceware.org/bugzilla/> 2013-03-05 20:16 ` kdudka at redhat dot com 2013-05-22 12:39 ` pmuldoon at redhat dot com
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=20090924161542.27392.qmail@sourceware.org \ --to=sourceware-bugzilla@sourceware.org \ --cc=gdb-prs@sourceware.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: linkBe 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).