﻿<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ja">
	<id>https://wiki.blender.jp/index.php?action=history&amp;feed=atom&amp;title=Dev%3ADoc%2FTools%2FDebugging%2FGCC_Address_Sanitizer</id>
	<title>Dev:Doc/Tools/Debugging/GCC Address Sanitizer - 版の履歴</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.blender.jp/index.php?action=history&amp;feed=atom&amp;title=Dev%3ADoc%2FTools%2FDebugging%2FGCC_Address_Sanitizer"/>
	<link rel="alternate" type="text/html" href="https://wiki.blender.jp/index.php?title=Dev:Doc/Tools/Debugging/GCC_Address_Sanitizer&amp;action=history"/>
	<updated>2026-07-04T13:55:06Z</updated>
	<subtitle>このウィキのこのページに関する変更履歴</subtitle>
	<generator>MediaWiki 1.31.0</generator>
	<entry>
		<id>https://wiki.blender.jp/index.php?title=Dev:Doc/Tools/Debugging/GCC_Address_Sanitizer&amp;diff=141579&amp;oldid=prev</id>
		<title>Yamyam: 1版 をインポートしました</title>
		<link rel="alternate" type="text/html" href="https://wiki.blender.jp/index.php?title=Dev:Doc/Tools/Debugging/GCC_Address_Sanitizer&amp;diff=141579&amp;oldid=prev"/>
		<updated>2018-06-28T20:54:08Z</updated>

		<summary type="html">&lt;p&gt;1版 をインポートしました&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;ja&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← 古い版&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;2018年6月28日 (木) 20:54時点における版&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;ja&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(相違点なし)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Yamyam</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.blender.jp/index.php?title=Dev:Doc/Tools/Debugging/GCC_Address_Sanitizer&amp;diff=141578&amp;oldid=prev</id>
		<title>2018年5月7日 (月) 13:35にwiki&gt;Ideasman42による</title>
		<link rel="alternate" type="text/html" href="https://wiki.blender.jp/index.php?title=Dev:Doc/Tools/Debugging/GCC_Address_Sanitizer&amp;diff=141578&amp;oldid=prev"/>
		<updated>2018-05-07T13:35:30Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新規ページ&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= ASAN =&lt;br /&gt;
&lt;br /&gt;
GCC 4.8 adds address sanitizer, this will cause blender to quit with an error message on bad memory use (using uninitialized memory, accessing freed memory, accessing outside memory bounds).&lt;br /&gt;
&lt;br /&gt;
Also, since GCC 4.9, ASAN adds a memory leak checking (LeakSanitizer) that reports when closing Blender.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
Enable the address sanitize flag,&lt;br /&gt;
&lt;br /&gt;
 -fsanitize=address&lt;br /&gt;
&lt;br /&gt;
* CMake: add to 'CMAKE_CXX_FLAGS_DEBUG' and 'CMAKE_C_FLAGS_DEBUG'.&lt;br /&gt;
* SCons: add to 'BF_DEBUG_CCFLAGS'&lt;br /&gt;
&lt;br /&gt;
Then run blender until it crashes with an address sanitizer style error.&lt;br /&gt;
&lt;br /&gt;
The output of asan is rather cryptic (raw address offsets). To get human-readable backtraces, you can use the [https://llvm.org/svn/llvm-project/compiler-rt/trunk/lib/asan/scripts/asan_symbolize.py asan_symbolize.py python2 script], which is part of the llvm project:&lt;br /&gt;
&lt;br /&gt;
 ./bin/blender 2&amp;gt;&amp;amp;1 | asan_symbolize.py&lt;br /&gt;
&lt;br /&gt;
If you are working with C++ code, you may want to add the &amp;lt;code&amp;gt;-d&amp;lt;/code&amp;gt; option to asan_symbolize.py call, to demangle names.&lt;br /&gt;
&lt;br /&gt;
When the output is not enough to go by, run inside a debugger and break on the error reporting function&lt;br /&gt;
&lt;br /&gt;
 break __asan_report_error&lt;br /&gt;
&lt;br /&gt;
Example stack trace:&lt;br /&gt;
&amp;lt;code lang=text&amp;gt;&lt;br /&gt;
 #0  0x00007ffff4e63e40 in __asan_report_error () from /usr/lib/libasan.so.0&lt;br /&gt;
 #1  0x00007ffff4e5e804 in __asan_report_load1 () from /usr/lib/libasan.so.0&lt;br /&gt;
 #2  0x0000000002450a77 in mywrite (wd=0x600c0028cd60, adr=0x602c00048340, len=376) at ./source/blender/blenloader/intern/writefile.c:297&lt;br /&gt;
 #3  0x0000000002451413 in writedata (wd=0x600c0028cd60, filecode=1096040772, len=376, adr=0x602c00048340) at ./source/blender/blenloader/intern/writefile.c:395&lt;br /&gt;
 #4  0x0000000002462edc in write_texts (wd=0x600c0028cd60, idbase=0x60500000f5c8) at ./source/blender/blenloader/intern/writefile.c:2679&lt;br /&gt;
 #5  0x0000000002466826 in write_file_handle (mainvar=0x60500000f080, handle=0, compare=0x6044000158d0, current=0x60440004a5d0, write_user_block=0, write_flags=4608, thumb=0x0) at ./source/blender/blenloader/intern/writefile.c:3284&lt;br /&gt;
 #6  0x0000000002467631 in BLO_write_file_mem (mainvar=0x60500000f080, compare=0x6044000158d0, current=0x60440004a5d0, write_flags=4608) at ./source/blender/blenloader/intern/writefile.c:3485&lt;br /&gt;
 #7  0x0000000001e0105b in BKE_write_undo (C=0x60160000af90, name=0x3007820 &amp;quot;Open Text Block&amp;quot;) at ./source/blender/blenkernel/intern/blender.c:676&lt;br /&gt;
 #8  0x0000000000d34ee6 in ED_undo_push (C=0x60160000af90, str=0x3007820 &amp;quot;Open Text Block&amp;quot;) at ./source/blender/editors/util/undo.c:110&lt;br /&gt;
 #9  0x0000000000d356ba in ED_undo_push_op (C=0x60160000af90, op=0x601e00005b30) at ./source/blender/editors/util/undo.c:220&lt;br /&gt;
 #10 0x000000000088ec97 in wm_handler_fileselect_call (C=0x60160000af90, handlers=0x60240007cd50, handler=0x601a0004b390, event=0x6018001cf180) at ./source/blender/windowmanager/intern/wm_event_system.c:1622&lt;br /&gt;
 #11 0x000000000088fc90 in wm_handlers_do_intern (C=0x60160000af90, event=0x6018001cf180, handlers=0x60240007cd50) at ./source/blender/windowmanager/intern/wm_event_system.c:1816&lt;br /&gt;
 #12 0x0000000000890237 in wm_handlers_do (C=0x60160000af90, event=0x6018001cf180, handlers=0x60240007cd50) at ./source/blender/windowmanager/intern/wm_event_system.c:1891&lt;br /&gt;
 #13 0x00000000008919bc in wm_event_do_handlers (C=0x60160000af90) at ./source/blender/windowmanager/intern/wm_event_system.c:2138&lt;br /&gt;
 #14 0x00000000008781dd in WM_main (C=0x60160000af90) at ./source/blender/windowmanager/intern/wm.c:447&lt;br /&gt;
 #15 0x000000000087648a in main (argc=1, argv=0x7fffffffe058) at ./source/creator/creator.c:1646&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Quiet LeakSanitizer ==&lt;br /&gt;
&lt;br /&gt;
While this tool is really useful to detect memory leaks, it has some annoying drawback in Blender currently - usage of Python leads to a fair amount of (valid!) leak reports, about which we cannot do much currently (see also [https://docs.python.org/3.5/c-api/init.html#c.Py_Finalize Python documentation]).&lt;br /&gt;
&lt;br /&gt;
To silence those warnings (which can “hide” a real new one in the flow), you can use a ''suppression file'' and pass it as environment variable to run Blender:&lt;br /&gt;
&lt;br /&gt;
 $ LSAN_OPTIONS=suppressions=path/to/asan_blender_sup.txt path/to/bin/blender&lt;br /&gt;
&lt;br /&gt;
''asan_blender_sup.txt'' can contain several suppression rules (libraries or function names, including wildcards), but that single one should already remove most reports:&lt;br /&gt;
&lt;br /&gt;
 leak:libpython*&lt;br /&gt;
&lt;br /&gt;
Please note that this will remove any leak reports from code which backtrace contains a reference to libpython - this may be too generic, in which case just filtering out leaks coming from our bpy init code can be an option:&lt;br /&gt;
&lt;br /&gt;
 leak:BPY_python_start&lt;br /&gt;
&lt;br /&gt;
Note that you can also add some rule for your GPU driver, those also tend to not free all their memory upon termination…&lt;br /&gt;
&lt;br /&gt;
eg (for intel cards):&lt;br /&gt;
&lt;br /&gt;
 leak:libdrm_intel&lt;br /&gt;
 leak:i965_dri&lt;br /&gt;
&lt;br /&gt;
== Comparison with Valgrind ==&lt;br /&gt;
Address sanitizer can help find bugs that Valgrind would, but there are some important differences.&lt;br /&gt;
&lt;br /&gt;
'''Pros'''&lt;br /&gt;
* Fast enough for general use.&lt;br /&gt;
* Easy to use a breakpoint to investigate the point when and error happens.&amp;lt;br&amp;gt;''(Valgrind can use GDB too but its a bit more involved).''&lt;br /&gt;
&lt;br /&gt;
'''Cons'''&lt;br /&gt;
* Only deals with heap memory (not stack as valgrind).&lt;br /&gt;
* Can't be used with valgrind&amp;lt;br/&amp;gt;''(to use valgrind you'll have to remove the compiler flags and rebuild)''&lt;br /&gt;
&lt;br /&gt;
== Further Reading ==&lt;br /&gt;
&lt;br /&gt;
This feature is quite in-depth and this doc only explains basic usage, for further reading:&lt;br /&gt;
&lt;br /&gt;
* http://clang.llvm.org/docs/AddressSanitizer.html#usage&lt;/div&gt;</summary>
		<author><name>wiki&gt;Ideasman42</name></author>
		
	</entry>
</feed>