Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ Programming ➜ General ➜ Crash in initstate_r()

Crash in initstate_r()

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Zeno   USA  (2,871 posts)  Bio
Date Sat 28 Jan 2006 01:08 AM (UTC)

Amended on Thu 25 Nov 2010 05:29 PM (UTC) by Zeno

Message
I'm trying to run the Phantasia4 source:
http://www.phantasia4.com/download.html (down)
Can be played here: http://www.phantasia4.org

It compiled fine, but when I try to run it, it crashes. Under gdb, it seems to crash in /lib/libc.so.6 in the function initstate_r() which is not part of the source. Anyone know why it's crashing?

In the source, this is the line that calls initstate_r:
   /* seed the random number generator */
    initstate_r (time(NULL), (char *)&randomStateBuffer, STATELEN,
       (struct random_data *)&randData);

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #1 on Sat 28 Jan 2006 01:19 AM (UTC)
Message
See: http://lists.debian.org/debian-glibc/2006/01/msg00037.html

Are you compiling with gcc 4.1? That could be it. I don't know anything else about this, I just googled for initstate_r and found that...

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #2 on Sat 28 Jan 2006 01:34 AM (UTC)
Message
I saw that. But no, I'm using gcc 3.3.6.

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #3 on Thu 02 Feb 2006 01:47 AM (UTC)
Message
Never really figured it out. I ended up using initstate() instead of initstate_r(), as well as srandom() etc. It's running now, but I don't know what effects those changes may have.

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #4 on Thu 02 Feb 2006 01:56 AM (UTC)
Message
Quote:
The initstate_r function behaves exactly like the initstate function except that it uses and modifies the state in the object pointed to by the fourth parameter instead of the global state.
What that means is that initstate_r is re-entrant, and can be used, for example, in multithreaded applications.

I suspect that multiple simultaneous calls to initstate would cause havoc, since the function apparently uses a single global buffer for its data.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

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.


14,492 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.