lua-users home
lua-l archive

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




在 2020年3月12日,23:58,Coda Highland <chighland@gmail.com> 写道:




On Thu, Mar 12, 2020 at 10:14 AM 云风 <cloudwu@gmail.com> wrote:


> 在 2020年3月12日,22:39,Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br> 写道:
>
> 
>>
>> Is there any way to specify a seed when I create a new lua VM ? It's
>> very useful for reproduction of bugs .
>> If the seed is always random, the order of table iteration would be
>> different every time.
>

There is another reason that I want to set the seed by myself.

Our system use thousands lua VMs in one process. I make a small patch to share the function protos (including strings) among these VMs. So I need these VMs use the same seed, so that the strings’ hash can be  used in any of these VM.

If you're already patching the VM, it shouldn't be hard to just patch the seed assignment yourself.



I don’t want to change the lua api , and my patch doesn’t change the any lua api but only the implementation.

And We can’t change(assign) the seed after lua_newstate . So I can only use a global seed, it’s ugly.