[Win98 Setup Bug]
Bug DescriptionThe program
function f local fv fv = 1 f = fv end function print f()fails to run and crashes the interpreter process.
Bug Reason, What Causes the BugIn the file command/function.c the implementation of the command "function return value assignment" is erroneous. When a value belonging to a local variable is assigned as return value to the function name the value is referenced by the function return value directly instead of making a copy of the value. When the function finishes the function return with a result stored on a memory location, which is already released.
In debug compiled version of the interpreter this results an error message and exists with the code 666. In non-debug compilation of the program various crash effect is the result.
SolutionIn the function commands/function.c the implementation of the command FLET has to be altered. The following line has to be inserted:
if( ItemResult && TYPE(ItemResult) == VTYPE_ARRAY )ERROR(COMMAND_ERROR_NOARRAY); ItemResult = memory_DupMortalize(pEo->pMo,ItemResult,_pThisCommandMortals,&iErrorCode); if( pEo->pFunctionResult )The middle call to memory_DupMortalize with the given parameters is to be inserted.
scriba v1.0b27 will deliver the corrected interpreter in the binaries as well.
Bug Workaround Until Solution is AvailableYou may use the build25, which should not face this bug. If you are using features that are specific to build26 and you are not able to recompile the altered source code then you can alter your program so that the right side of any function result assignment is an expression containing something more than just a variable. For example
function f local fv fv = 1 f = fv+0 end function print f()does not produce the bug.
AcknowledgementMitchell Greess [firstname.lastname@example.org] has reported this problem on the very date when I discovered it.