p4r@zeno:~$ gcc -o test test.c
p4r@zeno:~$ gdb test
GNU gdb 6.3
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i486-slackware-linux"...Using host libthread_db library "/lib/libthread_db.so.1".
(gdb) run
Starting program: /home/p4r/test
Program received signal SIGSEGV, Segmentation fault.
0x40052c33 in initstate_r () from /lib/libc.so.6
(gdb) bt
#0 0x40052c33 in initstate_r () from /lib/libc.so.6
#1 0x080483f8 in main ()
(gdb)
I'm on Slackware 10.2.0
Old yeah, but I've tried upgrading libc and it didn't fix this crash.
Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
(gdb) run
Starting program: /home/p4r/a.out
Program received signal SIGSEGV, Segmentation fault.
0x40052c33 in initstate_r () from /lib/libc.so.6
(gdb) bt
#0 0x40052c33 in initstate_r () from /lib/libc.so.6
#1 0x080483f8 in main ()
Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Amended on Sun 26 Jun 2011 08:21 PM (UTC) by Twisol
Message
randomStateBuffer is already a char*, so using & on it results in char**. I know that was mentioned in an answer on SO, but it should definitely be changed.
I'm pretty sure you don't need the (struct random_data*) cast either, because it already is a (struct random_data*) after you use &. Not something that would make things break though.
I honestly don't see anything else that would make it crash. A post on a mailing list [1] suggests that, oddly enough, you need to do this before calling initstate_r():
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.