{"issue":{"state":"open","created_at":"2011-11-26T20:06:20Z","updated_at":"2011-12-05T13:43:24Z","comments":3,"user":{"gravatar_id":"f7450036a7dda71563d982e70d51d32a","id":541607,"url":"https://api.github.com/users/null77","login":"null77","avatar_url":"https://secure.gravatar.com/avatar/f7450036a7dda71563d982e70d51d32a?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"body":"The following kernel causes a crash, with a null pointer dereference, in my case. (1.0.12)\r\n\r\nUncommenting the raw memory writes works fine.\r\n\r\nThe method sometimes doesn't crash, but I call it multiple times, with different values of a, b, c, d, and different pointers for baryCoords and out.\r\n\r\nMaybe I'm doing something wrong? Sorry if this is wasting your time.\r\n\r\n```c\r\n\r\nstruct V3f\r\n{\r\n\tuniform float x, y, z;\r\n};\r\n\r\nexport void ResolveBaryCoords(\r\n\tuniform int count,\r\n\tuniform reference V3f a, uniform reference V3f b, uniform reference V3f c, uniform reference V3f d,\r\n\treference uniform float baryCoords[],\r\n\treference uniform float out[]\r\n)\r\n{\r\n\tuniform int base4 = 0;\r\n\tuniform int base3 = 0;\r\n\tfloat va, vb, vc, vd;\r\n\r\n    for (int i = programIndex; i < count; i += programCount) \r\n    {\r\n\t\taos_to_soa4(baryCoords, base4, va, vb, vc, vd);\r\n\t\tfloat x = a.x * va + b.x * vb + c.x * vc + d.x * vd;\r\n\t\tfloat y = a.y * va + b.y * vb + c.y * vc + d.y * vd;\r\n\t\tfloat z = a.z * va + b.z * vb + c.z * vc + d.z * vd;\r\n//\t\tout[base3 + programIndex*3] = x;\r\n//\t\tout[base3 + programIndex*3 + 1] = y;\r\n//\t\tout[base3 + programIndex*3 + 2] = z;\r\n\t\tsoa_to_aos3(x, y, z, out, base3);\r\n\t\tbase4 += programCount*4;\r\n\t\tbase3 += programCount*3;\r\n\t}\r\n}\r\n```","assignee":null,"id":2356747,"labels":[],"number":122,"pull_request":{"patch_url":null,"html_url":null,"diff_url":null},"title":"soa_to_aos3 crash","closed_at":null,"html_url":"https://github.com/ispc/ispc/issues/122","url":"https://api.github.com/repos/ispc/ispc/issues/122","milestone":null},"action":"created","comment":{"created_at":"2011-12-05T13:43:24Z","updated_at":"2011-12-05T13:43:24Z","user":{"gravatar_id":"a56bb3ad4d8777f42df61738f528c05b","id":102567,"url":"https://api.github.com/users/mmp","login":"mmp","avatar_url":"https://secure.gravatar.com/avatar/a56bb3ad4d8777f42df61738f528c05b?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"body":"I've spent some time digging into this and haven't been able to reproduce it; I've also done a bunch of runs with the valgrind memory checker and haven't seen any errors from it when running this code.  (This has been on OSX).  Specifically, I've been using the above ispc code with the following test code.\r\n\r\n```\r\nint main() {\r\n    int count = 27;\r\n    float *baryCoords = new float[count*4];\r\n    memset(baryCoords, 0, 4*count*sizeof(float));\r\n    float *out = new float[count*4];\r\n    memset(out, 0, 3*count*sizeof(float));\r\n\r\n    ispc::V3f a, b, c, d;\r\n    ResolveBaryCoords(count, &a, &b, &c, &d, baryCoords, out);\r\n}\r\n```\r\n\r\nHowever, I'd very much like to get to the bottom of what's going on with the crash you're seeing.  (I will also re-review the aos/soa code implementations again to make sure everything looks good.)  If you can tell me the OS/platform you're using and if you can come up with a test case, I'd be happy to keep digging!\r\n","id":3017073,"url":"https://api.github.com/repos/ispc/ispc/issues/comments/3017073"}}