j
: Next unread message k
: Previous unread message j a
: Jump to all threads
j l
: Jump to MailingList overview
From: Igor V. Kovalenko igor.v.kovalenko@gmail.com
- add dictlimit variable to store dictionary memory size - change herewrite() to check for overflow if dictlimit is set - sparc64: set dictlimit to allocated amount
Signed-off-by: Igor V. Kovalenko igor.v.kovalenko@gmail.com --- arch/sparc64/openbios.c | 2 ++ kernel/dict.c | 1 + kernel/forth.c | 8 ++++++++ kernel/include/dict.h | 1 + 4 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/arch/sparc64/openbios.c b/arch/sparc64/openbios.c index 2f1a955..67849e1 100644 --- a/arch/sparc64/openbios.c +++ b/arch/sparc64/openbios.c @@ -519,6 +519,8 @@ int openbios(void) collect_sys_info(&sys_info);
dict = malloc(DICTIONARY_SIZE); + dictlimit = DICTIONARY_SIZE; + load_dictionary((char *)sys_info.dict_start, (unsigned long)sys_info.dict_end - (unsigned long)sys_info.dict_start); diff --git a/kernel/dict.c b/kernel/dict.c index 34b97f3..822c923 100644 --- a/kernel/dict.c +++ b/kernel/dict.c @@ -21,6 +21,7 @@ unsigned char *dict = NULL; ucell *last; cell dicthead = 0; +ucell dictlimit = 0;
/* lfa2nfa * converts a link field address to a name field address, diff --git a/kernel/forth.c b/kernel/forth.c index 5fc53d3..2876709 100644 --- a/kernel/forth.c +++ b/kernel/forth.c @@ -851,6 +851,14 @@ static void herewrite(void) #ifdef CONFIG_DEBUG_INTERNAL printk("here!: new value: %x\n", tmp); #endif + + if (dictlimit && dicthead >= dictlimit) { + printk("Dictionary space overflow:" + " dicthead=" FMT_ucellx + " dictlimit=" FMT_ucellx + "\n", + dicthead, dictlimit); + } }
diff --git a/kernel/include/dict.h b/kernel/include/dict.h index 7e8c320..cc30f99 100644 --- a/kernel/include/dict.h +++ b/kernel/include/dict.h @@ -50,6 +50,7 @@ extern ucell PC;
extern unsigned char *dict; extern cell dicthead; +extern ucell dictlimit; extern ucell *last; #ifdef FCOMPILER extern ucell *trampoline;
Igor V. Kovalenko wrote:
From: Igor V. Kovalenko igor.v.kovalenko@gmail.com
- add dictlimit variable to store dictionary memory size
- change herewrite() to check for overflow if dictlimit is set
- sparc64: set dictlimit to allocated amount
This patch looks great in that it correctly picks up on the overflow condition when added to r740. If you could update it so that it works on all archs then I'm happy to apply it.
ATB,
Mark.
On Mon, Apr 12, 2010 at 2:15 PM, Mark Cave-Ayland mark.cave-ayland@siriusit.co.uk wrote:
Igor V. Kovalenko wrote:
From: Igor V. Kovalenko igor.v.kovalenko@gmail.com
- add dictlimit variable to store dictionary memory size
- change herewrite() to check for overflow if dictlimit is set
- sparc64: set dictlimit to allocated amount
This patch looks great in that it correctly picks up on the overflow condition when added to r740. If you could update it so that it works on all archs then I'm happy to apply it.
I was looking at hiding dict and dictlimit assignment behind initialization routine but it is not a priority task now that you applied modified version :)
Mark Cave-Ayland wrote:
This patch looks great in that it correctly picks up on the overflow condition when added to r740. If you could update it so that it works on all archs then I'm happy to apply it.
Turns out that it wasn't too difficult to modify the patch for all architectures and so I've applied a revised version of your patch to SVN.
Many thanks,
Mark.