View mode: basic / threaded / horizontal-split · Log in · Help
October 04, 2004
Freezing bug on Linux
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;
}
October 05, 2004
Re: Freezing bug on Linux
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;
> }
> 
>
October 05, 2004
Re: Freezing bug on Linux
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;
>> }
>> 
>>
October 05, 2004
Re: Freezing bug on Linux
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;
>>>}
>>>
>>>
> 
>
Top | Discussion index | About this forum | D home