* [Qemu-devel] [PATCH] readline: don't free completions in readline_free()
@ 2018-01-18 10:41 Greg Kurz
2018-01-18 10:45 ` Paolo Bonzini
0 siblings, 1 reply; 3+ messages in thread
From: Greg Kurz @ 2018-01-18 10:41 UTC (permalink / raw)
To: qemu-devel
Cc: Paolo Bonzini, Marc-André Lureau,
Philippe Mathieu-Daudé,
Dr. David Alan Gilbert
Since commit e5dc1a6c6c43, QEMU aborts on exit if completion was used
in the monitor:
*** Error in `obj/ppc64-softmmu/qemu-system-ppc64': double free or
corruption (fasttop): 0x00000100331069d0 ***
#0 0x00007ffff267eff0 in raise () from /lib64/libc.so.6
#1 0x00007ffff268136c in abort () from /lib64/libc.so.6
#2 0x00007ffff26c6b48 in __libc_message () from /lib64/libc.so.6
#3 0x00007ffff26d69fc in free () from /lib64/libc.so.6
#4 0x00007ffff28cb794 in g_free () from /lib64/libglib-2.0.so.0
#5 0x00000000106230e4 in readline_free (rs=0x11223e60) at
/home/greg/Work/qemu/qemu-spapr/util/readline.c:514
#6 0x0000000010074cc4 in monitor_data_destroy (mon=0x1121c9f0) at
/home/greg/Work/qemu/qemu-spapr/monitor.c:586
#7 0x000000001007bcc8 in monitor_cleanup () at
/home/greg/Work/qemu/qemu-spapr/monitor.c:4125
#8 0x0000000010291274 in main (argc=<optimized out>,
argv=<optimized out>, envp=<optimized out>) at
/home/greg/Work/qemu/qemu-spapr/vl.c:4795
Completion strings are not persistent accross completions (why would
they?). They are allocated under readline_completion(), which already
takes care of freeing them before returning.
Maybe all completion related bits should be moved out of ReadLineState
to a dedicated structure ?
In the meantime, let's drop the offending lines from readline_free()
to fix the crash.
Signed-off-by: Greg Kurz <groug@kaod.org>
---
util/readline.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/util/readline.c b/util/readline.c
index 24ec839854cf..ec91ee0fea6f 100644
--- a/util/readline.c
+++ b/util/readline.c
@@ -510,9 +510,6 @@ void readline_free(ReadLineState *rs)
for (i = 0; i < READLINE_MAX_CMDS; i++) {
g_free(rs->history[i]);
}
- for (i = 0; i < READLINE_MAX_COMPLETIONS; i++) {
- g_free(rs->completions[i]);
- }
g_free(rs);
}
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] readline: don't free completions in readline_free()
2018-01-18 10:41 [Qemu-devel] [PATCH] readline: don't free completions in readline_free() Greg Kurz
@ 2018-01-18 10:45 ` Paolo Bonzini
2018-01-18 11:16 ` Philippe Mathieu-Daudé
0 siblings, 1 reply; 3+ messages in thread
From: Paolo Bonzini @ 2018-01-18 10:45 UTC (permalink / raw)
To: Greg Kurz, qemu-devel
Cc: Marc-André Lureau, Philippe Mathieu-Daudé,
Dr. David Alan Gilbert
On 18/01/2018 11:41, Greg Kurz wrote:
> Since commit e5dc1a6c6c43, QEMU aborts on exit if completion was used
> in the monitor:
>
> *** Error in `obj/ppc64-softmmu/qemu-system-ppc64': double free or
> corruption (fasttop): 0x00000100331069d0 ***
>
> #0 0x00007ffff267eff0 in raise () from /lib64/libc.so.6
> #1 0x00007ffff268136c in abort () from /lib64/libc.so.6
> #2 0x00007ffff26c6b48 in __libc_message () from /lib64/libc.so.6
> #3 0x00007ffff26d69fc in free () from /lib64/libc.so.6
> #4 0x00007ffff28cb794 in g_free () from /lib64/libglib-2.0.so.0
> #5 0x00000000106230e4 in readline_free (rs=0x11223e60) at
> /home/greg/Work/qemu/qemu-spapr/util/readline.c:514
> #6 0x0000000010074cc4 in monitor_data_destroy (mon=0x1121c9f0) at
> /home/greg/Work/qemu/qemu-spapr/monitor.c:586
> #7 0x000000001007bcc8 in monitor_cleanup () at
> /home/greg/Work/qemu/qemu-spapr/monitor.c:4125
> #8 0x0000000010291274 in main (argc=<optimized out>,
> argv=<optimized out>, envp=<optimized out>) at
> /home/greg/Work/qemu/qemu-spapr/vl.c:4795
>
> Completion strings are not persistent accross completions (why would
> they?). They are allocated under readline_completion(), which already
> takes care of freeing them before returning.
>
> Maybe all completion related bits should be moved out of ReadLineState
> to a dedicated structure ?
>
> In the meantime, let's drop the offending lines from readline_free()
> to fix the crash.
>
> Signed-off-by: Greg Kurz <groug@kaod.org>
> ---
> util/readline.c | 3 ---
> 1 file changed, 3 deletions(-)
>
> diff --git a/util/readline.c b/util/readline.c
> index 24ec839854cf..ec91ee0fea6f 100644
> --- a/util/readline.c
> +++ b/util/readline.c
> @@ -510,9 +510,6 @@ void readline_free(ReadLineState *rs)
> for (i = 0; i < READLINE_MAX_CMDS; i++) {
> g_free(rs->history[i]);
> }
> - for (i = 0; i < READLINE_MAX_COMPLETIONS; i++) {
> - g_free(rs->completions[i]);
> - }
> g_free(rs);
> }
>
>
Queued, thanks.
Paolo
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] readline: don't free completions in readline_free()
2018-01-18 10:45 ` Paolo Bonzini
@ 2018-01-18 11:16 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 3+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-01-18 11:16 UTC (permalink / raw)
To: Paolo Bonzini, Greg Kurz, qemu-devel
Cc: Marc-André Lureau, Dr. David Alan Gilbert
On 01/18/2018 07:45 AM, Paolo Bonzini wrote:
> On 18/01/2018 11:41, Greg Kurz wrote:
>> Since commit e5dc1a6c6c43, QEMU aborts on exit if completion was used
>> in the monitor:
>>
>> *** Error in `obj/ppc64-softmmu/qemu-system-ppc64': double free or
>> corruption (fasttop): 0x00000100331069d0 ***
>>
>> #0 0x00007ffff267eff0 in raise () from /lib64/libc.so.6
>> #1 0x00007ffff268136c in abort () from /lib64/libc.so.6
>> #2 0x00007ffff26c6b48 in __libc_message () from /lib64/libc.so.6
>> #3 0x00007ffff26d69fc in free () from /lib64/libc.so.6
>> #4 0x00007ffff28cb794 in g_free () from /lib64/libglib-2.0.so.0
>> #5 0x00000000106230e4 in readline_free (rs=0x11223e60) at
>> /home/greg/Work/qemu/qemu-spapr/util/readline.c:514
>> #6 0x0000000010074cc4 in monitor_data_destroy (mon=0x1121c9f0) at
>> /home/greg/Work/qemu/qemu-spapr/monitor.c:586
>> #7 0x000000001007bcc8 in monitor_cleanup () at
>> /home/greg/Work/qemu/qemu-spapr/monitor.c:4125
>> #8 0x0000000010291274 in main (argc=<optimized out>,
>> argv=<optimized out>, envp=<optimized out>) at
>> /home/greg/Work/qemu/qemu-spapr/vl.c:4795
>>
>> Completion strings are not persistent accross completions (why would
>> they?). They are allocated under readline_completion(), which already
>> takes care of freeing them before returning.
Oops I missed that.
>>
>> Maybe all completion related bits should be moved out of ReadLineState
>> to a dedicated structure ?
>>
>> In the meantime, let's drop the offending lines from readline_free()
>> to fix the crash.
>>
>> Signed-off-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>> ---
>> util/readline.c | 3 ---
>> 1 file changed, 3 deletions(-)
>>
>> diff --git a/util/readline.c b/util/readline.c
>> index 24ec839854cf..ec91ee0fea6f 100644
>> --- a/util/readline.c
>> +++ b/util/readline.c
>> @@ -510,9 +510,6 @@ void readline_free(ReadLineState *rs)
>> for (i = 0; i < READLINE_MAX_CMDS; i++) {
>> g_free(rs->history[i]);
>> }
>> - for (i = 0; i < READLINE_MAX_COMPLETIONS; i++) {
>> - g_free(rs->completions[i]);
>> - }
>> g_free(rs);
>> }
>>
>>
>
> Queued, thanks.
>
> Paolo
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-01-18 11:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-18 10:41 [Qemu-devel] [PATCH] readline: don't free completions in readline_free() Greg Kurz
2018-01-18 10:45 ` Paolo Bonzini
2018-01-18 11:16 ` Philippe Mathieu-Daudé
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.