I'm working on a game using Nim, which compiles down to C. I'm getting experiencing a crash on device only that I'm struggling to debug. SDK version 2.3.1.
When I run crashlog.txt through the symbolizer, it just gives me question marks:
The last device crash I debugged I was able to to repro in the simulator. The error message was unaligned fastbin chunk detected. I resolved that error by deleting code, not by solving the underlying issue, so I'm suspicious this is the same problem. But like I said, I'm unable to repro in the simulator this time.
I'm about to switch to more tedious debugging options (printf, custom malloc), so I'm looking for ideas on anything else I should be doing before I go down that path.
As alluded to in File open crashes on device C API - #11 by dave, we actually do have symbols for (some) the Playdate firmware, located in the symbols.db file that's included with the SDK, but I never could find the memory addresses from my crash logs in the file. It just now occurred to me to convert the hexadecimal addresses from the logs into decimal (tool) to match the ones in the database, and sure enough, I can see the file name corresponding to the pc and lr values in your crash log.
Your pc and lr values are 2405cca8 and 2405d17d, which are 604359848 and 604361085 in decimal. If I search for those numbers in the lines table, it tells me that the pc value was found in file_id 166 (at line 3496). The lr value isn't found, but the surrounding addresses are in the same file. If I search for that file id in the files table, it tells me that file is /Core/dlmalloc.c. It's worth noting that while I wasn't able to find those addresses in the functions table, I could find addresses within a couple hundred of yours.
Hopefully this is somewhat helpful.
It just now occurred to me to convert the hexadecimal addresses from the logs into decimal (tool) to match the ones in the database, and sure enough, I can see the file name corresponding to the pc and lr values in your crash log
Great find! It does a bit to confirm that this is likely a memory issue.
I never was able to get ASan working for me on Ubuntu because of the issue I linked above. Valgrind seemed to work well enough, but it didn't help much because I was still unable to repro the crash on the simulator.
Instead, I edited the setup.c file that ships with the playdate SDK to have it log everything it was doing. With this, I discovered that the Nim integration layer wasn't fully using the playdate allocator. Under the covers, it was directly calling malloc in the c std lib, which apparently still works.
I was able to get rid the device crashes by ensuring that Nim itself was using playdate.system.realloc. (Caveat: I reserve the right to find more debilitating crashes that wind up being difficult to debug)