You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 8, 2024. It is now read-only.
In case it helps:
At the first call of the method setDataAsync the size = 0, previousSize = 0, newSize = 223
At the second call of the method the size = 223, previousSize = 27986, newSize = 223, as a result it gets to:
size -= previousSize - newSize
And because size is a UInt iVar, it crashes.
So, the previous size was much larger than the new size and in the same time the size iVar is not big enough for the subtracting operation. Not sure why is the previous size that big if the first call of the method determines an initial change in size of 223.
And the ExpensiveObject extension is specified like this:
extension NSDate: ExpensiveObject { public var cost: Int { return 1 } }
Maybe I'm doing something wrong with the cost [I was not sure what is the correct way to determine it's cost, so I just assumed we can reduce it to TimInterval cost which is a Double], but even in this case, I guess the library should be crash free and in this kind of situations just return an error or fail silently with an error log.
Also please note that my tests set the value for exactly the same key 3 times consequently.
The text was updated successfully, but these errors were encountered:
Hi @Carpemeid, thanks for the very detailed description of the issue you're encountering!
To be honest, I have little time to investigate this in the short term, but I'll try to have a look as soon as I can and I'll come back to you with my findings!
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
For some reasons only in my tests, the framework fails in the DiskCacheLevel.swift method setDataAsync.
The crash seems to be caused by the assignment of a negative value to the iVar size which is an UInt.
We are specifically talking about this part of the code
In case it helps:
At the first call of the method setDataAsync the size = 0, previousSize = 0, newSize = 223
At the second call of the method the size = 223, previousSize = 27986, newSize = 223, as a result it gets to:
size -= previousSize - newSize
And because size is a UInt iVar, it crashes.
So, the previous size was much larger than the new size and in the same time the size iVar is not big enough for the subtracting operation. Not sure why is the previous size that big if the first call of the method determines an initial change in size of 223.
More details:
The cache I am using is as follows:
MemoryCacheLevel<URL, NSDate>().compose(DiskCacheLevel<URL, NSDate>().pooled())
And the ExpensiveObject extension is specified like this:
extension NSDate: ExpensiveObject { public var cost: Int { return 1 } }
Maybe I'm doing something wrong with the cost [I was not sure what is the correct way to determine it's cost, so I just assumed we can reduce it to TimInterval cost which is a Double], but even in this case, I guess the library should be crash free and in this kind of situations just return an error or fail silently with an error log.
Also please note that my tests set the value for exactly the same key 3 times consequently.
The text was updated successfully, but these errors were encountered: