Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LST discards duplicate symbols in import, invalidating SIDs #644

Closed
zslayton opened this issue Nov 19, 2020 · 0 comments · Fixed by #651
Closed

LST discards duplicate symbols in import, invalidating SIDs #644

zslayton opened this issue Nov 19, 2020 · 0 comments · Fixed by #651
Labels

Comments

@zslayton
Copy link
Contributor

When ion-js reads binary Ion data that includes a local symbol table, it checks to see whether each string being added to the table is already present. If it is, it skips that string. The symbol is not added and the number of entries in the symbol table no longer aligns with the table that was used to encode the data. This behavior is incorrect and causes Errors to be thrown when reading Ion written by libraries other than ion-js.

For example, this Ion text:

{
  files: [
    {name: "img1", format: "JPG", bytes: 552},
    {name: "img2", format: "PNG", bytes: 716},
    {name: "img3", format: "GIF", bytes: 1091},
    {name: "notes", format: "TXT", bytes: 480},
  ]
}

contains the symbols files, name, format, and bytes.

A writer encoding that data into binary might (unwisely) choose to add name to the symbol table again even though it's already in the system symbol table as SID $4, creating a new SID $11.

Ignoring the duplicate symbol means that every starting at SID $11 will map to incorrect text or to no text at all, leading to corrupted data and exceptions like the following:

Error: Symbol $20 greater than maxID.
    at BinaryReader.getSymbolString (src/IonBinaryReader.ts:249:23)
    at BinaryReader.fieldName (src/IonBinaryReader.ts:128:21)
    at _loadStruct (src/dom/index.ts:118:29)
    at _loadValue (src/dom/index.ts:108:38)
    at Object.load (src/dom/index.ts:68:44)
@zslayton zslayton added the bug label Nov 19, 2020
@zslayton zslayton changed the title LST discards duplicate symbols on imports, invalidating SIDs LST discards duplicate symbols in import, invalidating SIDs Nov 19, 2020
zslayton added a commit that referenced this issue Nov 24, 2020
* LSTs no longer use Objects with default properties to index symbols (Issue #649)
* LSTs no longer discard duplicate symbols during init (Issue #644)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant