View Issue Details

IDProjectCategoryView StatusLast Update
0002957FSSCPmultiplayerpublic2013-11-20 06:43
Reporterchief1983 Assigned Tochief1983  
PrioritynormalSeveritycrashReproducibilityhave not tried
Status resolvedResolutionfixed 
Platformx86-64OSFreeBSDOS Version9.2
Product Version3.7.1 
Target Version3.7.2 
Summary0002957: *nix Standalone crash on assertion failure
DescriptionBeam couldn't find a good object model/type!! (0)
Beam couldn't find a good object model/type!! (0)
vm_forward_interpolate: Bad rotation
vm_forward_interpolate: Bad rotation
ASSERTION: "RAND_MAX == 0x7fffffff" at systemvars.cpp:123
Steps To ReproduceHad two Windows 7 clients connected to the WebUI standalone on my FreeBSD machine, running r10121, playing Aeolus Duel, when a couple minutes in, the standalone server crashed out with the assertion above.
Additional InformationI'm guessing RAND_MAX isn't 0x7fffffff or 0x7fff on this particular platform. The rand32 function probably needs to be expanded to be more flexible, like maybe supporting any number of bits between 16 and 32, or possibly a RAND_MAX higher than 32 bits. Not sure what the case was here when it crashed, other than it broke.
TagsNo tags attached.

Activities

chief1983

2013-11-19 19:59

administrator   ~0015425

From the /usr/include/stdlib.h on FreeBSD 9.2:
#define RAND_MAX 0x7ffffffd

rand32() assumes it is either 0x7fff (MSVC, etc) and goes one way, or Asserts that it is 0x7fffffff, which it is not quite on FreeBSD, leading to a debug build crash when rand32 is called. Surprised it took me a few minutes of playing to crash, must not be called except in certain situations.

So it looks like rand32 could use a slight overhaul, maybe to at least make sure that if RAND_MAX is not 0x7fffffff, that we try to make a 32bit random number out of however many bits we do have.

chief1983

2013-11-19 20:35

administrator   ~0015426

Last edited: 2013-11-19 20:38

More info on the FreeBSD RAND_MAX change found via http://freebsd.1045724.n5.nabble.com/RAND-MAX-issue-td5839987.html

Maybe consider upgrading to the Mersenne Twister http://www.bedaux.net/mtrand/

chief1983

2013-11-19 23:05

administrator   ~0015428

This issue was created by 0001823. Assert(RAND_MAX >= 0x7ffffffd); would probably handle this, and let us catch any with a RAND_MAX between MSVC and FreeBSD in the future.

chief1983

2013-11-20 06:43

administrator   ~0015432

Fix committed to trunk@10129.

Related Changesets

fs2open: trunk r10129

2013-11-20 02:11

chief1983


Ported: N/A

Details Diff
Fix 0002957 - FreeBSD RAND_MAX is 0x7ffffffd, not 0x7fffffff, so we can't always assume that it's the latter. Also move the check earlier in the code, if it's going to break at all, break immediately on any non-conforming platform so we can fine tune this some more. Affected Issues
0002957
mod - /trunk/fs2_open/code/freespace2/freespace.cpp Diff File
mod - /trunk/fs2_open/code/globalincs/systemvars.cpp Diff File

Issue History

Date Modified Username Field Change
2013-11-19 06:23 chief1983 New Issue
2013-11-19 19:59 chief1983 Note Added: 0015425
2013-11-19 20:35 chief1983 Note Added: 0015426
2013-11-19 20:38 chief1983 Note Edited: 0015426
2013-11-19 22:52 chief1983 Assigned To => karajorma
2013-11-19 22:52 chief1983 Status new => assigned
2013-11-19 23:05 chief1983 Note Added: 0015428
2013-11-19 23:28 chief1983 Assigned To karajorma => chief1983
2013-11-20 06:43 chief1983 Changeset attached => fs2open trunk r10129
2013-11-20 06:43 chief1983 Note Added: 0015432
2013-11-20 06:43 chief1983 Status assigned => resolved
2013-11-20 06:43 chief1983 Resolution open => fixed