Ticket #637 (Open)Thu May 09 13:24:38 UTC 2024
Data abort on entering C module if WimpSlot too small
Reported by: | Ben Avison (25) | Severity: | Normal |
Part: | RISC OS: Module | Release: | |
Milestone: | Status | Open |
Details by Ben Avison (25):
If a module is written in C and it can be entered as the current application (using OS_Module 2 or otherwise) then if the WimpSlot is too small then you get a data abort. This is presumably because the C library doesn’t check memory is available before creating a heap in the application slot.
Evidence for why it should be the C library’s responsibility to check this comes from:
- the C library will attempt to grow the application slot when allocating a heap block that doesn’t fit: https://gitlab.riscosopen.org/RiscOS/Sources/Li…
- for AIF applications, FileSwitch is responsible for growing the application slot if necessary before starting: https://gitlab.riscosopen.org/RiscOS/Sources/Fi…
Steps to reproduce:
cmhg file should include:
module-is-runnable:
C source should include:
int main(void)
{
}
Then from the CLI, type:
*WimpSlot 0 0
*RMRun mymodule
Changelog:
Modified by Sprow (202) Thu, May 09 2024 - 20:16:32 GMT
Just for info: several modules I’ve seen in passing deal with this themselves by setting up a stack before getting to main() by also using the library-enter-code keyword to get in beforehand and grab some space from somewhere like the RMA.
Searching the sources for those modules using both module-is-runnable and library-enter-code it includes: URI, ShellCLI, AcornSSL, TServer.