Re: Segfault with std.container.Array but not regular dynamic array

2012-11-29 Thread Maxim Fomin
On Wednesday, 28 November 2012 at 22:13:05 UTC, Dan wrote: On Wednesday, 28 November 2012 at 20:30:41 UTC, Maxim Fomin wrote: On Wednesday, 28 November 2012 at 18:08:59 UTC, Dan wrote: This code with version=bug produces garbage because of opAssign. It seems that opAssign is actually called

Re: Segfault with std.container.Array but not regular dynamic array

2012-11-29 Thread Dan
On Thursday, 29 November 2012 at 07:59:02 UTC, Maxim Fomin wrote: This doesn't look like assembly for previous source. Please provide the source for which you have assembly and tell which dmd options do you use. Well, I'm using the latest dmd (from the trunk), phobos, druntime, so I could

Re: Segfault with std.container.Array but not regular dynamic array

2012-11-29 Thread Maxim Fomin
On Thursday, 29 November 2012 at 12:38:03 UTC, Dan wrote: On Thursday, 29 November 2012 at 07:59:02 UTC, Maxim Fomin wrote: This doesn't look like assembly for previous source. Please provide the source for which you have assembly and tell which dmd options do you use. Well, I'm using the

Re: Segfault with std.container.Array but not regular dynamic array

2012-11-29 Thread Dan
On Thursday, 29 November 2012 at 15:06:07 UTC, Maxim Fomin wrote: On Thursday, 29 November 2012 at 12:38:03 UTC, Dan wrote: On Thursday, 29 November 2012 at 07:59:02 UTC, Maxim Fomin wrote: This doesn't look like assembly for previous source. Please provide the source for which you have

Re: Segfault with std.container.Array but not regular dynamic array

2012-11-28 Thread Dan
On Tuesday, 27 November 2012 at 18:04:19 UTC, Maxim Fomin wrote: I think it crashes because of using associative array. Assignment to an absent aa member causes memory allocation without proper object construction, and immediately after compiler issues call to opAssign for not-constructed

Re: Segfault with std.container.Array but not regular dynamic array

2012-11-28 Thread Dan
On Monday, 26 November 2012 at 15:44:42 UTC, Joseph Rushton Wakeling wrote: Hello all, I'm writing some code which is meant to represent a network of linked nodes. [snip] Ok, another follow up. I can reproduce your segfault using your posted code, it is included below. But the interesting

Re: Segfault with std.container.Array but not regular dynamic array

2012-11-28 Thread Maxim Fomin
On Wednesday, 28 November 2012 at 13:09:36 UTC, Dan wrote: On Monday, 26 November 2012 at 15:44:42 UTC, Joseph Rushton Wakeling wrote: Hello all, I'm writing some code which is meant to represent a network of linked nodes. [snip] Ok, another follow up. I can reproduce your segfault using

Re: Segfault with std.container.Array but not regular dynamic array

2012-11-28 Thread Joseph Rushton Wakeling
On 11/28/2012 02:09 PM, Dan wrote: It would be interesting to know if Joseph was doing his testing out in unittest or in a main. In main -- the code you saw attached to my earlier email is the code I was running. Thanks very much for your efforts at chasing down the bug!

Re: Segfault with std.container.Array but not regular dynamic array

2012-11-28 Thread Dan
On Wednesday, 28 November 2012 at 13:43:04 UTC, Maxim Fomin wrote: On Wednesday, 28 November 2012 at 13:09:36 UTC, Dan wrote: Actually bug is still there - changing unittest to main() does not fix program, even if it seems to run correctly. The problem with memory corruption is that it may

Re: Segfault with std.container.Array but not regular dynamic array

2012-11-28 Thread Maxim Fomin
On Wednesday, 28 November 2012 at 18:08:59 UTC, Dan wrote: Thanks! I see what you are saying in valgrind. However, the following shows no problem in valgrind. Same code, only using S instead of RefCounted!(int). How could that be explained? Note that both RefCount!() and your posted S have

Re: Segfault with std.container.Array but not regular dynamic array

2012-11-28 Thread Dan
On Wednesday, 28 November 2012 at 20:30:41 UTC, Maxim Fomin wrote: On Wednesday, 28 November 2012 at 18:08:59 UTC, Dan wrote: This code with version=bug produces garbage because of opAssign. It seems that opAssign is actually called before accessing map: Maxim, thanks for looking more at

Re: Segfault with std.container.Array but not regular dynamic array

2012-11-27 Thread Joseph Rushton Wakeling
On 11/26/2012 11:42 PM, Dan wrote: Ok, now I really want to know why it crashes. I've narrowed it down to an example below. It seems there is a problem with RefCounted being used as value in a map. I don't have the expertise to understand the assembly, but just to note that even with all the

Re: Segfault with std.container.Array but not regular dynamic array

2012-11-27 Thread Maxim Fomin
On Monday, 26 November 2012 at 22:42:53 UTC, Dan wrote: On Monday, 26 November 2012 at 19:14:09 UTC, Joseph Rushton Wakeling wrote: On 11/26/2012 04:07 PM, Joseph Rushton Wakeling wrote: Ok, now I really want to know why it crashes. I've narrowed it down to an example below. It seems there

Re: Segfault with std.container.Array but not regular dynamic array

2012-11-27 Thread Ali Çehreli
On 11/27/2012 10:04 AM, Maxim Fomin wrote: On Monday, 26 November 2012 at 22:42:53 UTC, Dan wrote: On Monday, 26 November 2012 at 19:14:09 UTC, Joseph Rushton Wakeling wrote: On 11/26/2012 04:07 PM, Joseph Rushton Wakeling wrote: Ok, now I really want to know why it crashes. I've narrowed it

Re: Segfault with std.container.Array but not regular dynamic array

2012-11-27 Thread Maxim Fomin
On Tuesday, 27 November 2012 at 18:30:07 UTC, Ali Çehreli wrote: Same problem under Linux. Somebody, please file this bug! Thank you! :) Ali http://d.puremagic.com/issues/show_bug.cgi?id=9084

Segfault with std.container.Array but not regular dynamic array

2012-11-26 Thread Joseph Rushton Wakeling
Hello all, I'm writing some code which is meant to represent a network of linked nodes. Each node is represented by a struct that contains the node's ID and an array of links to other nodes. Just as an experiment, I've tried out two different ways of doing this:

Segfault with std.container.Array but not regular dynamic array

2012-11-26 Thread Joseph Rushton Wakeling
Hello all, I'm writing some code which is meant to represent a network of linked nodes. Each node is represented by a struct that contains the node's ID and an array of links to other nodes. Just as an experiment, I've tried out two different ways of doing this:

Re: Segfault with std.container.Array but not regular dynamic array

2012-11-26 Thread Joseph Rushton Wakeling
On 11/26/2012 04:07 PM, Joseph Rushton Wakeling wrote: I'm a bit confused as to why. By the look of things it's actually the creation of new entries in the Node[uint] associative array, rather than appending links to the individual nodes. Can anyone advise? I have noticed that changing Node1

Re: Segfault with std.container.Array but not regular dynamic array

2012-11-26 Thread Dan
On Monday, 26 November 2012 at 19:14:09 UTC, Joseph Rushton Wakeling wrote: On 11/26/2012 04:07 PM, Joseph Rushton Wakeling wrote: I'm a bit confused as to why. By the look of things it's actually the creation of new entries in the Node[uint] associative array, rather than appending links to

Re: Segfault with std.container.Array but not regular dynamic array

2012-11-26 Thread Dan
On Monday, 26 November 2012 at 19:14:09 UTC, Joseph Rushton Wakeling wrote: On 11/26/2012 04:07 PM, Joseph Rushton Wakeling wrote: Ok, now I really want to know why it crashes. I've narrowed it down to an example below. It seems there is a problem with RefCounted being used as value in a