<div><font style="BACKGROUND-COLOR: #ece9ed">Hello,</font></div>
<div><font style="BACKGROUND-COLOR: #ece9ed"></font> </div>
<div><font style="BACKGROUND-COLOR: #ece9ed">I got a question about the script function class(SwfdecAsScriptFunction) design in swfdec.</font></div>
<div><font style="BACKGROUND-COLOR: #ece9ed"></font> </div>
<div><font style="BACKGROUND-COLOR: #ece9ed">Why doesn't a script function mark its target(SwfdecAsScriptFunction::target) in the marking phase? What if the function's target has been destroyed while the function itself is still kept alive? (Answer myself: then there would be a segfault when executing that function)</font></div>
<div><font style="BACKGROUND-COLOR: #ece9ed"></font> </div>
<div><font style="BACKGROUND-COLOR: #ece9ed">Let me give a more specific case:</font></div>
<div><font style="BACKGROUND-COLOR: #ece9ed"></font> </div>
<div><font style="BACKGROUND-COLOR: #ece9ed">(1)swf(movie) 'A' defines a script function 'movie_a_func()' inside its body.</font></div>
<div><font style="BACKGROUND-COLOR: #ece9ed">(2)swf(movie) 'B' loads movie 'A' at runtime by using loadMovieNum('A.swf', 2);</font></div>
<div><font style="BACKGROUND-COLOR: #ece9ed">(3)movie 'B' then create a reference to function 'movie_a_func()' , eg. movie_b_func = _level2.movie_a_func;</font></div>
<div><font style="BACKGROUND-COLOR: #ece9ed">(4)unload movie 'A' by using _level2.unloadMovie(); </font></div>
<div><font style="BACKGROUND-COLOR: #ece9ed">(5)next frame; //Note target of ''movie_a_func', which is 'A' is destroyed and collected here.</font></div>
<div><font style="BACKGROUND-COLOR: #ece9ed">(6)call function 'movie_b_func'; // bomb, trying to reference its target(movie A) that is already freed.</font></div>
<div><font style="BACKGROUND-COLOR: #ece9ed"></font> </div>
<div><font style="BACKGROUND-COLOR: #ece9ed">The above case could happen more easily when set GC threshold to zero(alway gc). </font></div>
<div><font style="BACKGROUND-COLOR: #ece9ed"></font> </div>
<div><font style="BACKGROUND-COLOR: #ece9ed">The obvious fix to me is always marking the target of a script function, but I am not 100% sure if it's the right way. It would be helpful if anyone could confirm with me. (BTW, I'v made the real tests described as above.)</font></div>
<div><font style="BACKGROUND-COLOR: #ece9ed"></font> </div>
<div><font style="BACKGROUND-COLOR: #ece9ed">Yes, I'll file a bug if get confirmed or at least there is someone concerning this mail.</font></div>
<div><font style="BACKGROUND-COLOR: #ece9ed"></font> </div>
<div><font style="BACKGROUND-COLOR: #ece9ed"></font> </div>
<div><font style="BACKGROUND-COLOR: #ece9ed">--zou</font></div>
<div><font style="BACKGROUND-COLOR: #ece9ed"></font> </div>
<div><font style="BACKGROUND-COLOR: #ece9ed"></font> </div>
<div><font style="BACKGROUND-COLOR: #ece9ed"></font> </div>