-
Notifications
You must be signed in to change notification settings - Fork 19.9k
Avoid infinite loop in ftoa_engine #30754
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
Conversation
|
This fixes the problem in Lua on CubeOrange (which is funneled to this same routine): Before: After: Interesting that The problematic value's hex representation is 0x7, so it's only a few ticks above the minimum positive float. |
Co-authored-by: JasonMDavey <[email protected]>
Co-authored-by: JasonMDavey <[email protected]>
4c48b6c to
6a8959e
Compare
|
Do your troubles with replication mean this is a ChibiOS-specific problem right now? |
|
Yeah, I cannot replicate this in SITL and am in fact getting different results for the non-crashing cases. Concerning... EDIT: possibly because SITL does not have the linker wrap args that catch Lua's use of bare I can verify Peter's test now though. |
|
Some more notes from investigating:
Understanding a little more I think this is a slightly over-complicated fix. I'd be happy with just the flush inside |
The output from the ftoa_engine is actually empty with that patch alone! I really didn't try to understand it, just avoid the infinite loop. If you think you can do better, please do feel free to force-push :-) |
Closes #30722
I am not satisfied with this at the moment as I was unable to replicate the problem as described in the issue.@tpwrules helped make this reproduce the problem; the snprintf test infinitely loops before the fix and doesn't afterwards.The issue states that we can cross this codepath in ftoa_engine via send_text, but my test for print_vprintf in here does not replicate the problem before or after the clamping patch!
This is a belts-and-bracers patch, with a bad/minimal patch inside ftoa_engine to avoid the infinite loop and a better clamping patch inside the sole caller to ftoa_engine.