| Thread overview | ||||||
|---|---|---|---|---|---|---|
|
September 08, 2008 finalizer's not really finalizers? - causing segfaults | ||||
|---|---|---|---|---|
| ||||
One of the segfaults I was getting was in _d_finalizer() - c.destructor was pointing to an invalid address.. What I'm suspecting happens is that the compiler thinks that casting the pointer to a (ClassInfo **) appears to be valid, but is not actually.. and then c.destructor points to an invalid address, causing a segfault. by removing the calls in the GC to the finalizer - I think this bug gets solved (however obviously ~this() probably doesnt work any more..) Is this a feasible situation???? Regards Alan | ||||
September 08, 2008 Re: finalizer's not really finalizers? - causing segfaults | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Alan Knowles | Alan Knowles wrote:
> One of the segfaults I was getting was in
> _d_finalizer() - c.destructor was pointing to an invalid address..
>
> What I'm suspecting happens is that the compiler thinks that casting the pointer to a (ClassInfo **) appears to be valid, but is not actually.. and then c.destructor points to an invalid address, causing a segfault.
>
> by removing the calls in the GC to the finalizer - I think this bug gets solved (however obviously ~this() probably doesnt work any more..)
>
> Is this a feasible situation????
It's more likely that you have a dangling reference or something like that.
Sean
| |||
September 10, 2008 Re: finalizer's not really finalizers? - causing segfaults | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Sean Kelly | I think i nailed it down to one of the destructors calling std.gc.genCollect()
I'm wondering though why that did not cause a deadlock situation
genCollect() -> calls the destructor -> destructor calls genCollect() or any other gc related stuff - it's supposed to be caught by the gcLock??
It looks like an inherent risk of using destructors - I could not see any code that tries to prevent memory operations from destructors..???
Regards
Alan
Sean Kelly wrote:
> Alan Knowles wrote:
>> One of the segfaults I was getting was in
>> _d_finalizer() - c.destructor was pointing to an invalid address..
>>
>> What I'm suspecting happens is that the compiler thinks that casting the pointer to a (ClassInfo **) appears to be valid, but is not actually.. and then c.destructor points to an invalid address, causing a segfault.
>>
>> by removing the calls in the GC to the finalizer - I think this bug gets solved (however obviously ~this() probably doesnt work any more..)
>>
>> Is this a feasible situation????
>
> It's more likely that you have a dangling reference or something like that.
>
>
> Sean
| |||
September 10, 2008 Re: finalizer's not really finalizers? - causing segfaults | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Alan Knowles | Alan Knowles wrote:
> I think i nailed it down to one of the destructors calling std.gc.genCollect()
>
> I'm wondering though why that did not cause a deadlock situation
>
> genCollect() -> calls the destructor -> destructor calls genCollect() or any other gc related stuff - it's supposed to be caught by the gcLock??
Mutexes in D are recursive. I don't think this should change, as it allows a dtor to allocate memory, for example, which can be useful in logging and so on.
Sean
| |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply