I have a piece of code about 600 lines long which currently doesn't run due to seg fault. I have run gdb but it isn't relly helping me as I don't know what I am looking for. I have also run valgrind which I have been led to believe i more helpful, but I am working on a mac and valgrind doesn't really work on mac. I don't have a linux box and so can't run valgrind properly. Is there anyone willing to run my code through valgrind to find the issue, or are there websites that do this?? The reason I ask here is because I have found websites, but because I am using the gmp bignum library, the website just kicks back error about the library not being there because they don't have it.
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000008
0x000000010001ec2d in __gmpf_urandomb ()
(gdb) bt
#0 0x000000010001ec2d in __gmpf_urandomb ()
#1 0x0000000100002013 in main () at TammesA7.cc:60
(gdb) info frame
Stack level 0, frame at 0x7fff5fb61130:
rip = 0x10001ec2d in __gmpf_urandomb; saved rip 0x100002013
called by frame at 0x7fff5fbffb30
Arglist at 0x7fff5fb61128, args:
Locals at 0x7fff5fb61128, Previous frame's sp is 0x7fff5fb61130
Saved registers:
rbx at 0x7fff5fb61108, r12 at 0x7fff5fb61110, r14 at 0x7fff5fb61118, r15 at 0x7fff5fb61120, rip at 0x7fff5fb61128
But I have copied the code with mpg_urandomb() into another file and compiled and run that, so I think I am using it right (with regard initialising etc.) so not sure why it is having an issue in this program.
I can post the code if needed, but like I say it is long and messy.
Yes I do, it is in a loop to assign random numbers (not integers) to floats, but like I said, I tooks this loops and put it in another program and that one runs fine which makes me wonder why it does not in this one...
If that function is a part of the GMP library, it either means:
1. You are using it wrongly (sending the wrong arguments).
or
2. The library itself has a weak spot in its code.
Well I tried, and I can't get it to work. I'm sorry. All I can say is that your issue is in that urandomb function. Have you looked at the documentation of that function?
For completion, the issue was that the random number generator needs to be initialised. I had forgotten this having been using mpg_class for everything else which initialises for you.