www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
Archives

D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript

D.gnu - Freezing bug on Linux

↑ ↓ ← 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
↑ ↓ 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
↑ ↓ 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
↑ ↓ → 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