https://bugs.winehq.org/show_bug.cgi?id=46273
Bug ID: 46273 Summary: rand() doesn't get a unique state per-fiber like it appears to on native windows Product: Wine Version: 1.8.7 Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: winecrt0 Assignee: wine-bugs@winehq.org Reporter: winebz@pengaru.com Distribution: ---
I've been using WINE to test windows builds during game development in Debian GNU/Linux.
I use the windows fibers API to implement coroutines and in testing on Win7 noticed a bunch of coroutine-backed game objects using rand() for randomized visible things were unexpectedly looking uniform. In WINE they had all appeared distinctly random.
I'm not an experienced windows developer, but it /appears/ that in Win7, calling rand() in a newly created fiber restarts from the default seed rather than sharing the same PRNG state with the other fibers. It's rather odd, but I verified it with a smaller test program that only printed the return value from rand() in new fibers, and they were all printing the same value.
It's possible this is already fixed in a newer WINE version, I'm limited to what's bundled in debian 9.5 (1.8.7). Or maybe this is considered a Windows bug and WINE's behavior is deliberately different.
https://bugs.winehq.org/show_bug.cgi?id=46273
--- Comment #1 from Austin English austinenglish@gmail.com --- As I'm sure you realize, 1.8.x is very outdated (we're already in the 4.0 release process). If you could test from a newer debian repo (i.e., testing/unstable) that would be helpful.
In any case, could you attach the test source/binary?
https://bugs.winehq.org/show_bug.cgi?id=46273
--- Comment #2 from winebz@pengaru.com --- Created attachment 62984 --> https://bugs.winehq.org/attachment.cgi?id=62984 rand() from fibers test program
This program creates 100 fibers and waits for their exit.
The fibers all execute the same function, in pseudo-code: { print(rand()) sleep_schedule_others(1s) print(rand()) }
In WINE 1.8.7, I observe all the fibers printing random numbers.
In Win7, I observe 100 of the same random number, a delay, then 100 of another uniform random number.
https://bugs.winehq.org/show_bug.cgi?id=46273
joaopa jeremielapuree@yahoo.fr changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |jeremielapuree@yahoo.fr
--- Comment #3 from joaopa jeremielapuree@yahoo.fr --- As already said, what is the purpose to test wit such an old version of wine? Test with wine-4.0-rc1.
https://bugs.winehq.org/show_bug.cgi?id=46273
Nikolay Sivov bunglehead@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Ever confirmed|0 |1
--- Comment #4 from Nikolay Sivov bunglehead@gmail.com --- (In reply to joaopa from comment #3)
As already said, what is the purpose to test wit such an old version of wine? Test with wine-4.0-rc1.
And now you can try it yourself with attached test program.
(In reply to winebz from comment #2)
Created attachment 62984 [details] rand() from fibers test program
This program creates 100 fibers and waits for their exit.
The fibers all execute the same function, in pseudo-code: { print(rand()) sleep_schedule_others(1s) print(rand()) }
In WINE 1.8.7, I observe all the fibers printing random numbers.
In Win7, I observe 100 of the same random number, a delay, then 100 of another uniform random number.
Yes, I can confirm.
https://bugs.winehq.org/show_bug.cgi?id=46273
--- Comment #5 from winebz@pengaru.com --- If it's of any use, I've made the source available via giet in a semi-convenient to build form (autotools):
`git clone git://git.pengaru.com/randtest`
See the README for instructions on building with mingw. Please note there are submodules requiring a recursive init for the fibers support, as explained in the README.
I only wanted to document the apparent difference from genuine Windows in filing this bug. For my purposes I've switched to different PRNG, it's not important to fix from my perspective.
It might make the most sense to simply document the bug.
https://bugs.winehq.org/show_bug.cgi?id=46273
Austin English austinenglish@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords| |download, source, testcase
https://bugs.winehq.org/show_bug.cgi?id=46273
Austin English austinenglish@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Distribution|--- |Debian