This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix for segmentation fault


On Thu, Apr 24, 2008 at 12:18:22PM +0530, Srinivasa D S wrote:
> Hi
> 	When I executed latest systemtap on x86_64, I got segmentation
> fault. On analysis, I found 
> 
> ........................................................
> Loaded symbols for /lib64/libpthread.so.0
> Reading symbols from /lib64/ld-linux-x86-64.so.2...done.
> Loaded symbols for /lib64/ld-linux-x86-64.so.2
> Core was generated by `./stap -vvv -e probe kernel.function("sys_open")
> "hi");}
> '.
> Program terminated with signal 11, Segmentation fault.
> #0  0x00007f470e8a31c6 in report_kernel (dwfl=0xf5f3e0,
>     release=<value optimized out>, predicate=0)
>     at /home/systemtap/btils/elfutils-0.131/libdwfl/linux-kernel-module
> 197               mod->e_type = ET_DYN;
> 
> 
> Attaching fix for the problem.
> 
> Signed-off-by: Srinivasa DS <srinivasa@in.ibm.com>
> 
> 
> ---
>  libdwfl/linux-kernel-modules.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> Index: elfutils-0.131/libdwfl/linux-kernel-modules.c
> ===================================================================
> --- elfutils-0.131.orig/libdwfl/linux-kernel-modules.c
> +++ elfutils-0.131/libdwfl/linux-kernel-modules.c
> @@ -191,7 +191,7 @@ report_kernel (Dwfl *dwfl, const char **
>  	  Dwfl_Module *mod = INTUSE(dwfl_report_elf) (dwfl, KERNEL_MODNAME,
>  						      fname, fd, 0);
>  	  if (mod == NULL)
> -	    result = -1;
> +	    return -1;

I guess this is incorrect as you skip the closing the file descriptor
and freeing fname even though result is -1. How about the following instead?

Don't dereference a NULL pointer when handling kernel modules

Signed-off-by: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
---
 libdwfl/linux-kernel-modules.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Index: elfutils-0.131/libdwfl/linux-kernel-modules.c
===================================================================
--- elfutils-0.131.orig/libdwfl/linux-kernel-modules.c
+++ elfutils-0.131/libdwfl/linux-kernel-modules.c
@@ -192,9 +192,9 @@ report_kernel (Dwfl *dwfl, const char **
 						      fname, fd, 0);
 	  if (mod == NULL)
 	    result = -1;
-
-	  /* The kernel is ET_EXEC, but always treat it as relocatable.  */
-	  mod->e_type = ET_DYN;
+	  else
+	    /* The kernel is ET_EXEC, but always treat it as relocatable.  */
+	    mod->e_type = ET_DYN;
 	}
 
       if (!report || result < 0)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]