www.digitalmars.com         C & C++   DMDScript  

D.gnu - Freezing bug on Linux

reply teqDruid <teqDruid_member pathlink.com> writes:
I was hoping that this Linux GC bug was in the back-end, so it wouldn't be
replicated into GDC, but it would appear not.  I'm going to look into it some
more, but I don't have a whole lot of experience with compilers (or pthreads, or
anything relevant to this bug) so I doubt I'll be able to figure it out.  Walter
hasn't replied regarding it.  I'd appriciate it if someone would help out and
take a look... It's really holding me up. Here's the code... it freezes, and can
only be killed by sending it a SIGKILL.

TIA
John

mport std.thread;
import std.gc;

int main() {
Object x;
int n;
GCStats stats;
Thread t = new Thread(delegate int() {
Object y;
while(1) {
y = new Object;
//Thread.yield();
}
return 0;
});
t.start();
while(1) {

x = new Object;
getStats(stats);
printf("%u %u %u %u\n",stats.poolsize,stats.usedsize,
stats.freeblocks,stats.pageblocks);
//Thread.yield();
//    if (n++ == 1000) fullCollect();
}
return 0;
}
Oct 04 2004
parent reply David Friedman <d3rdclsmail earthlink.net> writes:
teqDruid wrote:

 I was hoping that this Linux GC bug was in the back-end, so it wouldn't be
 replicated into GDC, but it would appear not.  I'm going to look into it some
 more, but I don't have a whole lot of experience with compilers (or pthreads,
or
 anything relevant to this bug) so I doubt I'll be able to figure it out. 
Walter
 hasn't replied regarding it.  I'd appriciate it if someone would help out and
 take a look... It's really holding me up. Here's the code... it freezes, and
can
 only be killed by sending it a SIGKILL.
 
 TIA
 John
 
Found the problem -- Solution: in thread.d:Thread.pauseAll, move the "while (npause--)" loop outside of the for loop. This is in the version(linux) section (and version(GNU) for GDC). David
 mport std.thread;
 import std.gc;
 
 int main() {
 Object x;
 int n;
 GCStats stats;
 Thread t = new Thread(delegate int() {
 Object y;
 while(1) {
 y = new Object;
 //Thread.yield();
 }
 return 0;
 });
 t.start();
 while(1) {
 
 x = new Object;
 getStats(stats);
 printf("%u %u %u %u\n",stats.poolsize,stats.usedsize,
 stats.freeblocks,stats.pageblocks);
 //Thread.yield();
 //    if (n++ == 1000) fullCollect();
 }
 return 0;
 }
 
 
Oct 04 2004
parent reply teqDruid <me teqdruid.com> writes:
Damn! I've gone over that code a few times, and didn't notice that. 
Thanks!  Should I post the patch on the bugs NG, or do you want to?

John

On Mon, 04 Oct 2004 23:15:34 -0400, David Friedman wrote:

 teqDruid wrote:
 
 I was hoping that this Linux GC bug was in the back-end, so it wouldn't be
 replicated into GDC, but it would appear not.  I'm going to look into it some
 more, but I don't have a whole lot of experience with compilers (or pthreads,
or
 anything relevant to this bug) so I doubt I'll be able to figure it out. 
Walter
 hasn't replied regarding it.  I'd appriciate it if someone would help out and
 take a look... It's really holding me up. Here's the code... it freezes, and
can
 only be killed by sending it a SIGKILL.
 
 TIA
 John
 
Found the problem -- Solution: in thread.d:Thread.pauseAll, move the "while (npause--)" loop outside of the for loop. This is in the version(linux) section (and version(GNU) for GDC). David
 mport std.thread;
 import std.gc;
 
 int main() {
 Object x;
 int n;
 GCStats stats;
 Thread t = new Thread(delegate int() {
 Object y;
 while(1) {
 y = new Object;
 //Thread.yield();
 }
 return 0;
 });
 t.start();
 while(1) {
 
 x = new Object;
 getStats(stats);
 printf("%u %u %u %u\n",stats.poolsize,stats.usedsize,
 stats.freeblocks,stats.pageblocks);
 //Thread.yield();
 //    if (n++ == 1000) fullCollect();
 }
 return 0;
 }
 
Oct 05 2004
parent David Friedman <d3rdclsmail earthlink.net> writes:
Patch posted.

teqDruid wrote:

 Damn! I've gone over that code a few times, and didn't notice that. 
 Thanks!  Should I post the patch on the bugs NG, or do you want to?
 
 John
 
 On Mon, 04 Oct 2004 23:15:34 -0400, David Friedman wrote:
 
 
teqDruid wrote:


I was hoping that this Linux GC bug was in the back-end, so it wouldn't be
replicated into GDC, but it would appear not.  I'm going to look into it some
more, but I don't have a whole lot of experience with compilers (or pthreads, or
anything relevant to this bug) so I doubt I'll be able to figure it out.  Walter
hasn't replied regarding it.  I'd appriciate it if someone would help out and
take a look... It's really holding me up. Here's the code... it freezes, and can
only be killed by sending it a SIGKILL.

TIA
John
Found the problem -- Solution: in thread.d:Thread.pauseAll, move the "while (npause--)" loop outside of the for loop. This is in the version(linux) section (and version(GNU) for GDC). David
mport std.thread;
import std.gc;

int main() {
Object x;
int n;
GCStats stats;
Thread t = new Thread(delegate int() {
Object y;
while(1) {
y = new Object;
//Thread.yield();
}
return 0;
});
t.start();
while(1) {

x = new Object;
getStats(stats);
printf("%u %u %u %u\n",stats.poolsize,stats.usedsize,
stats.freeblocks,stats.pageblocks);
//Thread.yield();
//    if (n++ == 1000) fullCollect();
}
return 0;
}
Oct 05 2004