V5 beta fail to serialize double on ARM CPU
See original GitHub issueHi, I observe the following error in logs of my app:
System.DataMisalignedException: A datatype misalignment was detected in a load or store instruction.
at LiteDB.BufferExtensions.ToBytes(Double value, Byte[] array, Int32 startIndex)
at LiteDB.Engine.BufferWriter.WriteNumber[T](T value, Action`3 toBytes, Int32 size)
at LiteDB.Engine.BufferWriter.Write(Double value)
at LiteDB.Engine.BufferWriter.WriteElement(String key, BsonValue value)
at LiteDB.Engine.BufferWriter.WriteDocument(BsonDocument value, Boolean recalc)
at LiteDB.Engine.DataService.Insert(BsonDocument doc)
at LiteDB.Engine.LiteEngine.InsertDocument(Snapshot snapshot, BsonDocument doc, BsonAutoId autoId, IndexService indexer, DataService data)
at LiteDB.Engine.LiteEngine.<>c__DisplayClass8_0.<Insert>b__0(TransactionService transaction)
at LiteDB.Engine.LiteEngine.AutoTransaction[T](Func`2 fn)
at LiteDB.Engine.LiteEngine.Insert(String collection, IEnumerable`1 docs, BsonAutoId autoId)
at LiteDB.LiteCollection`1.Insert(T document)
It happens everytime on types with non default double values. Here’s the definition of the type:
public class Checkpoint : ICheckpoint
{
private static long nextSequence;
public DateTime Timestamp { get; set; } = new DateTime(0, DateTimeKind.Utc);
public string RiderId { get; set; }
public long Id { get; set; }
public DateTime LastSeen { get; set; } = new DateTime(0, DateTimeKind.Utc);
public int Count { get; set; } = 1;
public bool Aggregated { get; set; }
public bool IsManual { get; set; }
public double Rps { get; set; }
public Checkpoint()
{
}
public Checkpoint(string riderId, DateTime? timestamp = null)
{
Id = Interlocked.Increment(ref nextSequence);
RiderId = riderId;
LastSeen = Timestamp = timestamp ?? new DateTime(0, DateTimeKind.Utc);
}
public override string ToString()
{
return $"{RiderId} Ts:{Timestamp:t}";
}
private sealed class TimestampRelationalComparer : IComparer<Checkpoint>
{
public int Compare(Checkpoint x, Checkpoint y)
{
if (ReferenceEquals(x, y)) return 0;
if (ReferenceEquals(null, y)) return 1;
if (ReferenceEquals(null, x)) return -1;
return x.Timestamp.CompareTo(y.Timestamp);
}
}
public static IComparer<Checkpoint> TimestampComparer { get; } = new TimestampRelationalComparer();
}
If the Rps value is zero, the object would serialize and deserialize without problems. Unfortunately, I can’t create a minimal reproduction yet. A simple to save and load one item is not failing. So probably particular value makes the difference
Issue Analytics
- State:
- Created 4 years ago
- Comments:10
Top Results From Across the Web
Cannot install expo-cli global (windows 10) · Issue #650
Description I can't install expo-cli npm 6.9.0, node v12.3.1 (also tried stable 10.15.3 got same result) Expected Behavior npm install ...
Read more >Bug listing with status RESOLVED with resolution OBSOLETE ...
... window flash, 100% CPU" status:RESOLVED resolution:OBSOLETE severity:normal ... Bug:266479 - "Python-2.6 failed to crosscompile on arm" status:RESOLVED ...
Read more >TensorRT Release Notes
This release incorporates Arm® -based CPU cores for Server Base System ... The TensorRT engine might fail to build under QAT mode if...
Read more >Unreal Engine 5.2 Release Notes
Fixed cases where bCooked could get mistakenly unset when serializing a Class during reference collection in cooked versions of the Editor. Fixed an...
Read more >DataStax Python Driver - CHANGELOG
Insights fail to serialize the startup message when the SSL Context is from ... Fix error when preparing queries with beta protocol v5...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi, confirm, that build from latest master has fixed the bug. Thanks!
I had the same issue on an old raspberry pi. I compiled the source from master and linked that to my project. Upgrade of an 188MB databse went fine and app is running again. So it seems the issue is indeed closed. Thanks for the fix.