Repository navigation
Check in unit tests that live Lua code uses no erased generic static - #1500
Merged
Merged
Conversation
After the Lua generics phase and the tree shaker, a function which is live through allocated classes must not read or write a generic static through its erased original once the static has specialised copies: one instantiation would then have two stores (#1498). The check runs in unit-test mode only, before the garbage removal hides the split as a dropped write, and uses RemoveGarbage's allocation-based reachability so dead dispatch kept by the tree shaker is not reported.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #1498.
What
After the Lua generics phase and the tree shaker (
transformProgToLua), a function that is live through allocated classes must not read or write a generic static through its erased original once that static has specialised copies. If it does, one instantiation has two backing stores, and one is written where the other is read: the #1498 miscompile.ImTranslator.assertNoLiveErasedGenericStatic()asserts this in unit-test mode only, likeassertFlatandassertNoGarbage. It reports a violation as an internalCompileErrornaming the function and the static.TreeShaker.removeUnreachableFunctions. Later, the garbage removal deletes the write-only erased store, so the split shows up only as a dropped write, and a check at that point catches fewer cases.RemoveGarbage.reachableFunctions(allocation-based, same style asreachableMethods). Tree-shaker presence would report dead dispatch, for example the erasedBox_readintupleSpecializedInterfaceDispatchDoesNotRootErasedStaticInitializer.transformProgToLuatime overall. Builds outside unit tests skip it.Evidence
LuaBackendAuditTests.liveErasedGenericStaticFailsTheUnitTestCheck: it adds a read of the erased static tomainand expects the error. It fails without the hook.EliminateGenericsfix reverted to its previous version, all 26 failingGenericStore*tests stop at compile time with this error (Store_put/Store_read/Store_add/Store_poponStore_values) instead of producing wrong output.