<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Erlang非业余研究 &#187; gcc</title>
	<atom:link href="http://blog.yufeng.info/archives/tag/gcc/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.yufeng.info</link>
	<description>Erlang系统深度探索和应用</description>
	<lastBuildDate>Tue, 17 Jan 2012 06:05:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>gcc mudflap 用来检测内存越界的问题</title>
		<link>http://blog.yufeng.info/archives/698</link>
		<comments>http://blog.yufeng.info/archives/698#comments</comments>
		<pubDate>Sat, 25 Sep 2010 03:49:00 +0000</pubDate>
		<dc:creator>Yu Feng</dc:creator>
				<category><![CDATA[工具介绍]]></category>
		<category><![CDATA[gcc]]></category>
		<category><![CDATA[mudflap]]></category>
		<category><![CDATA[valgrind]]></category>

		<guid isPermaLink="false">http://blog.yufeng.info/?p=698</guid>
		<description><![CDATA[原创文章，转载请注明： 转载自Erlang非业余研究 本文链接地址: gcc mudflap 用来检测内存越界的问题 参考资料：http://www.redhat.com/magazine/015jan06/features/valgrind/ http://www.stlinux.com/devel/debug/mudflap 我们用C语言在做大型服务器程序的时候，不可避免的要面对内存错误的问题。典型的问题是内存泄漏，越界，随机乱写等问题。 在linux下valgrind是个很好的工具，大部分问题都可以查的到的。但是对于更微妙的越界问题，valgrind有时候也是无能为力的。比如下面的问题。 [admin@my174 ~]$ cat bug.c valgrind报告一切安好。 mudflap就很顺利的检查出来了。 [admin@my174 ~]$ gcc -v &#8230; gcc version 4.1.2 20080704 (Red Hat 4.1.2-46) 当然我们的这个例子很简单，典型的服务器要比这个复杂很多， 而且mudflap的运行开销也非常高，我们在定位此类bug的时候不妨实验下。 Have fun! Post Footer automatically generated by wp-posturl plugin for wordpress.]]></description>
			<content:encoded><![CDATA[<div style="margin-top: 15px; font-style: italic">
<p><strong>原创文章，转载请注明：</strong> 转载自<a href="http://blog.yufeng.info/">Erlang非业余研究</a></p>
<p><strong>本文链接地址:</strong> <a href="http://blog.yufeng.info/archives/698">gcc mudflap 用来检测内存越界的问题</a></p>
</div>
<p>参考资料：<a href="http://www.redhat.com/magazine/015jan06/features/valgrind/">http://www.redhat.com/magazine/015jan06/features/valgrind/</a><br />
<a href="http://www.stlinux.com/devel/debug/mudflap">http://www.stlinux.com/devel/debug/mudflap</a></p>
<p>我们用C语言在做大型服务器程序的时候，不可避免的要面对内存错误的问题。典型的问题是内存泄漏，越界，随机乱写等问题。  在linux下valgrind是个很好的工具，大部分问题都可以查的到的。但是对于更微妙的越界问题，valgrind有时候也是无能为力的。比如下面的问题。</p>
<p>[admin@my174 ~]$ cat bug.c</p>
<pre class="brush: cpp; title: ; notranslate">
int a[10];
int b[10];
int main(void) {
   return a[11];
}
</pre>
<pre class="brush: bash; title: ; notranslate">
[admin@my174 ~]$ gcc -g -o bug bug.c
[admin@my174 ~]$ valgrind ./bug
==5791== Memcheck, a memory error detector.
==5791== Copyright (C) 2002-2006, and GNU GPL'd, by Julian Seward et al.
==5791== Using LibVEX rev 1658, a library for dynamic binary translation.
==5791== Copyright (C) 2004-2006, and GNU GPL'd, by OpenWorks LLP.
==5791== Using valgrind-3.2.1, a dynamic binary instrumentation framework.
==5791== Copyright (C) 2000-2006, and GNU GPL'd, by Julian Seward et al.
==5791== For more details, rerun with: -v
==5791==
==5791==
==5791== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 4 from 1)
==5791== malloc/free: in use at exit: 0 bytes in 0 blocks.
==5791== malloc/free: 0 allocs, 0 frees, 0 bytes allocated.
==5791== For counts of detected errors, rerun with: -v
==5791== All heap blocks were freed -- no leaks are possible.
[admin@my174 ~]$
</pre>
<p>valgrind报告一切安好。</p>
<pre class="brush: bash; title: ; notranslate">
[admin@my174 ~]$ gcc -o bug bug.c -g -fmudflap -lmudflap
[admin@my174 ~]$ ./bug
*******
mudflap violation 1 (check/read): time=1285386334.204054 ptr=0x700e00 size=48
pc=0x2b6c3013c4c1 location=`bug.c:5 (main)'
      /usr/lib64/libmudflap.so.0(__mf_check+0x41) [0x2b6c3013c4c1]
      ./bug(main+0x7a) [0x400952]
      /lib64/libc.so.6(__libc_start_main+0xf4) [0x39ea21d994]
Nearby object 1: checked region begins 0B into and ends 8B after
mudflap object 0x16599370: name=`bug.c:1 a'
bounds=[0x700e00,0x700e27] size=40 area=static check=3r/0w liveness=3
alloc time=1285386334.204025 pc=0x2b6c3013bfe1
number of nearby objects: 1
</pre>
<p>mudflap就很顺利的检查出来了。</p>
<p>[admin@my174 ~]$ gcc -v<br />
&#8230;<br />
gcc version 4.1.2 20080704 (Red Hat 4.1.2-46)</p>
<p>当然我们的这个例子很简单，典型的服务器要比这个复杂很多， 而且mudflap的运行开销也非常高，我们在定位此类bug的时候不妨实验下。<br />
Have fun!</p>
<div style="margin-top: 0; margin-bottom: 15px; color: #888888; font-size: 80%; font-style: italic">
<p>Post Footer automatically generated by <a href="http://easwy.com/blog/wordpress/wp-posturl/" style="color: #8888FF; text-decoration: underline;">wp-posturl plugin</a> for wordpress.</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.yufeng.info/archives/698/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>gccgo合并到gcc4.5</title>
		<link>http://blog.yufeng.info/archives/206</link>
		<comments>http://blog.yufeng.info/archives/206#comments</comments>
		<pubDate>Thu, 28 Jan 2010 03:10:12 +0000</pubDate>
		<dc:creator>Yu Feng</dc:creator>
				<category><![CDATA[杂七杂八]]></category>
		<category><![CDATA[4.5]]></category>
		<category><![CDATA[gcc]]></category>
		<category><![CDATA[go]]></category>

		<guid isPermaLink="false">http://blog.yufeng.info/?p=206</guid>
		<description><![CDATA[原创文章，转载请注明： 转载自Erlang非业余研究 本文链接地址: gccgo合并到gcc4.5 From: http://lwn.net/Articles/371466/ I am pleased to announce that the GCC Steering Committee has accepted the contribution of the gccgo front-end and gcc-specific runtime for the Go language with Ian Taylor appointed maintainer. The GCC Release Managers will decide the details about the timing of the merge and inclusion in GCC 4.5 [...]]]></description>
			<content:encoded><![CDATA[<div style="margin-top: 15px; font-style: italic">
<p><strong>原创文章，转载请注明：</strong> 转载自<a href="http://blog.yufeng.info/">Erlang非业余研究</a></p>
<p><strong>本文链接地址:</strong> <a href="http://blog.yufeng.info/archives/206">gccgo合并到gcc4.5</a></p>
</div>
<p>From:<a href="http://lwn.net/Articles/371466/"> http://lwn.net/Articles/371466/</a></p>
<p>I am pleased to announce that the GCC Steering Committee has<br />
accepted the contribution of the gccgo front-end and gcc-specific runtime<br />
for the Go language with Ian Taylor appointed maintainer.  The GCC<br />
Release Managers will decide the details about the timing of the merge and<br />
inclusion in GCC 4.5 or later.</p>
<p>	Please join me in congratulating and thanking Ian and the Go<br />
language developers.  Please update your listing in the MAINTAINERS file.</p>
<p>Happy hacking!<br />
David
<div style="margin-top: 0; margin-bottom: 15px; color: #888888; font-size: 80%; font-style: italic">
<p>Post Footer automatically generated by <a href="http://easwy.com/blog/wordpress/wp-posturl/" style="color: #8888FF; text-decoration: underline;">wp-posturl plugin</a> for wordpress.</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.yufeng.info/archives/206/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

