public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug cli/28041] New: Memory leak upon prefix redefinition
@ 2021-07-01 13:44 quentin at minster dot io
2021-07-01 13:45 ` [Bug cli/28041] " quentin at minster dot io
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: quentin at minster dot io @ 2021-07-01 13:44 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=28041
Bug ID: 28041
Summary: Memory leak upon prefix redefinition
Product: gdb
Version: HEAD
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: cli
Assignee: unassigned at sourceware dot org
Reporter: quentin at minster dot io
Target Milestone: ---
Created attachment 13522
--> https://sourceware.org/bugzilla/attachment.cgi?id=13522&action=edit
test.gdb
>From Python, when defining a prefix/command with the same name as an existing
prefix, the existing prefix gets deleted but not its subcommands. This results
in a memory leak, or in strange behavior if some Python objects still refer to
the undeleted-but-uninvokable subcommand.
Attached is a sample test.gdb script that demonstrates the issue (works at
least on `gdb-10-branch` HEAD, 10.2 & 10.1): after redefinition of prefix
"foo", the Python object for command "foo bar", though unreferenced, is not
deleted.
Also, it is still reachable through the "bar" alias, which is confusing because
the new prefix "foo" doesn't contain any subcommands.
Buggy output:
$ gdb -q -x test.gdb
DEL PREFIX foo
HOOK foo
COMMAND foo
HOOK foo bar
COMMAND foo bar
This issue doesn't seem to arise when defining the prefixes/commands using
`define` and `define-prefix`, because re-definition of an existing prefix just
seems to modify the existing prefix.
Attached is also a patch to fix this issue: when deleting a prefix in
`delete_cmd()`, also delete all its subcommands and their aliases.
After applying the fix, the subcommands of the deleted prefix are indeed
deleted (and their Python objects released), as are their aliases, as is
illustrated by the same sample test.gdb script.
Fixed output:
$ gdb -q -x test.gdb
DEL PREFIX foo
DEL COMMAND foo bar
HOOK foo
COMMAND foo
test.gdb:53: Error in sourced command file:
Undefined command: "bar". Try "help".
Please feel free to request more details, or suggest corrections/improvements
to the patch.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug cli/28041] Memory leak upon prefix redefinition
2021-07-01 13:44 [Bug cli/28041] New: Memory leak upon prefix redefinition quentin at minster dot io
@ 2021-07-01 13:45 ` quentin at minster dot io
2021-07-01 13:46 ` quentin at minster dot io
2021-07-05 1:32 ` simark at simark dot ca
2 siblings, 0 replies; 4+ messages in thread
From: quentin at minster dot io @ 2021-07-01 13:45 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=28041
--- Comment #1 from Quentin Minster <quentin at minster dot io> ---
Created attachment 13523
--> https://sourceware.org/bugzilla/attachment.cgi?id=13523&action=edit
0001-gdb-Fix-memory-leak-of-subcommands-when-deleting-a-p.patch
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug cli/28041] Memory leak upon prefix redefinition
2021-07-01 13:44 [Bug cli/28041] New: Memory leak upon prefix redefinition quentin at minster dot io
2021-07-01 13:45 ` [Bug cli/28041] " quentin at minster dot io
@ 2021-07-01 13:46 ` quentin at minster dot io
2021-07-05 1:32 ` simark at simark dot ca
2 siblings, 0 replies; 4+ messages in thread
From: quentin at minster dot io @ 2021-07-01 13:46 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=28041
Quentin Minster <quentin at minster dot io> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |quentin at minster dot io
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug cli/28041] Memory leak upon prefix redefinition
2021-07-01 13:44 [Bug cli/28041] New: Memory leak upon prefix redefinition quentin at minster dot io
2021-07-01 13:45 ` [Bug cli/28041] " quentin at minster dot io
2021-07-01 13:46 ` quentin at minster dot io
@ 2021-07-05 1:32 ` simark at simark dot ca
2 siblings, 0 replies; 4+ messages in thread
From: simark at simark dot ca @ 2021-07-05 1:32 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=28041
Simon Marchi <simark at simark dot ca> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |simark at simark dot ca
--- Comment #2 from Simon Marchi <simark at simark dot ca> ---
Hi Quentin,
If you'd like to get your patch reviewed, please send your patch to the
gdb-patches list. See: https://sourceware.org/gdb/wiki/ContributionChecklist
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-07-05 1:32 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-01 13:44 [Bug cli/28041] New: Memory leak upon prefix redefinition quentin at minster dot io
2021-07-01 13:45 ` [Bug cli/28041] " quentin at minster dot io
2021-07-01 13:46 ` quentin at minster dot io
2021-07-05 1:32 ` simark at simark dot ca
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).