beyond-all-reason / beyond-all-reason/RecoilEngine

Investigate userdata safety in synced

Open
#2,344 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
679
Forks
290
Avg merge
3d 2h
Merged PRs (30d)
40

Description

AFAIK userdata types were/are 100% forbidden in synced luarules. I assume this is because of desync, but I don't remember this being said explicitly anywhere.

Userdata allows neat interfaces so it would be good to investigate how dangerous they really are. Test some obvious scenarios:
* what if you do `table[userdata] = bla`, and then `table.sort` or `for ... in pairs`? Is the order deterministic?
* can you get some sort of nondeterministic, address-based value from a userdata via things like `string.format` or `tostring`?
* what about more esoteric things like GC hooks, metamethods, cleanup time/order when used as a key in a table set to use weak keys, or interactions with weird interfaces like the lua registry or Recoil cross-env calls (`SYNCED.bla`, `local userdata_from_luaui = Script.LuaUI.Bla`, etc)?

#2343 adds userdata to synced, so it's a good testbed. (It's fine to merge 2343 even if this investigation isn't done, gamedevs will just have to remember not to do anything stupid with the interface.)

Contributor guide

Open the contributing guide

Research direction

Use #2343's synced userdata support as the testbed and exercise the listed table, formatting, GC, metamethod, weak-key, registry, and Recoil cross-environment scenarios. Record whether each behavior is deterministic and safe for synced luarules, then document the resulting constraints for gamedevs.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, lua
Domain
game-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.