LiJIan
2007-Oct-15 14:39 UTC
[dtrace-discuss] how to get "libmtmalloc.so.1:malloc" returned address in DTrace script
Should I use MDB to see why the return value was not carried in arg1? But how? Would some experts give me help or advice with this? Thanks! BR Jian -- This message posted from opensolaris.org
Adam Leventhal
2007-Oct-15 20:59 UTC
[dtrace-discuss] how to get "libmtmalloc.so.1:malloc" returned address in DTrace script
On Mon, Oct 15, 2007 at 07:39:16AM -0700, LiJIan wrote:> Should I use MDB to see why the return value was not carried in arg1? But how? > Would some experts give me help or advice with this? Thanks!Unfortunately, libmtmalloc''s malloc function can make a tail-call to either oversize() or malloc_internal() -- both internal functions. This means that the apparent return value in the return probe isn''t actually the value returned from malloc(). To accurately get the return value, you''ll need to get the return value from those functions. This is a tricky issue. One could imagine a class of function return probes which would indicate if there was a normal return or a tail-call, but we decided that that was too complicated. Perhaps it would be a good idea to create additional probes: args0 args1 return-normal address of return site return value return-call address of tail-call address of tail-called function Adam -- Adam Leventhal, FishWorks http://blogs.sun.com/ahl
LiJIan
2007-Oct-18 05:49 UTC
[dtrace-discuss] how to get "libmtmalloc.so.1:malloc" returned address in DTrace script
Thank you very much for your help, Adam. Now I write another script to check memory leak issue as follows, it works well, but during runing I see some error output on screen such as "dtrace: error on enabled probe ID 3 (ID 49838: pid6918:libmtmalloc.so.1:malloc_internal:return): invalid address (0x1fdc78000) in action #3". Do you know why the error occur? Does the error affect the output of the D script, or I still can take use of output of the D script for memory leak analysis ? Thanks again. ------------------- #!/usr/sbin/dtrace -s pid$1:libmtmalloc.so.1:malloc:entry { self->trace = 1; self->size = arg0; } pid$1:libmtmalloc.so.1:free:entry /arg0 != 0/ { printf("\nfree Ptr=0x%p ", arg0); } pid$1::malloc_internal:return, pid$1::oversize:entry /self->size/ { printf("\nmalloc Ptr=0x%p Size=%d", arg1, self->size); ustack(); system("date"); self->size = 0; self->trace = 0; } --------------------- BRs LiJian -- This message posted from opensolaris.org
Angelo.Rajadurai at Sun.COM
2007-Oct-18 15:55 UTC
[dtrace-discuss] how to get "libmtmalloc.so.1:malloc" returned address in DTrace script
The error invalid address seems to me coming when the pid$1::oversize:entry fires. It only has one argument but you seem to be looking for arg1 - the second argument. Also not sure how the script runs as you would need the -w option for enabling destructive probes to be able to run the system("date") action. In fact a better way to print the date is by using the walltimestamp. Using printf("Date: %Y\n", walltimestamp); HTHs Angelo LiJIan wrote:> Thank you very much for your help, Adam. > Now I write another script to check memory leak issue as follows, it works well, but during runing I see some error output on screen such as "dtrace: error on enabled probe ID 3 (ID 49838: pid6918:libmtmalloc.so.1:malloc_internal:return): invalid address (0x1fdc78000) in action #3". > Do you know why the error occur? Does the error affect the output of the D script, or I still can take use of output of the D script for memory leak analysis ? > Thanks again. > > ------------------- > #!/usr/sbin/dtrace -s > > pid$1:libmtmalloc.so.1:malloc:entry > { > self->trace = 1; > self->size = arg0; > } > > pid$1:libmtmalloc.so.1:free:entry > /arg0 != 0/ > { > printf("\nfree Ptr=0x%p ", arg0); > } > > pid$1::malloc_internal:return, > pid$1::oversize:entry > /self->size/ > { > printf("\nmalloc Ptr=0x%p Size=%d", arg1, self->size); > ustack(); > system("date"); > self->size = 0; > self->trace = 0; > } > --------------------- > > > BRs > LiJian > > > -- > This message posted from opensolaris.org > _______________________________________________ > dtrace-discuss mailing list > dtrace-discuss at opensolaris.org
Adam Leventhal
2007-Oct-22 23:54 UTC
[dtrace-discuss] how to get "libmtmalloc.so.1:malloc" returned address in DTrace script
On Wed, Oct 17, 2007 at 10:49:10PM -0700, LiJIan wrote:> pid$1::malloc_internal:return, > pid$1::oversize:entryI assume you want the oversize:return probe rather than the entry probe. Adam -- Adam Leventhal, FishWorks http://blogs.sun.com/ahl
LiJIan
2007-Oct-24 08:44 UTC
[dtrace-discuss] how to get "libmtmalloc.so.1:malloc" returned address in DTrace script
Hi, Adam Yes, it should be "oversize::return" instead of "oversize::entry". I will change and then retry it. Thank you. BRs LiJian -- This message posted from opensolaris.org
LiJIan
2007-Oct-29 03:40 UTC
[dtrace-discuss] how to get "libmtmalloc.so.1:malloc" returned address in DTrace script
Hi Adam, I changed the D script to as follows. ----------------------------------------- #!/usr/sbin/dtrace -s pid$1:libmtmalloc.so.1:malloc:entry { self->trace = 1; self->size = arg0; } pid$1:libmtmalloc.so.1:free:entry /arg0 != 0/ { printf("\nfree Ptr=0x%p ", arg0); } pid$1:libmtmalloc.so.1:malloc_internal:return /self->size/ { printf("\nmalloc Ptr=0x%p Size=%d", arg1, self->size); ustack(); self->size = 0; self->trace = 0; } pid$1:libmtmalloc.so.1:oversize:return /self->size/ { printf("\nmalloc Ptr=0x%p Size=%d", arg1, self->size); ustack(); self->size = 0; self->trace = 0; } ----------------------------------------- But during running it, the error still occured, ----------------------- # dtrace -qs ./mem2.d 13206 dtrace: error on enabled probe ID 3 (ID 49838: pid13206:libmtmalloc.so.1:malloc_internal:return): invalid address (0x1fdf72000) in action #3 dtrace: error on enabled probe ID 3 (ID 49838: pid13206:libmtmalloc.so.1:malloc_internal:return): invalid address (0x1fdf72000) in action #3 dtrace: error on enabled probe ID 3 (ID 49838: pid13206:libmtmalloc.so.1:malloc_internal:return): invalid address (0x1fdf72000) in action #3 dtrace: error on enabled probe ID 3 (ID 49838: pid13206:libmtmalloc.so.1:malloc_internal:return): invalid address (0x1fdf72000) in action #3 dtrace: error on enabled probe ID 3 (ID 49838: pid13206:libmtmalloc.so.1:malloc_internal:return): invalid address (0x1fd572000) in action #3 dtrace: error on enabled probe ID 3 (ID 49838: pid13206:libmtmalloc.so.1:malloc_internal:return): invalid address (0x1fd572000) in action #3 --------------------- The address "0x1fdf72000" apparently is wrong, does "malloc_internal:return" sometimes return a wrong address ? What is the "action #3" ? Thanks. BRs LiJian -- This message posted from opensolaris.org
Adam Leventhal
2007-Oct-31 08:06 UTC
[dtrace-discuss] how to get "libmtmalloc.so.1:malloc" returned address in DTrace script
Can you try just doing this: pid$1:libmtmalloc.so.1:malloc_internal:return { ustack(); } Do you see errors? What does dtrace -V show? - ahl On Sun, Oct 28, 2007 at 08:40:44PM -0700, LiJIan wrote:> Hi Adam, > I changed the D script to as follows. > > ----------------------------------------- > > #!/usr/sbin/dtrace -s > > pid$1:libmtmalloc.so.1:malloc:entry > { > self->trace = 1; > self->size = arg0; > } > > pid$1:libmtmalloc.so.1:free:entry > /arg0 != 0/ > { > printf("\nfree Ptr=0x%p ", arg0); > } > > pid$1:libmtmalloc.so.1:malloc_internal:return > /self->size/ > { > printf("\nmalloc Ptr=0x%p Size=%d", arg1, self->size); > ustack(); > self->size = 0; > self->trace = 0; > } > > pid$1:libmtmalloc.so.1:oversize:return > /self->size/ > { > printf("\nmalloc Ptr=0x%p Size=%d", arg1, self->size); > ustack(); > self->size = 0; > self->trace = 0; > } > > ----------------------------------------- > > > But during running it, the error still occured, > > ----------------------- > > # dtrace -qs ./mem2.d 13206 > dtrace: error on enabled probe ID 3 (ID 49838: pid13206:libmtmalloc.so.1:malloc_internal:return): invalid address (0x1fdf72000) in action #3 > dtrace: error on enabled probe ID 3 (ID 49838: pid13206:libmtmalloc.so.1:malloc_internal:return): invalid address (0x1fdf72000) in action #3 > dtrace: error on enabled probe ID 3 (ID 49838: pid13206:libmtmalloc.so.1:malloc_internal:return): invalid address (0x1fdf72000) in action #3 > dtrace: error on enabled probe ID 3 (ID 49838: pid13206:libmtmalloc.so.1:malloc_internal:return): invalid address (0x1fdf72000) in action #3 > dtrace: error on enabled probe ID 3 (ID 49838: pid13206:libmtmalloc.so.1:malloc_internal:return): invalid address (0x1fd572000) in action #3 > dtrace: error on enabled probe ID 3 (ID 49838: pid13206:libmtmalloc.so.1:malloc_internal:return): invalid address (0x1fd572000) in action #3 > > --------------------- > > The address "0x1fdf72000" apparently is wrong, does "malloc_internal:return" sometimes return a wrong address ? What is the "action #3" ? > > Thanks. > > > BRs > LiJian > > > -- > This message posted from opensolaris.org > _______________________________________________ > dtrace-discuss mailing list > dtrace-discuss at opensolaris.org-- Adam Leventhal, FishWorks http://blogs.sun.com/ahl