Segfault caused when indexing a 2D array with an index within the dimensions calculated by extent

29 views
Skip to first unread message

hamzeh alsalhi

unread,
Jul 10, 2014, 3:35:06 PM7/10/14
to haskel...@googlegroups.com
I have a 20 by 20 array called img. I noticed it is causing the segfaults in my (fairly lengthy) haskell program at run-time. Firstly, I can call extent on this array with no problem and I get back a shape of 20 by 20. However if I index img with any index in the range 0-19 on both axis I get a segfault. It is a delayed array of unboxed doubles and I also get a segfault if I try to run computeUnboxedS or sumAllS or traverse on the array img.

It is also worth mentioning img is an array I get by slicing a 4D array using 'All' on two of the axis and specific indicies on the other two axes. I have removed all behavior based random on random number generation from the program and the segfault still shows up at different times every time the program is rerun. Removing the offending operations on the array confirms that it is certainly the array causing the segfaults and the program runs for a long time with no sign of any segfault.

hamzeh alsalhi

unread,
Jul 12, 2014, 10:50:15 AM7/12/14
to haskel...@googlegroups.com
I Figured out my issue! I was off by one on my slicing operation. I was doing 1..Dim when I should have been doing (1..Dim)-1. This is a common enough mistake I should have been able to catch on my own but I suppose it took me longer because I was faced with an ambiguous segfault that did not give me any information to locate the erroneous code.
Reply all
Reply to author
Forward
0 new messages