This is the mail archive of the
archer@sourceware.org
mailing list for the Archer project.
Should users be protected from badly-recursive pretty printers?
- From: ppluzhnikov at google dot com (Paul Pluzhnikov)
- To: archer at sourceware dot org
- Cc: ppluzhnikov at google dot com
- Date: Tue, 4 Nov 2008 11:39:25 -0800 (PST)
- Subject: Should users be protected from badly-recursive pretty printers?
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=google.com; s=beta;t=1225827572; bh=MiTxu2tSbA2HjskIc/PTEsaLbto=;h=DomainKey-Signature:To:Cc:Subject:Message-Id:Date:From; b=XkwtAt94D8pzbHDUYRe5dPjGdO+0VpyQL+wEjt2hNF8L7H9Hg0WygSeVYTovY2PTc9AbfceLVIy6seGAmMTYrA==
- Domainkey-signature: a=rsa-sha1; s=beta; d=google.com; c=nofws; q=dns;h=to:cc:subject:message-id:date:from;b=iXjNi/hf0RNPz40qr/0zl2/STNnrwfZx1CuvBhs7rHcvZKUpjUkYx0Q1ORa0aBMMY8zMDg4N8OstxWKKumbE4w==
Greetings,
Consider:
--- simple.c --- cut ---
#include <string.h>
int main()
{
union U {
char s[sizeof(int)];
int x;
} u, v;
strcpy(u.s, "abc");
v.x = 0xABCDEF;
return 0; // break here
}
--- simple.c --- cut ---
--- simple2.py --- cut ---
def pp_u(val):
return "<" + str(val) + ">"
gdb.cli_pretty_printers['^union U$'] = pp_u
--- simple2.py --- cut ---
Above pretty printer is infinitely recursive, even though this may
not be apparent to a casual GDB user.
Using that pretty printer also produces "strange" result (there is no
"out-of-stack due to recursion too deep" inidication):
(gdb) p u
$1 =
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<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