SharedCLibrary runtime
André Timmermans (100) 655 posts |
I always have difficulties tracing the origin of “* unrecoverable error in run time system: free failed”. Would it be possible to generate a stack trace to at least have a hint where to look for the issue? Also another issue with these unrecoverable errors, is to leave all resources (files, sockets, …) open. I get that calling the user atexit() routine might be unwise but I was wondering if it would be safe to call the routine that closes open files? |
Charles Ferguson (8243) 427 posts |
“Unrecoverable” means just that – the system cannot determine if it’s safe to do anything. The best it can hope to do is report that there was a problem, and try to exit. Because there is no process management in RISC OS, this form of unrecoverable error means you are lucky if you can even exit the application and return to some other part of the system. Usually it’s stack or heap corruption, and that might include the stacked environment of the caller. To aid in debugging, replace your standard heap calls with those that include checks for double frees, includes guard words and otherwise protects you from corrupting things so completely that you cannot exit cleanly. The Fortify library or similar will do this job for you. Look inside the Nettle source code (https://github.com/dpt/Nettle/blob/master/nettle/c/fortify) – I’d intended to do a release of it standalone, but its license is… interesting. |