X-Git-Url: https://git.llucax.com/personal/website.git/blobdiff_plain/4ba06413f535a389bab1987d2dcb46de3a912050..32cb310b42235f42ba8f9f70bb7ba3fe07b99377:/source/blog/posts/2009/09/life-in-hell.rst?ds=sidebyside diff --git a/source/blog/posts/2009/09/life-in-hell.rst b/source/blog/posts/2009/09/life-in-hell.rst index 72faac5..b2a0f96 100644 --- a/source/blog/posts/2009/09/life-in-hell.rst +++ b/source/blog/posts/2009/09/life-in-hell.rst @@ -8,7 +8,7 @@ a compiler that doesn't write proper debug information and you're writing a garbage collector. But you have to do it when things go wrong. And things usually go wrong. -__ http://proj.llucax.com.ar/blog/dgc/blog/post/-288428a1 +__ https://proj.llucax.com.ar/blog/dgc/blog/post/-288428a1 .. _D: http://www.digitalmars.com/d/ This is a small chronicle about how I managed to debug a weird problem =) @@ -19,9 +19,9 @@ no real D_ applications out there, suitable for an automated GC benchmark at least [#benchapp]_. Dil_ looked like a good candidate so I said *let's use Dil in the benchmark suite!*. -.. _`Naive GC`: http://git.llucax.com.ar/w/software/dgc/naive.git -__ http://proj.llucax.com.ar/blog/dgc/blog/post/37e6cb2a -.. _micro-benchmarks: http://git.llucax.com.ar/w/software/dgc/dgcbench.git +.. _`Naive GC`: https://git.llucax.com.ar/w/software/dgc/naive.git +__ https://proj.llucax.com.ar/blog/dgc/blog/post/37e6cb2a +.. _micro-benchmarks: https://git.llucax.com.ar/w/software/dgc/dgcbench.git .. _Dil: http://code.google.com/p/dil And I did. But Dil_ didn't work as I expected. Even when running it without @@ -74,9 +74,9 @@ to a multiple of a word, so I made `gc_malloc()`_ `align the data portion of the cell to a multiple of a word`__, but nothing. .. _Valgrind: http://valgrind.org/ -.. _`gc_malloc()`: http://git.llucax.com.ar/w/software/dgc/naive.git/blob/2d8639409b4749afd92266347f20b99da80e14c9:/gc/gc.d#l502 -__ http://git.llucax.com.ar/w/software/dgc/naive.git/commitdiff/39707a88bed116fbda8c590c9b6ff9193f30f58f -__ http://git.llucax.com.ar/w/software/dgc/naive.git/commitdiff/39707a88bed116fbda8c590c9b6ff9193f30f58f +.. _`gc_malloc()`: https://git.llucax.com.ar/w/software/dgc/naive.git/blob/2d8639409b4749afd92266347f20b99da80e14c9:/gc/gc.d#l502 +__ https://git.llucax.com.ar/w/software/dgc/naive.git/commitdiff/39707a88bed116fbda8c590c9b6ff9193f30f58f +__ https://git.llucax.com.ar/w/software/dgc/naive.git/commitdiff/39707a88bed116fbda8c590c9b6ff9193f30f58f Since Valgrind_ only detected that problem, which was at the static constructor of the module ``tango.io.Console``, I though it might be a Tango_ bug, so @@ -105,7 +105,7 @@ to the mutator (the `basic GC`__ can do that too if compiled with ``-debug=MEMSTOMP``). That would confirm that the swept memory were still in use. And it did. -__ http://git.llucax.com.ar/w/software/dgc/naive.git/commitdiff/bc664a95db5c7bab194f2e64cf96b6f092c5e60c +__ https://git.llucax.com.ar/w/software/dgc/naive.git/commitdiff/bc664a95db5c7bab194f2e64cf96b6f092c5e60c __ http://www.dsource.org/projects/tango/browser/tags/releases/0.99.8/lib/gc/basic The I tried this modified GC with *memory stomp* with my micro-benchmarks_ and @@ -131,7 +131,7 @@ to let the GC take over of **all** memory management... And *finally* all So, the problem should be either my `gc_free()`_ implementation (which is really simple) or a Dil_ bug. -.. _`gc_free()`: http://git.llucax.com.ar/w/software/dgc/naive.git/blob/2d8639409b4749afd92266347f20b99da80e14c9:/gc/gc.d#l661 +.. _`gc_free()`: https://git.llucax.com.ar/w/software/dgc/naive.git/blob/2d8639409b4749afd92266347f20b99da80e14c9:/gc/gc.d#l661 In order to get some extra information on where the problem is, I changed the `Cell.alloc()`_ implementation to use mmap_ to `allocate whole pages`__, one @@ -140,9 +140,9 @@ easily mprotect_ the cell *data* when the cell was swept (and un\ -mprotect_\ ing them when they were give back to the program) in order to make Dil_ segfault exactly where the freed memory was used. -.. _`Cell.alloc()`: http://git.llucax.com.ar/w/software/dgc/naive.git/blob/346f04b3e1026ded5af3ac95a483b2c3d05a6d60:/gc/cell.d#l86 +.. _`Cell.alloc()`: https://git.llucax.com.ar/w/software/dgc/naive.git/blob/346f04b3e1026ded5af3ac95a483b2c3d05a6d60:/gc/cell.d#l86 .. _mmap: http://www.kernel.org/doc/man-pages/online/pages/man2/mmap.2.html -__ http://git.llucax.com.ar/w/software/dgc/naive.git/commitdiff/cc637a89be9b51945246bd65fa15080464a90aca +__ https://git.llucax.com.ar/w/software/dgc/naive.git/commitdiff/cc637a89be9b51945246bd65fa15080464a90aca .. _mprotect: http://www.kernel.org/doc/man-pages/online/pages/man2/mprotect.2.html I ran Dil_ using strace_ and this is what happened::