torch/torch7 — pull request #48 by timharley (2014-06-23 18:29:29+00:00)
Title: Fix a bug in getRNGState/setRNGState

The `next` field of the THGenerator struct was not serialized correctly. This caused aliasing problems if using multiple THGenerator objects, and worse, caused segfaults when serializing RNGState to file then using from a second process.

The first commit introduces a failing test. The second commit fixes the bug and makes the test pass. I have verified that this fixes the serialization fault above, but it is not possible to add a simple test for this case as it requires two processes.

An alternative to this patch would be to make the `next` field an array index rather than a direct pointer, as it is used only for looping over the `state` member array. Would this be preferable?