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

HIBONJSON: Converting timestamp leads to crashes on some platforms #406

Open
lucasnethaj opened this issue Feb 12, 2024 · 0 comments
Open
Labels
defect Something isn't working good first issue Good for newcomers

Comments

@lucasnethaj
Copy link
Member

lucasnethaj commented Feb 12, 2024

The std library implementation of toISOExtString() does not include the timezone when it is in LocalTime.
Which is annoying for us because hibon-json needs the timezone in order to be hash invariant across time zones.
Currently we use a hack where we wrap the class with a class called DefinitelyNotLocalTime
However this seems to lead to crashes on some platforms when called repeatedly (specifically iOS)

The simple solution would be to just implement the toISOExtString() function without the extra timezone checks. And then of course remove the hack class

@lucasnethaj lucasnethaj added defect Something isn't working good first issue Good for newcomers labels Feb 12, 2024
lucasnethaj added a commit that referenced this issue Feb 12, 2024
Review week 06
# Changelog for Epoch 720414 .. 793069

**Tagionshell automatic test**
We have implemented a automatic test on the shell for the acceptance stage. Until now we have only had automatic tests on the shell when running the longitudinal tests, so this makes it easier for us to catch errors quicker. The test also utilizes our new trt-read update process.

**Contract Tracing proposal**
We have created a proposal for how the tracing of contracts should be implemented. See [docs.tagion.org](https://docs.tagion.org/#/documents/TIPs/contract_tracing_proposal_18_feb) for further information.

**HiBONJSON timestamp formatting**
We use a function from D's standard library for converting from hibon's time format sdt time which is represented as a 64-bit integer and the ISO8601 text format. Which looks like this `2024-02-12T11:15:37+07:00`.
The problem is that the timezone can be ommited like this `2024-02-12T11:15:37` and the timezone would then be assumeed to be the local time.
This is the default behavior for the library function which means that the timezone would never be included in HIBONJSON. 
Which meant that a hibon including a timestamp. When converted to json and sent to another timezone and coverted back to hibon
would no longer be the same timestamp and of course no longer the same hash.
We have made a temporary solution for this, but it seems to cause issues on some platforms see #406

In the process we also found a bug in the function that converts from the text format to the binary format 'fromISOExtString()`.
Which would not correctly subtract the time offset in non hourly timezones like Indias IST(UTC +5:30) or Canadas NST(UTC -2:30).
Which we did not even know existed.
This means for now that the standard hibonjson implementation does not allow converting from a string timestamp with an un hourly timeoffset.
@lucasnethaj lucasnethaj mentioned this issue Jun 3, 2024
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
defect Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant