This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 5/5] Fix memory leak in exception code
On 4/25/19 7:30 PM, Tom Tromey wrote:
> Pedro> Why fix it like this, instead of fixing it like in the guile patch?
> Pedro> I'd think you could even use a common POD type for both guile and here?
>
> Tom> No particularly good reason. I'll change it.
>
> Actually, there was a reason. Converting an exception to a POD means
> copying the string contents.
>
> Perhaps that isn't a big concern. I guess only exceptions escaping to
> the top level will do this.
Yeah, I don't think it's a concern here.
It seemed better than adding a global, thinking about threads, but now
that I think a bit more about it, I realize that we won't ever be
able to have multiple threads call into readline simultaneously -- it's
full of global state. So I'm fine with your patch as is, afterall.
I think it'd be good to extend the comment, something like:
- /* This is static to avoid undefined behavior when calling
- longjmp. */
+ /* This is static to avoid undefined behavior when calling
+ longjmp -- gdb_exception has a dtor with side effects. */
Thanks,
Pedro Alves