Weird std.stdio threading bug?

dsimcha dsimcha at yahoo.com
Tue Apr 28 08:15:59 PDT 2009


== Quote from Steven Schveighoffer (schveiguy at yahoo.com)'s article
> On Tue, 28 Apr 2009 10:16:21 -0400, dsimcha <dsimcha at yahoo.com> wrote:
> > == Quote from Steven Schveighoffer (schveiguy at yahoo.com)'s article
> >> On Tue, 28 Apr 2009 09:51:54 -0400, dsimcha <dsimcha at yahoo.com> wrote:
> >> > == Quote from Steven Schveighoffer (schveiguy at yahoo.com)'s article
> >> >> Have you tried synchronizing on an actual object?  I remember some
> >> time
> >> >> back how Walter proposed removing synchronized as you have written
> >> it.
> >> >> Not sure what happened for that.
> >> >> The way you have written the code, assuming that the synchronized
> >> >> statement is doing what you think it's doing, the call to writeln
> >> should
> >> >> be completely syncrhonous, so multithreading issues or not, it should
> >> >> work.
> >> >> -Steve
> >> >
> >> > Good idea, still doesn't work.  All of the loops just die after a few
> >> > iterations,
> >> > leaving me at 0% CPU usage.  This happens on multiple win32 boxes.
> >> > Could someone
> >> > please test this on some other OS?
> >> Latest compiler? D1 D2?
> >> -Steve
> >
> > 2.029.  Thanks for your help.  I'm just trying to make sure this is a
> > legit bug
> > and maybe understand its underpinnings a little better before I file a
> > bug report,
> > because if it is a legit bug, it's a pretty serious one.
> Yep, I confirm (on WinXP).  I get 2 or three outputs and then hang.
> I also tried several different things:
> Things that worked (continually output "Doing stuff."):
> 1. removing the synchronized(lock) statement
> 2. Changing the number of threads to 0
> 3. Changing the print line to use printf("Doing stuff.\n");
> Things that still failed:
> 4. Changing the number of threads to 1 (which would mean 2 threads, the
> main thread and the sub thread).
> The fact that 2 worked and 3 worked indicates to me that it's not simply a
> bug involving the lock mechanism, it's definitely something to do with
> writeln.
> I'd file a bug with the latest code you posted.
> I tried the original code once on Linux.  I get much more printouts than 2
> or 3, but it still hangs.
> So it's cross-platform.
> -Steve

Done.  http://d.puremagic.com/issues/show_bug.cgi?id=2907

Thanks for your help.



More information about the Digitalmars-d mailing list