0

I am on binary search in pset3 find. As noted here, I get an crash when I try to run it through a pipe to generate with more than 580 numbers to generate with seed of 50. So command (note that it is running on my home computer with elementary OS Freya beta 2 and not the appliance):

pythonhax@pythonhax-eOS: ~/Dropbox/CS50x/pset3/find$ ./generate 580 50 | ./find 127

haystack[0] = 
haystack[1] =
haystack[2] = 
.
.
.
haystack[579] = 
haystack[580] =

Found needle in haystack!

pythonhax@pythonhax-eOS: ~/Dropbox/CS50x/pset3/find$ ./generate 581 50 | ./find 127

haystack[0] = 
haystack[1] =
haystack[2] = 
.
.
.
haystack[580] = 
haystack[581] =
Segmentation fault (core dumped)
pythonhax@pythonhax-eOS: ~/Dropbox/CS50x/pset3/find$

Any way I can run GDB on this so I don't have to supply 581 numbers?

1

I answered on your reddit post but I'll post it here too:

Run generate and send it to a text file, then run find under gdb using the text file as input

./generate 581 50 > 581nums.txt
gdb ./find
(gdb) run 127 < 581nums.txt

If that works without crashing, then you know it's not your code but something on your system that is causing the crash.

| improve this answer | |

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .