|
Boost : |
From: Jens Maurer (Jens.Maurer_at_[hidden])
Date: 2005-07-21 17:18:13
John Maddock wrote:
> I've tracked down the cause of the random_test failures with some Win32
> compilers (Borland and Intel 8 and 9 certainly).
Thanks a lot.
> Within the test, the random number generator gets passed around by value
> when constructing a variate_generator.
Indeed, after all, random_test claims to be a test. :-)
> However there are a couple of
> generators that contain large arrays of long's (the mersenne twister is the
> first to be tested that has this problem).
sizeof(boost::mt19937) is 4996. Funny that this already causes problems.
> It's reasonably well known that
> on Windows, copying large arrays on the stack can overrun Window's stack
> protection and growth mechanism, resulting in the program trying to write to
> an invalid address.
[Linker flags for Borland and Intel omitted.]
> I'm not even sure if this is the right fix: should we really be passing such
> large arrays around on the stack in the first place?
Frankly, I'm completely puzzled that apparently relatively modern
Windows versions can't handle medium-sized (5 KB) stack allocations.
After all, the wonders of modern MMUs enable operating systems to handle
similar tasks such as demand-paging just fine. And Unix-style operating
systems do handle arbitrary stack growth just fine.
Looks like the only option is to allocate the data area on the heap.
Which increases the overhead for creating and destroying a mersenne_twister
quite a lot.
Jens Maurer
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk