Bug 201350 - loader nextboot will leave trash in stack
Summary: loader nextboot will leave trash in stack
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Many People
Assignee: FreeBSD bugs mailing list
Keywords: patch
Depends on:
Reported: 2015-07-05 00:19 UTC by Toomas Soome
Modified: 2015-07-05 01:03 UTC (History)
1 user (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Toomas Soome 2015-07-05 00:19:19 UTC
the include_nextboot_file word is using catch to intercept errors from file io, and leaves trash in stack; 

it happens because before ['] peek_file catch the get_nextboot_conf_file leaves stack as ( addr len ) and catch will restore stack pointer to the same state (but not values!). to clean up, following update will do:

: include_nextboot_file
-  get_nextboot_conf_file
-  ['] peek_file catch
+  get_nextboot_conf_file               ( addr len )
+  ['] peek_file catch                  ( addr len code )
+  dup EOPEN = if
+    drop       ( drop exception code )
+    2drop      ( drop file name restored by catch )
+  else
+    throw
+  then

the throw/catch mechanism is described very nicely by www.complang.tuwien.ac.at/anton/euroforth/ef98/milendorf98.pdf

btw, also related to nextboot, yes that strdup is leak and not needed at all;)
: get_nextboot_conf_file ( -- addr len )
-  nextboot_conf_file strget strdup     \ XXX is the strdup a leak ?
+  nextboot_conf_file strget