-
-
Notifications
You must be signed in to change notification settings - Fork 28
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
[RP2040, ARDUINO, PLATFORMIO] PNGDec decode causes infinite loop #25
Comments
Correction, it does not enter an infinite loop, it just crashes the RP2040. (infinite loop was created by adding debug lines and the omitted {} in the infinite for loop / switch loop in inflate. The CPU seems to crash on a write to *put++ on the line: I can't seem to find where and how the put pointer is initialized, the loop crashes when it writes a value from state->length to put pointing to address 0x2000D640 Ok traced put back to probably strm->next_out; strm->next_out is last set to pCurr (which in this case still on the first round seems to be set to pPage->ucPixels Debug info: |
I believe this is due to the RP2040 having an exception for unaligned pointer access. I think I regressed this code to undo that optimization. Clone the latest code instead of using the last release and see if it's resolved. If not, try removing |
First of all thanks for your reply! Actually the proposed solution evenlually lead to a fix! After removing the ALLOWS_UNALIGNED blocks from both the inflate.c and inffast.c it worked! The RP2040 does not like the UNALIGNED access it seems. It has some unstriped memory area's though, maybe it is possible to force a variable in those blocks to fix the issue as well and keep the performance of UNALIGNED access? just guessing here.
That seems to have been caused by the debugging lines, reloading the code only modifying the UNALIGNED blocks fixes the issue and produces good PNG representation. Thanks. |
Did you change the current code on Github to get it to work? When you say "removed the unaligned blocks" do you mean you disabled the #define or actually deleted the lines? The code on Github should work unchanged on your RP2040. If you confirm this, I'll do a new release. |
Hi BitBank2, #define ALLOWS_UNALIGNED In both inflate.c and inffast.c, and i can confirm that the latter also works. Thanks again for your efforts and for creating this tool. |
Describe the bug
When running pngDEC with the example octocat files on a RP2040 (platformIO, both earlephilhower cora and pico core). the png header is read correctly, however a call to png.decode(nullptr, 0); results in an infinite loop (in zlib inflate).
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The expected behaviour whould be that the png is decoded and for each line of image drawPNGLine is called.
Image you're having trouble with
example Octocat files from the PNGdec library.
The text was updated successfully, but these errors were encountered: