Description
A stale child symbol table can replace a newer, larger root symbol table when parsers are closed out of creation order.
For example, if one parser is created and reads one field name, and another parser created from the same JsonFactory reads additional field names and closes first, the root symbol table is updated with the larger child table. When the older parser closes later, however, its smaller child table can replace the newer root table.
As a result, the shared symbol table can lose symbols learned by a newer parser.
Reproduction
The issue applies to both byte-backed and char-backed parsers:
- Create parser A from a shared
JsonFactory.
- Read one field name with parser A.
- Create parser B from the same factory.
- Read additional field names with parser B.
- Close parser B.
- Close parser A.
After parser B closes, the root symbol table contains the larger symbol set. After parser A closes, the root table can regress to parser A's stale, smaller child table.
Expected behavior
An older child symbol table should not replace a newer, larger root table produced by another child.
Actual behavior
The older child can merge after the newer child and replace the root table with its stale state.
Notes
This affects both CharsToNameCanonicalizer and ByteQuadsCanonicalizer.
This is separate from the intentional reset behavior for oversized symbol tables. The issue here is specifically an older child state replacing a newer root state during out-of-order parser release.
Description
A stale child symbol table can replace a newer, larger root symbol table when parsers are closed out of creation order.
For example, if one parser is created and reads one field name, and another parser created from the same
JsonFactoryreads additional field names and closes first, the root symbol table is updated with the larger child table. When the older parser closes later, however, its smaller child table can replace the newer root table.As a result, the shared symbol table can lose symbols learned by a newer parser.
Reproduction
The issue applies to both byte-backed and char-backed parsers:
JsonFactory.After parser B closes, the root symbol table contains the larger symbol set. After parser A closes, the root table can regress to parser A's stale, smaller child table.
Expected behavior
An older child symbol table should not replace a newer, larger root table produced by another child.
Actual behavior
The older child can merge after the newer child and replace the root table with its stale state.
Notes
This affects both
CharsToNameCanonicalizerandByteQuadsCanonicalizer.This is separate from the intentional reset behavior for oversized symbol tables. The issue here is specifically an older child state replacing a newer root state during out-of-order parser release.