Hi,

In ppc-linux and ppc64-linux, when calling ltrace with:

$ ltrace -e non-existent-function ./hello-world

ltrace segfaults. The reason is that in enable_all_breakpoints there's
some PowerPC specific code (guarded by #ifdef __powerpc__), which calls
sym2addr passing proc->list_of_symbols as argument. The problem is that
because we don't have any event to monitor, proc->list_of_symbols is
NULL and ppc's sym2addr will reference the null pointer.

To be honest, I'm not familiar with the ltrace source code and thus I
don't know if this patch is a fix or just a workaround. :-) There are no
changes in the testsuite results (for ppc-linux, I used Michael Edwards'
patch to fix the compilation errors). What do you think?

As an aside, even when I commented out all the code guarded by #if
__powerpc__, the testsuite results were unchanged, so I'm not sure that
it is even necessary. But I don't want to go down that rabbit hole at
this moment.
-- 
[]'s
Thiago Jung Bauermann
IBM Linux Technology Center


diff --git a/breakpoints.c b/breakpoints.c
index 1ea406a..7998b88 100644
--- a/breakpoints.c
+++ b/breakpoints.c
@@ -95,7 +95,7 @@ enable_all_breakpoints(Process *proc) {
                 * If the dynamic linker hasn't populated the PLT then
                 * dont enable the breakpoints
                 */
-               if (options.libcalls) {
+               if (options.libcalls && proc->list_of_symbols) {
                        a = ptrace(PTRACE_PEEKTEXT, proc->pid,
                                   sym2addr(proc, proc->list_of_symbols),
                                   0);



_______________________________________________
Ltrace-devel mailing list
[email protected]
http://lists.alioth.debian.org/mailman/listinfo/ltrace-devel

Reply via email to