<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-6958481</id><updated>2011-11-27T18:27:10.512-06:00</updated><category term='Solaris'/><category term='libumem'/><category term='c'/><title type='text'>&gt;8^)</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://shr3kst3r.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6958481/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://shr3kst3r.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Dennis Rowe</name><uri>http://www.blogger.com/profile/10418392183543680770</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>1</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6958481.post-117055917011068539</id><published>2007-02-03T21:12:00.000-06:00</published><updated>2007-02-03T22:33:37.947-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='libumem'/><category scheme='http://www.blogger.com/atom/ns#' term='c'/><category scheme='http://www.blogger.com/atom/ns#' term='Solaris'/><title type='text'>Force a core on exit() without modifying the applications code</title><content type='html'>A nice option to have when using libumem, is the option to core the process right before it exits.  Here is how to interpose your own exit() on your application without modifying any of the application's code.&lt;br /&gt;&lt;br /&gt;Test application (test.cc):&lt;br /&gt;&lt;pre&gt;#include &lt;iostream&gt;&lt;br /&gt;#include &lt;string&gt;&lt;br /&gt;using namespace std;&lt;br /&gt;int main(){&lt;br /&gt; char* s = new char[1000];&lt;br /&gt; printf("Done\n");&lt;br /&gt;}&lt;/string&gt;&lt;/iostream&gt;&lt;/pre&gt;&lt;br /&gt;Compile test.cc:&lt;br /&gt;&lt;pre&gt;$ cc test.cc -o test&lt;/pre&gt;&lt;br /&gt;The shared library containing our exit function (exit_interposer.c):&lt;br /&gt;&lt;pre&gt;#include &lt;stdio.h&gt;&lt;br /&gt;#include &lt;stdlib.h&gt;&lt;br /&gt;void exit(int status) {&lt;br /&gt; abort();&lt;br /&gt;}&lt;/stdlib.h&gt;&lt;/stdio.h&gt;&lt;/pre&gt;&lt;br /&gt;Compile exit_interposer.c:&lt;br /&gt;&lt;pre&gt;cc -o exit_interposer.so -G -Kpic exit_interposer.c&lt;/pre&gt;&lt;br /&gt;Now run our test program with our new exit function:&lt;br /&gt;&lt;pre&gt;$ UMEM_DEBUG=default UMEM_LOGGING=transaction&lt;br /&gt;LD_PRELOAD=libumem.so.1:`pwd`/exit_interposer.so ./test&lt;br /&gt;Done&lt;br /&gt;Abort (core dumped)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Now we can see the leak with libumem:&lt;br /&gt;&lt;pre&gt;icing:shrek&gt; mdb core.test.11049.icing&lt;br /&gt;Loading modules: [ libumem.so.1 libc.so.1 ld.so.1 ]&lt;br /&gt;&gt; ::findleaks&lt;br /&gt;CACHE     LEAKED   BUFCTL CALLER&lt;br /&gt;08082610       1 080af078 libCrun.so.1`__1c2n6FI_pv_+0x33&lt;br /&gt;----------------------------------------&lt;br /&gt;Total       1 buffer, 1152 bytes&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;This should also work on a daemon which forks processes as long as LD_PRELOAD is set correctly.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6958481-117055917011068539?l=shr3kst3r.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://shr3kst3r.blogspot.com/feeds/117055917011068539/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6958481&amp;postID=117055917011068539' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6958481/posts/default/117055917011068539'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6958481/posts/default/117055917011068539'/><link rel='alternate' type='text/html' href='http://shr3kst3r.blogspot.com/2007/02/force-core-on-exit-without-modifying.html' title='Force a core on exit() without modifying the applications code'/><author><name>Dennis Rowe</name><uri>http://www.blogger.com/profile/10418392183543680770</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
