Re-acquire GIL earlier in gdbpy_parse_and_eval
authorTom Tromey <tromey@adacore.com>
Thu, 27 Jul 2023 13:54:18 +0000 (07:54 -0600)
committerTom Tromey <tromey@adacore.com>
Fri, 28 Jul 2023 12:15:30 +0000 (06:15 -0600)
commit0c8a0b88d18d9c8d6cd52bd1a56d6ab88570f287
tree62a57b6dae1eed0da48c0622e7b9ae2e44d7820a
parent95b83567a4500c9cc14480dc171cf1d26a1555a6
Re-acquire GIL earlier in gdbpy_parse_and_eval

Tom de Vries filed a bug about an intermittent gdb DAP failure -- and
coincidentally, at the same time, Alexandra Hájková sent email about a
somewhat similar failure.

After looking into this for a while (with no results) using ASan and
valgrind, I found that setting PYTHONMALLOC=malloc_debug found the bug
instantly.

The problem is that gdbpy_parse_and_eval releases the GIL while
calling parse_and_eval, but fails to re-acquire it before calling
value_to_value_object.  This is easily fixed by introducing a new
scope.

I wonder whether the test suite should unconditionally set
PYTHONMALLOC=malloc_debug.

Tested-by: Tom de Vries <tdevries@suse.de>
Reviewed-By: Tom de Vries <tdevries@suse.de>
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30686
gdb/python/python.c