lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 7/29/2014 4:58 PM, Roberto Ierusalimschy wrote:
So, I guess that the best solution for this would be for the Lua API to
receive an external random seed as argument to lua_newstate, and let the
embedder decide whether to provide an actual random data or not. And of
course, the standard interpreter would have to have an option to expose
this if so desired.

We have considered that. However, fixing the seed does not eliminate the
problem, only ameliorate it. "Non-conventional" keys (such as tables
and functions) use the object address as the key, so ASLR makes those
keys non deterministic, independently of any seed. (In particular,
this problem was already present in Lua well before 5.2.) The fact
that, without random seeds, traversals for tables with no object keys
are deterministic should be seen as an implementation detail. The
clean approach is not to count on it. (You may sort your data, as Alex
suggested.)

Indeed sorting is a solution, but when we made the switch to 5.2 in luatex it took quite a while before I got it catched in all places where consistent order of keys matters (at least stable / consistent for specific compiled versions of the program embedding Lua; it's less important across versions). It's a nice example of a change that looks harmless but can lead to surprises. (We do a lot of hashing and caching and when saving intermediate data for successive runs one needs to keep it in mind.).

It makes me wonder what surprises we run into with the new number implementation. At first sight it looks harmless, but one could as well argue for pretty long testing periods to make sure that it has no (interesting) side effects.

Anyway, progress is ok.

Hans


-----------------------------------------------------------------
                                          Hans Hagen | PRAGMA ADE
              Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
    tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                             | www.pragma-pod.nl
-----------------------------------------------------------------