Revision: 54048
          http://brlcad.svn.sourceforge.net/brlcad/?rev=54048&view=rev
Author:   brlcad
Date:     2012-12-11 23:04:58 +0000 (Tue, 11 Dec 2012)
Log Message:
-----------
ran into an rt crash when I enabled randmt on a highly-parallel system.  the 
global_state static was uninitialized leading to the conclusion that we either 
have a memory corruption issue or, more likely, a problem with initialization 
order.  c++ guarantees the order will be in the order declared, but I can't 
find any reference of that guarantee for C.  Still, the intermediate variable 
seems unnecessary since we can just get rid of the pointer.

Modified Paths:
--------------
    brlcad/trunk/NEWS
    brlcad/trunk/src/libbn/randmt.c

Modified: brlcad/trunk/NEWS
===================================================================
--- brlcad/trunk/NEWS   2012-12-11 22:33:42 UTC (rev 54047)
+++ brlcad/trunk/NEWS   2012-12-11 23:04:58 UTC (rev 54048)
@@ -13,6 +13,7 @@
 --- 2012-07-XX  Release 7.22.2                                     ---
 ----------------------------------------------------------------------
 
+* fixed random number SMP bug affecting rt and adrt - Sean Morrison
 * added support for editing 2D sketch objects in archer - Bob Parker
 * fixed File->New deprecation error in archer - Sean Morrison
 * improved Linux platform application and file icons - Jordi Sayol

Modified: brlcad/trunk/src/libbn/randmt.c
===================================================================
--- brlcad/trunk/src/libbn/randmt.c     2012-12-11 22:33:42 UTC (rev 54047)
+++ brlcad/trunk/src/libbn/randmt.c     2012-12-11 23:04:58 UTC (rev 54048)
@@ -52,13 +52,13 @@
 
 #define MERSENNE_MAGIC 0x4D54524E
 
-static struct _internal_state_s {
+struct _internal_state_s {
     uint32_t magic;
     int mti;           /* state index */
     uint32_t mt[N];    /* state vector */
-} global_state_static = { MERSENNE_MAGIC, N+1, {0} };
+};
 
-static struct _internal_state_s *global_state = &global_state_static;
+static struct _internal_state_s global_state = { MERSENNE_MAGIC, N+1, {0} };
 
 void *
 bn_randmt_state_create()
@@ -144,12 +144,12 @@
 void
 bn_randmt_seed(unsigned long seed)
 {
-    bn_randmt_state_seed(global_state, (uint32_t)seed);
+    bn_randmt_state_seed(&global_state, (uint32_t)seed);
 }
 
 double bn_randmt()
 {
-    return bn_randmt_state(global_state);
+    return bn_randmt_state(&global_state);
 }
 
 /*

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to