From: ts Date: 2004-09-15T18:26:05+09:00 Subject: Re: [PATCH] dir.c --- Dir.chdir error handling >>>>> "H" == H Yamamoto writes: >> The problem with such examples is that only *one* person can reproduce >> it. Difficult to say something about it. H> Yes, I couldn't reproduce that in my gcc (2.9 in beos)... H> And even this code didn't crash. It's a little more complex : I can give you an example with 1.8.0 Look at [ruby-talk:80435] and try this script with 1.8.0 ------------------------------------------------------------ thread_block= Proc.new do 1.upto(20000) do a = {1 => 2} end Thread.new &thread_block end 1.upto(120) do Thread.new &thread_block end Thread.stop ------------------------------------------------------------ Now if ruby crash, rewrite mark_locations_array() like this ------------------------------------------------------------ static void mark_locations_array(x, n) register VALUE *x; register long n; { VALUE tmp; while (n--) { if (is_pointer_to_heap((void *)*x)) { tmp = *x; rb_gc_mark(tmp); } x++; } } ------------------------------------------------------------ and you'll see that ruby work (normally) If you look at the patch to correct this problem, written by matz, you'll see that it has nothing to do with `volatile' Now if you want to know why I've introduced the variable `tmp', this is just to make in sort that the assembler was different and because the assembler was modified this hyde completely the bug. What I want to say is : when you have such a problem (bug that you can see only with some C flags like -O3) this don't means that it exist fatally a problem with `volatile' and worst you can make some subtle modifications (like add `volatile') and this will hide the real bug. Guy Decoux