1. Have you tried running your code on a smaller dataset? Does it work, or does it give you a stack overflow as well?
2. What stack size are you using? As copeg suggested, try changing the stack...