Original code was accessing rs_cache memory without holding a lock
in some cases. If there was sufficient cache pressure, entry being
accessed may be overwritten by another thread, resulting in a data
race.
We now make a thread local copy of the data, before releasing the
lock. If we end up supporting UNW_CACHE_PER_THREAD properly
in the future, this memcpy should be unnecessary.
Greetings,
Attached patch is rather on the obvious side: setting caching policy and
than doing nothing is pointless; we'd better acutally test that it works!
Tested on Linux/x86_64.
Thanks,
--
Paul Pluzhnikov
Currently, libunwind allocates several PATH_MAX entries on stack, while
trying to find a binary via /proc/.../maps.
However stack space may be at premium (especially when sigaltstack is used),
and PATH_MAX on Linux is 4096, while SIGSTKSZ is only 8192 on x86.
Attached patch eliminates multiple PATH_MAX stack allocations, and simplifies
code in maps_next, at the cost of being unable to do anything if we can't
mmap one page. It appears to me that under such low-memory conditions,
libunwind will fail shortly elsewhere anyway.
This patch also disables more of debug_frame-handling code when
CONFIG_DEBUG_FRAME is undefined.
Tested on Linux/x86_64 with and without CONFIG_DEBUG_FRAME, no regressions.
Provide a special implementation for ia64, because the unwind
information is such that an IP adjustment is not necessary before
looking up unwind info.
Bad things happen if libunwind only provides parts of the ABI and
the rest come from libgcc.
Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
getcontext in libc.
Also cleanup the namespace (check-name-space passes on x86_64 now).
Replace uses of offsets.h with ucontext_i.h.
Rename _x86_64_setcontext to _Ux86_64_setcontext.
TBD: Add CFI annotations for get/setcontext.
Signed-off-by: Paul Pluzhnikov <ppluzhnikov@google.com>
Signed-off-by: Arun Sharma <arun.sharma@google.com>
* src/arm/unwind_i (arm_lock, arm_local_resume): Define.
* src/ptrace/_UPT_find_proc_info.c: Handle ARM like X86 etc.
* tests/flush-cache.S (flush_cache): Add (dummy) ARM-version.
ARM does need executable stack, even on Linux...
Signed-off-by: Anderson Lizardo <anderson.lizardo@indt.org.br>
Signed-off-by: Bruna Moreira <bruna.moreira@indt.org.br>
- Gtest-bt: like on x86/-64, the stack size passed to sigaltstack() is
too small for ARM thus causing segmentation fault due to stack
overflow.
- Gtest-dyn1: code size definition of dynamic function (template()) on
testcase is too big for ARM architecture so memcpy() reads invalid
memory causing random crashes (segmentation fault). A better
solution would be to compile the function in a separate binary,
mmap() it and memcpy() from it instead, so maximum size is known for
sure.
- check-name-space.in: fix some "bashisms", it causes the script to
fail to run on N8XX's busybox shell.
Signed-off-by: Anderson Lizardo <anderson.lizardo@indt.org.br>
Signed-off-by: Bruna Moreira <bruna.moreira@indt.org.br>
On some systems executable stacks are denied. Since libunwind and the
tests don't actually need executable stacks this patch marks all
assembly files as not needing it.
The original patch comes from frysk:
2007-04-05 Jan Kratochvil <jan.kratochvil@redhat.com>
* src/hppa/getcontext.S, src/hppa/setcontext.S, src/hppa/siglongjmp.S,
src/ia64/Ginstall_cursor.S, src/ia64/Linstall_cursor.S,
src/ia64/dyn_info_list.S, src/ia64/getcontext.S, src/ia64/longjmp.S,
src/ia64/setjmp.S, src/ia64/siglongjmp.S, src/ia64/sigsetjmp.S,
src/ppc64/longjmp.S, src/ppc64/siglongjmp.S, src/x86/longjmp.S,
src/x86/siglongjmp.S, src/x86_64/longjmp.S, src/x86_64/setcontext.S,
src/x86_64/siglongjmp.S: Stack should be non-executable, for SELinux.
I added a couple more markers for new files in current libunwind.
Before this patch you would get the following on selinux enabled
systems without allow_exec_stack: error while loading shared
libraries:
libunwind.so.7: cannot enable executable stack as shared object
requires: Permission denied
After the patch that error disappears and all test results are similar
to the results on systems without executable stack protection.
* tests/ia64-test-setjmp.c (doit): New forward declaration.
(doit_pointer): New function pointer variable initialized to DOIT.
(doit): Self-call made by an unoptimizable volatile indirect call.
* tests/test-ptrace.c (target_pid_kill): New function.
(target_pid, main): TARGET_PID made static, for target_pid_kill ().
(main): Register target_pid_kill () for atexit(3).
2007-04-04 Jan Kratochvil <jan.kratochvil@redhat.com>
* tests/Gtest-dyn1.c, tests/test-async-sig.c, tests/test-ptrace.c:
Fixed lockups on broken libunwind (as ppc64 is).
2007-03-07 Jan Kratochvil <jan.kratochvil@redhat.com>
* tests/test-async-sig.c (do_backtrace): Limit maximum backtrace depth
to 100 iterations; it workarounds FC6 DWARF-broken glibc.
2006-12-10 Jan Kratochvil <jan.kratochvil@redhat.com>
* tests/test-ptrace.c (main): Check for too many unexpected child
signals, such as the common `SIGSEGV'.
Don't test read-only access to F0 and F1 registers --- according to
the SCRA manual, those locations cannot even be expressed in SPILL
descriptors and newer versions of GAS (as well as IAS) won't accept
.spillreg directives targeting those registers.
2005/05/17 06:10:13-07:00 hp.com!davidm
(save_pr): Declare
(check_pr): New function.
(all_funcs): Mention save_pr/check_pr.
(random_word): New function.
(check_pr): Likewise.
(check_rotate_regs): Call check_pr().
(run_check): Use random_word() instead of random() to get a word full of
pseudo-random bits.
(Logical change 1.292)
to create NTHREADS threads. With NTHREADS==128 and the stack-size
rlimit set to "unlimited", the test is otherwise likely to fail because
on ia64 it will default to using 32MB of stack per thread.
(Logical change 1.291)
(consume_some_stack_space): New function.
(main): Call consume_some_stack_space() before establishing the
rlimit. Otherwise, stack-expansion may bump into
the address-space rlimit.
(Logical change 1.290)
(main): Do some silly FP computations. On x86-64, this ensures
that the signal handler invocations will always be called
with the FPU-state saved as well. Without this, the first
signal was invoked without FPU-state, the second with, causing
a spurious failure.
2004/11/17 02:06:25-08:00 mostang.com!davidm
(get_bsp): New function.
(handler): Clean up & check for error returns.
(main): Also fail if we didn't get SIGUSR2.
(Logical change 1.290)
for SuSE LES 9) so use 128KB instead.
(do_backtrace): Also print backtrace obtained via backtrace().
(foo): Remove backtrace() call---now done in do_backtrace().
(Logical change 1.290)
2004/10/19 23:11:07-07:00 mostang.com!davidm
(got_here): New global variable.
(raise_exception): Fix off-by-2 error so that we _really_ step
to the outermost a() frame.
(get_bsp): New function.
(__builtin_ia64_bsp): Remove.
(a): Print stack and bsp addresses as we recurse.
When resuming execution in outermost a() frame (n==depth),
clear "result" and set "got_here" so we know we landed in
the right place.
(main): Don't accept arguments that cause "depth" to be < 1.
When returning from a(), also check "got_here". If
the check failed, print result, got_here, and nerrors
for diagnostic purposes.
(Logical change 1.290)