<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-6958481</atom:id><lastBuildDate>Fri, 30 Aug 2024 03:12:07 +0000</lastBuildDate><category>Solaris</category><category>c</category><category>libumem</category><title>&amp;gt;8^)</title><description></description><link>http://shr3kst3r.blogspot.com/</link><managingEditor>noreply@blogger.com (Dennis Rowe)</managingEditor><generator>Blogger</generator><openSearch:totalResults>1</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6958481.post-117055917011068539</guid><pubDate>Sun, 04 Feb 2007 03:12:00 +0000</pubDate><atom:updated>2007-02-03T22:33:37.947-06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">c</category><category domain="http://www.blogger.com/atom/ns#">libumem</category><category domain="http://www.blogger.com/atom/ns#">Solaris</category><title>Force a core on exit() without modifying the applications code</title><description>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&#39;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(&quot;Done\n&quot;);&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.</description><link>http://shr3kst3r.blogspot.com/2007/02/force-core-on-exit-without-modifying.html</link><author>noreply@blogger.com (Dennis Rowe)</author><thr:total>0</thr:total></item></channel></rss>