-
-
Notifications
You must be signed in to change notification settings - Fork 6k
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
ChartUtils Crash on 32 Bit Devices #1737
Comments
Check that i is valid after rounding to prevent a crash.
need more info - why it is NaN in the first place? |
Problem is I have no 32bit device to test on. I don't see why would the value end up being |
It happens when the chart creates its default formatter. It was a huge number though, which might be an issue in itself. I can check next time have access to a 32 Bit device (later in the week). |
i run on iPad4 NSMutableArray *dataSets = [[NSMutableArray alloc] init]; Then , the var magnitude in fun roundToNextSignificant would be 0 , so i will be NaN. |
would you post more vars that lead magnitude to be 0? We don't know what your data entries are. And not giving enough info |
i reproduce this crash in ChartsDemo by del one line in fun setDataCount of LineChart1ViewController.m .
then , the var pw Int -308 would lead magnitude to be 0 on iPad4. |
I just encountered this crash today, in Charts 3, on an 9.2.1 iPhone 4S device, when ChartData contains an empty DataSet. ChartViewBase.data setter: Because ChartData's DataSet is empty, its
Back in ChartUtils.decimals Interestingly, on a 9.3.5 iPhone 5s device (64-bit) and the Xcode 8.1 iPhone 4S (9.2) simulator, pow() with the same inputs returns a different result: But ChartUtils.decimals' 'if i.isInfinite' saves the day. Unfortunately, I don't have a 32-bit device running iOS 10 to see how pow() behaves here. As a hacky workaround, I found that adding a dummy DataEntry(x:0, y:0) to the DataSet (only public way I could find to set yMin and yMax to 0), then clearing the DataSet to remove it, before setting ChartView.data, avoids the crash. (I also have to fuss with the LineChartView.xAxis to suppress the labels the axis renderer so helpfully wants to display for a empty dataset, but my usage is probably atypical. The chart displays realtime data and at this point, before I've collected any data points, I don't want any xAxis labels.) I'm a Charts nooB, so I won't embarrass myself by suggesting where to guard against this DBL_MAX issue. :) Hope this helps… |
Thanks for the info! Looks like the 32bit device has troubles.. @danielgindi |
I stumbled on this issue yesterday when creating and assigning an empty ChartData:
But when adding dataSets before assigning to chartData, everything works fine:
Only crashed on the 32 bit, not on the 64 bit device. |
@brunce make sure you call chartView.data = chartData at last, because the data setter will invoke @ObjColumnist I think you made the same mistake. You shouldn't feed data when you only have empty array. Everything is like default DBL_MAX /DBL_MIN and on 64 devices, the i is then +inf, while you say it's NaN on 32 bit device. I will try to find a 32 bit device to test |
Alright, I found an iPhone 5 to test, it's indeed because the CPU arch, same as @spalmen:
64bit:
Then, due to the difference,
32 bit
@danielgindi I will merge that PR. I tested it on iPhone 5, should be good. |
Added a check against NaN, fix ChartsOrg#1737
Added a check against NaN, fix ChartsOrg#1737
This is [still] present on 64bit devices (iPhone 6S plus) |
@acegreen please give proofs how this is still present like I tested above. |
On 32 Bit Devices the function
decimals
inChartUtils
causes a bad memory access when the default formatter for a Chart is created.That is because
i
is NaN so the linereturn Int(ceil(-log10(i))) + 2
crashes.The text was updated successfully, but these errors were encountered: