Pretty weird behavior in finalizer stack (bug?)
i encountering weird problem .net 1.1.
have class
when class collected, death signal send mystaticclass. based on that, mystaticclass performs several operations, , call stack of depth 6 generated (starting @ myobject.finalize()). (ps: know dispose pattern etc, not problem here, trully need intercept finalizer).
comes weird bug
basically, through recursive method call, 1 argument (a simple class), becomes null. cant figure out how such behavior possible. object still exists in context of method call of methoda , not in methodb. bug of .net ? forbidden make recursive calls in finalizer?
can me solve that, stuck issue.
in advance,
joannes
have class
public class myobject { int myid; ~myobject() { // lock , misc. snipped mystaticclass.signaldeathof(myid); } } |
when class collected, death signal send mystaticclass. based on that, mystaticclass performs several operations, , call stack of depth 6 generated (starting @ myobject.finalize()). (ps: know dispose pattern etc, not problem here, trully need intercept finalizer).
comes weird bug
public class mystaticclass { public static void signaldeathof(int id) { // not 'object' class in code // plus 'obj' referenced rooted object. object obj = new object(); methoda(id, obj); } public static void methoda(int id, object obj) { // work // obj != null (seen through debugger + assert) methodb(id, obj); } public static void methodb(int id, object obj) { // bug: obj == null (seen through debugger + assert) // 'id' has expected value. } } |
basically, through recursive method call, 1 argument (a simple class), becomes null. cant figure out how such behavior possible. object still exists in context of method call of methoda , not in methodb. bug of .net ? forbidden make recursive calls in finalizer?
can me solve that, stuck issue.
in advance,
joannes
hi,
didn't have time full research, here see:
i don't think it's bug, though behaviour not documented.
basically while passing object different domain within finalizer, domain being unloaded different thread.
so, if avoid that, you'll ok.
didn't have time full research, here see:
i don't think it's bug, though behaviour not documented.
basically while passing object different domain within finalizer, domain being unloaded different thread.
so, if avoid that, you'll ok.
.NET Framework > Common Language Runtime Internals and Architecture
Comments
Post a Comment