December 27, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8774



--- Comment #29 from github-bugzilla@puremagic.com 2012-12-27 00:18:28 PST ---
Commit pushed to staging at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/c1e04220dcd9d4e49d43a60d7619a19cc38e73e7 fix Issue 8774 - 2.059 worked 2.060 does not: nested delegate memory corruption

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 27, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8774



--- Comment #30 from github-bugzilla@puremagic.com 2012-12-27 00:21:19 PST ---
Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/d1f6b562ecd64e2405be00cea7abf6b8d5f78a55 fix Issue 8774 - 2.059 worked 2.060 does not: nested delegate memory corruption

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 27, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8774



--- Comment #31 from Walter Bright <bugzilla@digitalmars.com> 2012-12-27 00:24:27 PST ---
I did find a long time bug in the way closures are nested. This was not a regression. The non-thread test cases here are now fixed, but I don't know about the original problem with joining, so I won't mark it fixed just yet.

It's likely that this was causing problems in other bugzilla issues.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 27, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8774



--- Comment #32 from Russel Winder <russel@winder.org.uk> 2012-12-27 03:25:57 PST ---
(In reply to comment #26)
[…]
> It's not exactly  an iterable or sequence, it's a lazy computation represented as a range. The key point is that it doesn't even attempt to store results somewhere nor avoid recomputation on demand.

If I can iterate over it then it is iterable ;-)

The real point is lazy evaluation vs. strict evaluation. And the question is, as stated early: why did this ever work? On the other hand, the code works now.

[…]

> So... can you print the addresses of threads (in both start & join loops) in 2.059 where it used to work. It's intriguing to see if this guess is on spot and what forces are at work there.

I will try and look into this in the new year.

[…]
> No, I suspect you are confusing these 2 cases:
> foreach(i; x..y)
> {
>    threads ~= delegate (){
>        //use i here
>    }
> }
> 
> vs
> 
> threads = map!( (int i){ use i here ... })(...);

I suspect you are 100% correct :-) Thanks for the "heads up", code duly amended and still working.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 27, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8774



--- Comment #33 from Dmitry Olshansky <dmitry.olsh@gmail.com> 2012-12-27 03:37:35 PST ---
(In reply to comment #31)
> I did find a long time bug in the way closures are nested. This was not a regression.

Terrific, thanks!

> The non-thread test cases here are now fixed, but I don't know
> about the original problem with joining, so I won't mark it fixed just yet.
> 

The code shouldn't work and after fixing a bug in the compiler and in the code itself it works :)

For me on Win32 the breakdown across full versions (dmd+phobos+druntime) is as
follows:

2.061 with the latest patch:
with .array: works
w/o  .array: fails as it should (Unnable to join)

2.057-2.058 and 2.060
with .array: segfaults due to closure bug with stack corruption, can workaround
in the same way as discussed here
w/o  .array: fails as it should (Unnable to join)

2.059:
with .array: fails to compile with a range of Thread (!)
w/o  .array: fails as it should (Unable to join)

2.053-2.056:
 -fails to compile (no inference for nested function), fixing that it fails
with segfault (the same closure thing)
 -fails as it should  (Unable to join)

2.052 - fails to compile(cannot access frame of ...)

2.049-2.051 had no std.datetime & std.parallelism but even with it ripped off fails to compile as 2.052.

Thus I conclude that the issue with threading is invalid and is not a regression.

The only mystery remaining is why (and when?) it *did* work before. Probably it did work with LDC but then stopped. LDC is not affected by the closure bug and uses a patched fork of D run-time.

So I'd go ahead and close it as resolved fixed as a long standing critical bug with stack corruption in nested delegates.

Russel are you OK with that?

> It's likely that this was causing problems in other bugzilla issues.

Time to go on a witch-hunt! Maxim presented an excelent list to check.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 27, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8774



--- Comment #34 from Dmitry Olshansky <dmitry.olsh@gmail.com> 2012-12-27 03:52:06 PST ---
*** Issue 8505 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 27, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8774



--- Comment #35 from Maxim Fomin <maxim@maxim-fomin.ru> 2012-12-27 08:02:56 PST ---
(In reply to comment #31)
> I did find a long time bug in the way closures are nested. This was not a regression. The non-thread test cases here are now fixed, but I don't know about the original problem with joining, so I won't mark it fixed just yet.
> 
> It's likely that this was causing problems in other bugzilla issues.

Walter, take look at issue 8832. It is the same problem, but the code still segfaults. It seems your commits do not entirely fix the bug, although they fix a couple of other which are closed now.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 27, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8774



--- Comment #36 from Maxim Fomin <maxim@maxim-fomin.ru> 2012-12-27 08:11:22 PST ---
(In reply to comment #31)
> I did find a long time bug in the way closures are nested. This was not a regression. The non-thread test cases here are now fixed, but I don't know about the original problem with joining, so I won't mark it fixed just yet.
> 
> It's likely that this was causing problems in other bugzilla issues.

Walter, please take a look also at issue 7978. It still shows problem.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 27, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8774



--- Comment #37 from Maxim Fomin <maxim@maxim-fomin.ru> 2012-12-27 08:15:55 PST ---
(In reply to comment #31)

> It's likely that this was causing problems in other bugzilla issues.

Others (fixed by these commits) issues are: issue 8514, issue 8854, issue 5064,
issue 1350

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 27, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8774



--- Comment #38 from Walter Bright <bugzilla@digitalmars.com> 2012-12-27 10:15:02 PST ---
(In reply to comment #37)
> (In reply to comment #31)
> 
> > It's likely that this was causing problems in other bugzilla issues.
> 
> Others (fixed by these commits) issues are: issue 8514, issue 8854, issue 5064,
> issue 1350

Woo-hoo!

It sure was a nasty one.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------