segfault when function with cilk_for returns

segfault when function with cilk_for returns

Hello,Thanks a lot for Cilk++!I just wanted to report something that seems like a bug. Consider this:


double *values() {
	double *v = (double *)malloc(10 * sizeof(double));
	cilk_for(int i=0; i < 10; i++) 
		v[i] = 0.123 * i;

	return v;

int cilk_main() {
	double *v = values();
	printf("%gn", v[1]);

This program works in serial semantics (-fcilk-stub). However, the normal semantics gives a segmentation fault.My version iscilk++ (GCC) 4.2.4 (Cilk Arts build 8503).Best regards,Bruno

2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Hi Bruno,

Yes, that does appear to be a bug. I've reproduced it on my computer. Even when run on one core, it still segfaults, which suggests to me that the cilk_for body is being lifted wrong. But the bug disappears when all of the work is moved into cilk_main() which is very puzzling.

I'm afraid there aren't any planned updates for Cilk++ (since our efforts are primarily focused on thenew product)so the bug is what it is.

Leave a Comment

Please sign in to add a comment. Not a member? Join today