InvalidMemoryOperationError when calling functions from destructors

2013-04-25 Thread Volfram
I've run into a problem which I'd like to hope is a bug, but let's see if we can figure out if I'm doing something stupid first, eh? When a destructor calls a function from another module, I get an InvalidMemoryOperationError. When a destructor calls a function from another class in the same

Re: InvalidMemoryOperationError when calling functions from destructors

2013-04-25 Thread Vladimir Panteleev
On Thursday, 25 April 2013 at 15:50:27 UTC, Volfram wrote: Further info can be provided if necessary. Can you provide a full program that exhibits the behavior, or at least a stack trace? You may need to recompile Phobos and Druntime with the -gs flag to enable correct stacktraces.

Re: InvalidMemoryOperationError when calling functions from destructors

2013-04-25 Thread Jacob Carlborg
On 2013-04-25 17:50, Volfram wrote: I've run into a problem which I'd like to hope is a bug, but let's see if we can figure out if I'm doing something stupid first, eh? When a destructor calls a function from another module, I get an InvalidMemoryOperationError. When a destructor calls a functi

Re: InvalidMemoryOperationError when calling functions from destructors

2013-04-25 Thread Volfram
On Thursday, 25 April 2013 at 16:00:31 UTC, Vladimir Panteleev wrote: On Thursday, 25 April 2013 at 15:50:27 UTC, Volfram wrote: Further info can be provided if necessary. Can you provide a full program that exhibits the behavior, or at least a stack trace? You may need to recompile Phobos

Re: InvalidMemoryOperationError when calling functions from destructors

2013-04-25 Thread Vladimir Panteleev
On Thursday, 25 April 2013 at 16:17:57 UTC, Jacob Carlborg wrote: You cannot access GC controlled memory in class destructors. Not true. There's no guarantee in which order the destructors will be called. You don't know if the memory is still valid in a destructor. The memory is valid, it'

Re: InvalidMemoryOperationError when calling functions from destructors

2013-04-25 Thread David
> Regardless, the above (accessing objects in destructors) is not related > to the InvalidMemoryOperationError. See the documentation for it: > http://dlang.org/phobos/core_exception.html#.InvalidMemoryOperationError I had/have the same problem, it also occurs if you allocate in a destructor durin

Re: InvalidMemoryOperationError when calling functions from destructors

2013-04-25 Thread Jacob Carlborg
On 2013-04-25 19:57, Vladimir Panteleev wrote: Regardless, the above (accessing objects in destructors) is not related to the InvalidMemoryOperationError. See the documentation for it: http://dlang.org/phobos/core_exception.html#.InvalidMemoryOperationError Yeah, I though that was weird. -- /

Re: InvalidMemoryOperationError when calling functions from destructors

2013-04-26 Thread Volfram
Further inspection suggests that the BetaClass object I was accessing was already finalized by the time the AlphaClass object got around to trying to mess with it. Conclusion is that whether it's the in-destructor access or not, it's simply not safe to try to clean things up this way. I think

Re: InvalidMemoryOperationError when calling functions from destructors

2013-04-26 Thread Steven Schveighoffer
On Thu, 25 Apr 2013 10:57:13 -0700, Vladimir Panteleev wrote: On Thursday, 25 April 2013 at 16:17:57 UTC, Jacob Carlborg wrote: You cannot access GC controlled memory in class destructors. Not true. Can you be more specific? Maybe the wording was too strong. Should say "you shouldn't

Re: InvalidMemoryOperationError when calling functions from destructors

2013-04-27 Thread Vladimir Panteleev
On Saturday, 27 April 2013 at 06:12:03 UTC, Steven Schveighoffer wrote: On Thu, 25 Apr 2013 10:57:13 -0700, Vladimir Panteleev wrote: On Thursday, 25 April 2013 at 16:17:57 UTC, Jacob Carlborg wrote: You cannot access GC controlled memory in class destructors. Not true. Can you be more s

Re: InvalidMemoryOperationError when calling functions from destructors

2013-04-28 Thread Steven Schveighoffer
On Sat, 27 Apr 2013 07:58:25 -0700, Vladimir Panteleev wrote: On Saturday, 27 April 2013 at 06:12:03 UTC, Steven Schveighoffer wrote: On Thu, 25 Apr 2013 10:57:13 -0700, Vladimir Panteleev wrote: On Thursday, 25 April 2013 at 16:17:57 UTC, Jacob Carlborg wrote: You cannot access GC con

Re: InvalidMemoryOperationError when calling functions from destructors

2013-04-28 Thread Vladimir Panteleev
On Sunday, 28 April 2013 at 14:44:32 UTC, Steven Schveighoffer wrote: On Sat, 27 Apr 2013 07:58:25 -0700, Vladimir Panteleev wrote: On Saturday, 27 April 2013 at 06:12:03 UTC, Steven Schveighoffer wrote: On Thu, 25 Apr 2013 10:57:13 -0700, Vladimir Panteleev wrote: On Thursday, 25 April 2

Re: InvalidMemoryOperationError when calling functions from destructors

2013-04-28 Thread Steven Schveighoffer
On Sun, 28 Apr 2013 16:25:06 -0700, Vladimir Panteleev wrote: On Sunday, 28 April 2013 at 14:44:32 UTC, Steven Schveighoffer wrote: No, destructors are called along with deallocation. At the moment, the GC mutex is held while the collection is in progress, so it's not possible that a d