Table.insert crashes when passing NaN / Infinite position for value

table.insert will cause your client to hang forever if you call it when placing an element in an ‘infinite’ position.

image

Example code for reproduction:

  • table.insert({}, 0 / 0, 0)
  • table.insert({}, math.huge, 0)

I presume it hangs because it tries to create infinite nil valued indices? No reason anyone should be trying to pass infinite as a parameter to the position in the first place though.

12 Likes

This also happens for very large/small numbers:
table.insert({},2^31-1,0) is ok while table.insert({},2^31,0) isn’t.

Although they don’t hang forever, for me they hang for a very long period of time but certainly not forever.

I think the problem is that when casting a double (type of lua numbers) to an int values larger than 2^31-1 get wrapped around to -2^31, and then table.insert decides it has to shift up everything from #t to -2^31.

Is library functions taking a long time even a bug? The string pattern matching functions can take egregious amounts of time if you force them to backtrack a lot.

2 Likes

Thanks for the report. Please expect a delay in progress due to holidays and we will get back to you as soon as we return.

1 Like