Fix segv when referencing a value added to history after a Guile garbage collect.

* value.c (record_latest_value): Call release_value_or_incref
	instead of release_value.

	testsuite/
	* gdb.guile/scm-value.exp (test_value_in_inferior): Verify value added
	to history survives a gc.
This commit is contained in:
Doug Evans 2014-03-13 09:24:19 -07:00
parent c307e84195
commit 350e1a768c
4 changed files with 20 additions and 1 deletions

View File

@ -1,3 +1,8 @@
2014-03-13 Doug Evans <xdje42@gmail.com>
* value.c (record_latest_value): Call release_value_or_incref
instead of release_value.
2014-03-13 Pedro Alves <palves@redhat.com>
* procfs.c (procfs_target): Don't override to_shortname,

View File

@ -1,3 +1,9 @@
2014-03-13 Ludovic Courtès <ludo@gnu.org>
Doug Evans <xdje42@gmail.com>
* gdb.guile/scm-value.exp (test_value_in_inferior): Verify value added
to history survives a gc.
2014-03-13 Pedro Alves <palves@redhat.com>
* gdb.base/default.exp: Don't test "target procfs".

View File

@ -67,6 +67,10 @@ proc test_value_in_inferior {} {
gdb_test "gu (history-ref i)" "#<gdb:value 42>"
gdb_test "p \$" "= 42"
# Verify the recorded history value survives a gc.
gdb_test_no_output "guile (gc)"
gdb_test "p \$\$" "= 42"
# Test dereferencing the argv pointer.
# Just get inferior variable argv the value history, available to guile.

View File

@ -1659,7 +1659,11 @@ record_latest_value (struct value *val)
from. This is a bit dubious, because then *&$1 does not just return $1
but the current contents of that location. c'est la vie... */
val->modifiable = 0;
release_value (val);
/* The value may have already been released, in which case we're adding a
new reference for its entry in the history. That is why we call
release_value_or_incref here instead of release_value. */
release_value_or_incref (val);
/* Here we treat value_history_count as origin-zero
and applying to the value being stored now. */