-
Notifications
You must be signed in to change notification settings - Fork 18
/
ucos2.patch
27 lines (22 loc) · 1.37 KB
/
ucos2.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
This patch fixes a bug present when passing the OS_TASK_OPT_STK_CLR
option to OSTaskCreateExt(). The original code would overwrite an
additional byte before the stack and leave the last byte untouched.
The Dynamic C 10.72E release includes the patched OS_TASK.C file, but
the uC/OS-II source isn't included in the Open Source GitHub code
repository. If your Dynamic C installation is based on 10.72D or
earlier, you will need to manually apply this fix using `patch`:
patch -p1 --forward < ucos2.patch
Include the command-line option "--dry-run" to test the patch. The
"--forward" option ignores the patch if already applied.
--- a/Lib/Rabbit4000/UCOS2/OS_TASK.C 2016-03-03 16:23:12 -0700
+++ b/Lib/Rabbit4000/UCOS2/OS_TASK.C 2019-06-11 17:09:04 -0700
@@ -479,7 +479,9 @@
if (opt & OS_TASK_OPT_STK_CHK) { // See if stack checking has been enabled
if (opt & OS_TASK_OPT_STK_CLR) { // See if stack needs to be cleared
// Yes, fill the stack with zeros
- _f_memset((void __far *)(PhysAddr - stk_size), 0, stk_size);
+ // PhysAddr is the last address of the stack (e.g., ...FF), so it's
+ // necessary to add 1 to get to the starting address of the stack.
+ _f_memset((void __far *)(PhysAddr - stk_size + 1), 0, stk_size);
}
}