nintendoswitch: Fix invalid memory read / write in print calls #1368
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
These fixes are for what it looks like a compiler bug. Me and @deadprogram tried for a while to debug what caused that problems, and it looks like it is some unknown compiler bug which it doesn't seens to happen for other platforms.
There are two bugs:
putchar, the slicing of a pre-allocated slice triggers a new memory allocation, which in some parts of the code isn't possible.runtime_nintendoswitch_heap.goif only there, works just fine. But if the target code has another panic, neither of the panic's output is printed correctly (the string passed to the print call has a null pointer)I can't be sure what's causing these errors, but this fixes it for now. I haven't got any issues in target code if that runtime code is like this.
@aykevl with this, the issues you were having in #1226 should be gone.