﻿<?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%2FValgrind</id>
	<title>Dev:Doc/Tools/Debugging/Valgrind - 版の履歴</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%2FValgrind"/>
	<link rel="alternate" type="text/html" href="https://wiki.blender.jp/index.php?title=Dev:Doc/Tools/Debugging/Valgrind&amp;action=history"/>
	<updated>2026-06-19T22:56:39Z</updated>
	<subtitle>このウィキのこのページに関する変更履歴</subtitle>
	<generator>MediaWiki 1.31.0</generator>
	<entry>
		<id>https://wiki.blender.jp/index.php?title=Dev:Doc/Tools/Debugging/Valgrind&amp;diff=56656&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/Valgrind&amp;diff=56656&amp;oldid=prev"/>
		<updated>2018-06-28T17:52:39Z</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日 (木) 17:52時点における版&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/Valgrind&amp;diff=56655&amp;oldid=prev</id>
		<title>wiki&gt;Ideasman42: /* Python Compiler Options */</title>
		<link rel="alternate" type="text/html" href="https://wiki.blender.jp/index.php?title=Dev:Doc/Tools/Debugging/Valgrind&amp;diff=56655&amp;oldid=prev"/>
		<updated>2015-09-22T08:47:49Z</updated>

		<summary type="html">&lt;p&gt;‎&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Python Compiler Options&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新規ページ&lt;/b&gt;&lt;/p&gt;&lt;div&gt;=Valgrind=&lt;br /&gt;
&lt;br /&gt;
Valgrind can be used to detect memory errors that a debugger such as gdb would not otherwise find.&lt;br /&gt;
&lt;br /&gt;
==Starting Blender==&lt;br /&gt;
install valgrind on your system.&lt;br /&gt;
&lt;br /&gt;
===OS X===&lt;br /&gt;
http://blog.loudhush.ro/2010/02/compiling-valgrind-on-snow-leopard.html&lt;br /&gt;
&lt;br /&gt;
===Linux===&lt;br /&gt;
&lt;br /&gt;
On ubuntu/debian&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
  sudo apt-get install valgrind&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you can go to the place you built blender and type...&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;valgrind --error-limit=no ./blender&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will run blender in valgrind and generate errors that you can use to find bugs before they crash blender or errors that may cause unpredictable behavior.&lt;br /&gt;
&lt;br /&gt;
These options give more useful output but make blender run slower too.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;valgrind --track-origins=yes  --error-limit=no ./blender&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example Output==&lt;br /&gt;
&amp;lt;source lang=bash&amp;gt;&lt;br /&gt;
==7847== Conditional jump or move depends on uninitialised value(s)&lt;br /&gt;
==7847==    at 0xC1A2CC: which_vfont (font.c:429)&lt;br /&gt;
==7847==    by 0xC1B476: BKE_text_to_curve (font.c:774)&lt;br /&gt;
==7847==    by 0xC4A3C2: do_makeDispListCurveTypes (displist.c:1692)&lt;br /&gt;
==7847==    by 0xC4AD04: makeDispListCurveTypes_forRender (displist.c:1870)&lt;br /&gt;
==7847==    by 0xA06554: init_render_curve (convertblender.c:2789)&lt;br /&gt;
==7847==    by 0xA0CAA9: init_render_object_data (convertblender.c:4392)&lt;br /&gt;
==7847==    by 0xA0CD65: add_render_object (convertblender.c:4441)&lt;br /&gt;
==7847==    by 0xA0D099: init_render_object (convertblender.c:4494)&lt;br /&gt;
==7847==    by 0xA0E3EF: database_init_objects (convertblender.c:4867)&lt;br /&gt;
==7847==    by 0xA0E923: RE_Database_FromScene (convertblender.c:4955)&lt;br /&gt;
==7847==    by 0xA7E0D1: do_render_3d (pipeline.c:1773)&lt;br /&gt;
==7847==    by 0xA7F001: do_render_fields_blur_3d (pipeline.c:2080)&lt;br /&gt;
==7847==  Uninitialised value was created by a heap allocation&lt;br /&gt;
==7847==    at 0x4C25FAD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)&lt;br /&gt;
==7847==    by 0xE0F66B: MEM_mallocN (mallocn.c:308)&lt;br /&gt;
==7847==    by 0xD0B620: read_struct (readfile.c:1284)&lt;br /&gt;
==7847==    by 0xD193D6: read_data_into_oldnewmap (readfile.c:5395)&lt;br /&gt;
==7847==    by 0xD195E5: read_libblock (readfile.c:5453)&lt;br /&gt;
==7847==    by 0xD2DDF9: blo_read_file_internal (readfile.c:11249)&lt;br /&gt;
==7847==    by 0xD32CA8: BLO_read_from_file (readblenentry.c:252)&lt;br /&gt;
==7847==    by 0xC64399: BKE_read_file (blender.c:376)&lt;br /&gt;
==7847==    by 0x6F21C6: load_file (creator.c:880)&lt;br /&gt;
==7847==    by 0xD41164: BLI_argsParse (BLI_args.c:276)&lt;br /&gt;
==7847==    by 0x6F2B6A: main (creator.c:1136)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Analyzing Output==&lt;br /&gt;
There are a few things to consider when reading the output,&lt;br /&gt;
* un-initialized memory may be caused by external libraries, unless these libraries are compiled with debug symbols there wont be as useful info. This cases are easy enough to identify, its just good to be mindful that not all reports are caused by issues in blender.&lt;br /&gt;
* Reports about un-initialized stack variables will show up at the function beginning even if the variable is defined within a block of the code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==False Positives==&lt;br /&gt;
Valgrind tends to give errors with blender on startup which you can safely ignore.&lt;br /&gt;
* X11: Anything related to X11/Xlib.&lt;br /&gt;
* Anything relating to drivers (sound, video).&lt;br /&gt;
* OpenGL: The OpenGL driver.&lt;br /&gt;
* Python: Python uses its own allocator which valgrind detects errors in. ''(can be resolved with a custom Python build - see below)''&lt;br /&gt;
* SDL/Sound: &lt;br /&gt;
* Blenders Undo System: Uses memory comparison which causes errors.&lt;br /&gt;
&lt;br /&gt;
The kinds of errors you get also depend on how valgrind is installed, since some installations come with default suppression files.&lt;br /&gt;
&lt;br /&gt;
As stated, these happen most when starting blender, so be prepared to ignore many errors on startup.&lt;br /&gt;
&lt;br /&gt;
===Compiler Options===&lt;br /&gt;
Another source of false positives can stem from the options used when compiling blender.&lt;br /&gt;
While not essential starting out. if you are spending a long time to track a bug down its better to be sure its reported correctly.&lt;br /&gt;
* compile with debug enabled.&lt;br /&gt;
* disable optimizations&lt;br /&gt;
* disable in-lining &lt;br /&gt;
&lt;br /&gt;
for gcc these flags are &lt;br /&gt;
 -O0 -g3 -fno-inline&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Python Compiler Options ====&lt;br /&gt;
As mentioned before, python can be the cause of many false positives.&lt;br /&gt;
&lt;br /&gt;
This can be avoided by building python without its own malloc replacement '--without-pymalloc' and will quiet most false positives.&lt;br /&gt;
&lt;br /&gt;
Example of building python with debug options and without pymalloc.&lt;br /&gt;
&lt;br /&gt;
 CFLAGS=&amp;quot;-fno-inline -g3 -O0&amp;quot; ./configure --prefix=/opt/py33 --enable-shared --with-pydebug --without-pymalloc --with-valgrind&lt;br /&gt;
 make&lt;br /&gt;
 make install&lt;br /&gt;
&lt;br /&gt;
If you really don't need python, you can also disable the build option WITH_PYTHON but this will remove most of the user interface.&lt;br /&gt;
&lt;br /&gt;
==Debugging==&lt;br /&gt;
&lt;br /&gt;
This requires using gdbserver and isn't essential for valgrind to be useful.&lt;br /&gt;
&lt;br /&gt;
see: http://valgrind.org/docs/manual/manual-core-adv.html#manual-core-adv.gdbserver-gdb&lt;br /&gt;
&lt;br /&gt;
==Error suppression==&lt;br /&gt;
''*Note*. setting suppressions is not strictly necessary but if you run valgrind a lot you may want to set it up - trying to find useful errors in thousands of reports is not really fun.''&lt;br /&gt;
&lt;br /&gt;
If you try running the command above you'll see meny errors, most of which are not useful. to address this you need to make a suppressions file.&lt;br /&gt;
&lt;br /&gt;
===Generic Suppressions===&lt;br /&gt;
''Note: heavily based on http://stackoverflow.com/questions/2375726/how-do-you-tell-valgrind-to-completely-suppress-a-particular-so-file.''&lt;br /&gt;
&lt;br /&gt;
We said above that we could ignore Python, OpenGL driver, etc. errors. You can tell valgrind to silently do that by using its &amp;lt;code&amp;gt;--suppressions&amp;lt;/code&amp;gt; option and a text file defining ignore rules.&lt;br /&gt;
&lt;br /&gt;
The general format is basically:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
# A line starting with a '#' is a comment.&lt;br /&gt;
&lt;br /&gt;
# Start of a rule&lt;br /&gt;
{&lt;br /&gt;
   # Name of the rule, you can use what you want here...&lt;br /&gt;
   Foobar&lt;br /&gt;
&lt;br /&gt;
   # Memcheck specifies the type of error this rule will &amp;quot;silent&amp;quot;.&lt;br /&gt;
   Memcheck:Cond&lt;br /&gt;
&lt;br /&gt;
   # Then we have an optional stack of object files (i.e. libraries).&lt;br /&gt;
   # You should use the full lib paths.&lt;br /&gt;
   # The '...' are &amp;quot;frame wildcards&amp;quot;, they say this rule is valid&lt;br /&gt;
   # for any object file before and after libpython.&lt;br /&gt;
   ...&lt;br /&gt;
   obj:/usr/lib/x86_64-linux-gnu/libpython3.3m.so.1.0&lt;br /&gt;
   ...&lt;br /&gt;
&lt;br /&gt;
   # Then we have an optional stack of function calls.&lt;br /&gt;
   # Here again, the '...' are &amp;quot;frame wildcards&amp;quot;, for functions this time.&lt;br /&gt;
   ...&lt;br /&gt;
   fun:gpu_buffer_setup&lt;br /&gt;
   fun:gpu_buffer_setup_type&lt;br /&gt;
   fun:gpu_buffer_setup_common&lt;br /&gt;
   ...&lt;br /&gt;
&lt;br /&gt;
# Close the rule&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is a file that suppress any error for a start &amp;amp; stop of Blender, on my machine. It should be easy to adapt (just check the lib paths, and replace the OpenGL driver part by your own version): [[file:blender_sup.txt|blender_sup.txt]]. Simply use it like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
valgrind --suppressions=~/blender_sup.txt ./blender&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;color: red;&amp;quot;&amp;gt;'''Warning:''' This file suppresses thousands of errors! In case you are investigating an area it “silents” (Blender's GPU draw code, and mostly Python and fglrx), please consider commenting out related rules.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Refining===&lt;br /&gt;
Above file (once adapted to your system) should cover nearly all false positives. However, you may want to add more specific rules. In this case, use the following method:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
valgrind --suppressions=~/blender_sup.txt --gen-suppressions=all ./blender 2&amp;gt; ~/blender_sup_TEMP.txt&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will add suppression rules to &amp;lt;code&amp;gt;~/blender_sup_TEMP.txt&amp;lt;/code&amp;gt; for all errors not already covered by your current &amp;lt;code&amp;gt;~/blender_sup.txt&amp;lt;/code&amp;gt; file. Open blender and do some operations generating the errors you want to get rid of…&lt;br /&gt;
&lt;br /&gt;
Open &amp;lt;code&amp;gt;~/blender_sup_TEMP.txt&amp;lt;/code&amp;gt;, select the errors you want to ignore, and copy their content between the braces &amp;lt;code&amp;gt;{...}&amp;lt;/code&amp;gt; into your &amp;lt;code&amp;gt;~/blender_sup.txt&amp;lt;/code&amp;gt; file. You should also add some comments about what/why you add those rules.&lt;br /&gt;
&lt;br /&gt;
Now you can can use valgrind as usual (using the &amp;lt;code&amp;gt;--suppressions=~/blender_sup.txt&amp;lt;/code&amp;gt; option), just keep in mind you disabled a bunch of errors, in case you can’t find what you are looking for!&lt;br /&gt;
&lt;br /&gt;
Some errors may keep appearing and you can ignore them:&lt;br /&gt;
* Undo - blender compares un-initialized memory when running undo, you cant supress this from 1 place because undo is called in many areas.&lt;br /&gt;
* Python - Python does its own memory management which confuses valgrind, and is also called in many places.&lt;br /&gt;
&lt;br /&gt;
[[Category:Script]]&lt;/div&gt;</summary>
		<author><name>wiki&gt;Ideasman42</name></author>
		
	</entry>
</feed>