|
|
afd09e |
commit 7cb54ca93cffc949b16611d5b6c66844524143d8
|
|
|
afd09e |
Author: Josh Stone <jistone@redhat.com>
|
|
|
afd09e |
Date: Thu Oct 17 16:05:25 2013 -0700
|
|
|
afd09e |
|
|
|
afd09e |
Fix DYNINST_index_lock state and ppc64 writeFunctionPtr
|
|
|
afd09e |
|
|
|
afd09e |
There are two fixes in this patch to resolve hangs that we've seen on
|
|
|
afd09e |
ppc64 tests, most notably in test_thread_5.
|
|
|
afd09e |
|
|
|
afd09e |
The first is that DYNINST_index_lock may be left in a locked state from
|
|
|
afd09e |
DYNINSTthreadIndexSLOW when DYNINST_thread_hash_size is 0. This simply
|
|
|
afd09e |
needs an unlock in that error path.
|
|
|
afd09e |
|
|
|
afd09e |
The second resolves *why* DYNINST_thread_hash_size is 0, even after it
|
|
|
afd09e |
was correctly initialized to 40. This turned out to be corruption when
|
|
|
afd09e |
the mutator writeFunctionPtr sets DYNINST_pthread_self. Those symbols
|
|
|
afd09e |
in libdyninstAPI_RT.so happen to be arranged like so:
|
|
|
afd09e |
|
|
|
afd09e |
0000000000031180 B DYNINST_pthread_self
|
|
|
afd09e |
0000000000031188 B DYNINST_sysEntry
|
|
|
afd09e |
0000000000031190 B DYNINST_thread_hash_size
|
|
|
afd09e |
|
|
|
afd09e |
So writeFunctionPtr was sending three longs: the function descriptor
|
|
|
afd09e |
correctly in DYNINST_pthread_self; the toc in DYNINST_sysEntry, a dead
|
|
|
afd09e |
variable; and the guilty 0x0 in DYNINST_thread_hash_size. The only
|
|
|
afd09e |
thing a function pointer actually needs is the function descriptor.
|
|
|
afd09e |
|
|
|
afd09e |
For comparison, on EL5 and EL6 our build has the symbols like so:
|
|
|
afd09e |
|
|
|
afd09e |
000000000002c400 B DYNINST_pthread_self
|
|
|
afd09e |
000000000002c408 B DYNINSTlinkSave
|
|
|
afd09e |
000000000002c410 B DYNINSTtocSave
|
|
|
afd09e |
000000000002c418 B DYNINST_sysEntry
|
|
|
afd09e |
000000000002c420 B DYNINST_thread_hash_tids
|
|
|
afd09e |
000000000002c428 B DYNINST_thread_hash_size
|
|
|
afd09e |
|
|
|
afd09e |
So that still clobbered data, but DYNINSTlinkSave and DYNINSTtocSave are
|
|
|
afd09e |
both unused variables -- no harm done.
|
|
|
afd09e |
|
|
|
afd09e |
Signed-off-by: Josh Stone <jistone@redhat.com>
|
|
|
afd09e |
|
|
|
afd09e |
diff --git a/dyninstAPI/src/inst-power.C b/dyninstAPI/src/inst-power.C
|
|
|
afd09e |
index c2accaf..74436ec 100644
|
|
|
afd09e |
--- a/dyninstAPI/src/inst-power.C
|
|
|
afd09e |
+++ b/dyninstAPI/src/inst-power.C
|
|
|
afd09e |
@@ -2589,20 +2589,11 @@ bool writeFunctionPtr(AddressSpace *p, Address addr, func_instance *f)
|
|
|
afd09e |
#else
|
|
|
afd09e |
// 64-bit ELF PowerPC Linux uses r2 (same as AIX) for TOC base register
|
|
|
afd09e |
if (p->getAddressWidth() == sizeof(uint64_t)) {
|
|
|
afd09e |
- Address buffer[3];
|
|
|
afd09e |
Address val_to_write = f->addr();
|
|
|
afd09e |
// Use function descriptor address, if available.
|
|
|
afd09e |
if (f->getPtrAddress()) val_to_write = f->getPtrAddress();
|
|
|
afd09e |
- assert(p->proc());
|
|
|
afd09e |
- Address toc = p->proc()->getTOCoffsetInfo(f);
|
|
|
afd09e |
- buffer[0] = val_to_write;
|
|
|
afd09e |
- buffer[1] = toc;
|
|
|
afd09e |
- buffer[2] = 0x0;
|
|
|
afd09e |
-
|
|
|
afd09e |
- if (!p->writeDataSpace((void *) addr, sizeof(buffer), buffer))
|
|
|
afd09e |
- fprintf(stderr, "%s[%d]: writeDataSpace failed\n",
|
|
|
afd09e |
- FILE__, __LINE__);
|
|
|
afd09e |
- return true;
|
|
|
afd09e |
+ return p->writeDataSpace((void *) addr,
|
|
|
afd09e |
+ sizeof(val_to_write), &val_to_write);
|
|
|
afd09e |
}
|
|
|
afd09e |
else {
|
|
|
afd09e |
// Originally copied from inst-x86.C
|
|
|
afd09e |
diff --git a/dyninstAPI_RT/src/RTthread.c b/dyninstAPI_RT/src/RTthread.c
|
|
|
afd09e |
index 9897563..2a80f58 100644
|
|
|
afd09e |
--- a/dyninstAPI_RT/src/RTthread.c
|
|
|
afd09e |
+++ b/dyninstAPI_RT/src/RTthread.c
|
|
|
afd09e |
@@ -119,6 +119,7 @@ unsigned DYNINSTthreadIndexSLOW(dyntid_t tid) {
|
|
|
afd09e |
**/
|
|
|
afd09e |
if (!DYNINST_thread_hash_size) {
|
|
|
afd09e |
//Uninitialized tramp guard.
|
|
|
afd09e |
+ tc_lock_unlock(&DYNINST_index_lock);
|
|
|
afd09e |
return DYNINST_max_num_threads;
|
|
|
afd09e |
}
|
|
|
afd09e |
|