Commit 6911d7cc authored by Jeffrey Lee's avatar Jeffrey Lee
Browse files

Protect memory above MemoryLimit being nuked when starting a task

Detail:
  s/Wimp08s - Improve testapplication to detect situations where data is being stored above MemoryLimit, e.g. if a C app uses system() to issue *WimpTask
  Usually the CAO check will detect this kind of situation, except for the case where a single-tasking app issues *WimpTask - in which case the CAO will get reset to the Wimp module due to ModHandReason_Enter being used to get into USR mode so a temp parent task can be created
  Wimp_SlotSize checks MemoryLimit against ApplicationSpaceSize before allowing the wimpslot to be resized, so it seems to be a bit of an oversight that the task startup code wasn't doing the same
Admin:
  Tested on BB-xM
  Fixes ticket #279:
  https://www.riscosopen.org/tracker/tickets/279


Version 5.39. Tagged as 'Wimp-5_39'
parent d3034221
......@@ -11,13 +11,13 @@
GBLS Module_HelpVersion
GBLS Module_ComponentName
GBLS Module_ComponentPath
Module_MajorVersion SETS "5.38"
Module_Version SETA 538
Module_MajorVersion SETS "5.39"
Module_Version SETA 539
Module_MinorVersion SETS ""
Module_Date SETS "27 Mar 2014"
Module_ApplicationDate SETS "27-Mar-14"
Module_Date SETS "13 Apr 2014"
Module_ApplicationDate SETS "13-Apr-14"
Module_ComponentName SETS "Wimp"
Module_ComponentPath SETS "castle/RiscOS/Sources/Desktop/Wimp"
Module_FullVersion SETS "5.38"
Module_HelpVersion SETS "5.38 (27 Mar 2014)"
Module_FullVersion SETS "5.39"
Module_HelpVersion SETS "5.39 (13 Apr 2014)"
END
/* (5.38)
/* (5.39)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 5.38
#define Module_MajorVersion_CMHG 5.39
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 27 Mar 2014
#define Module_Date_CMHG 13 Apr 2014
#define Module_MajorVersion "5.38"
#define Module_Version 538
#define Module_MajorVersion "5.39"
#define Module_Version 539
#define Module_MinorVersion ""
#define Module_Date "27 Mar 2014"
#define Module_Date "13 Apr 2014"
#define Module_ApplicationDate "27-Mar-14"
#define Module_ApplicationDate "13-Apr-14"
#define Module_ComponentName "Wimp"
#define Module_ComponentPath "castle/RiscOS/Sources/Desktop/Wimp"
#define Module_FullVersion "5.38"
#define Module_HelpVersion "5.38 (27 Mar 2014)"
#define Module_LibraryVersionInfo "5:38"
#define Module_FullVersion "5.39"
#define Module_HelpVersion "5.39 (13 Apr 2014)"
#define Module_LibraryVersionInfo "5:39"
......@@ -828,19 +828,32 @@ setslotaccess ROUT
;
; Method:
; 1. If CAO pointer < MemoryLimit, then application memory is in use.
; 2. Issue Service_Memory: R0 = large - if anyone objects, memory is in use
; 2. If MemoryLimit < ApplicationSpaceSize, then memory (probably) in use.
; (catches situations where CAO isn't set, e.g. when *WimpTask creates a
; temp task and so CAO == our module)
; 3. Issue Service_Memory: R0 = large - if anyone objects, memory is in use
;
ApplicationStart * &8000
IsAnybodyThere * -64*&100000 ; large negative number
; NB: this number is checked for by ShellCLI
testapplication ROUT
Push "R1-R3,LR"
Push "R1-R4,LR"
;
LDR R1,orig_applicationspacesize ; watch out for Twin etc!
BL readCAOpointer ; use OS_ChangeEnvironment
CMP R2,R1 ; below memorylimit?
Pull "R1-R3,PC",CC
Pull "R1-R4,PC",CC
;
MOV R0,#ApplicationSpaceSize
MOV R1,#0
SWI XOS_ChangeEnvironment
MOV R4,R1
MOV R0,#MemoryLimit
MOV R1,#0
SWI XOS_ChangeEnvironment
CMP R1,R4
Pull "R1-R4,PC",CC ; MemoryLimit < ApplicationSpaceSize
;
Debug mjs3,"testapplication routine issueing Service_Memory"
MOV R1,#Service_Memory
......@@ -855,7 +868,7 @@ testapplication ROUT
SWI XOS_ServiceCall
CMPVC R1,#1 ; CC ==> service was claimed
;
Pull "R1-R3,PC"
Pull "R1-R4,PC"
; Out R2 = CAO pointer (read using OS_ChangeEnvironment)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment