delegates and threads
Johan Granberg
lijat.meREM at OVEgmail.com
Wed Jul 19 15:34:27 PDT 2006
I have been writing a function that takes an array of delegates and
executes them in parallel. (attached)
It works sort of but I ran into problems when I tried to use delegates
that referenced the frame/this pointer. (gdc-0.18 osx based on dmd 0.157)
Object a=new Object();
void foo(){printf("p");}//OK
void foo(){printf("%*s",a.toString());}//segfault
Is their anything in the language that prevents a thread from reading
the stack of another through a pointer? (or is this a language/compiler
bug) I have written a reduced test case bellow.
Thanks in advance.
//begin testcase
import parallel;
class A
{
void b(){printf("boo\n");}
}
void main()
{
A a=new A();
void delegate()[] o;
o~=delegate void()
{
printf("minsk\n");
};
o~=delegate void()
{
a.b();
};
o~=delegate void()
{
printf("foo\n");
};
printf("before\n");
parallelize(o);
printf("after\n");
}
//prints
Starting program: /Users/johan/Desktop/test/test
Reading symbols for shared libraries . done
before
minsk
foo
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x00000000
[Switching to process 3902 thread 0xf03]
_Dmain12__dgliteral2FZv () at test.d:17
17 a.b();
//end
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: parallel.d
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20060720/ef466d84/attachment.ksh>
More information about the Digitalmars-d
mailing list