Page 1 of 1 1
Topic Options
#77643 - 2001-04-22 06:44 AM BUG: Empty (no-op) functions cause invalid page fault
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Ruud,

Seems as if empty (stubbed-out) functions cause k2k to page fault. According to the manual, this should be perfectly legal syntax. This happens on NT and 9x with both kix32.exe and kix32c.exe. Here's the script and the dump...


code:

break on
myfunction()
exit


function myfunction()
endfunction


code:

KIX32C caused an invalid page fault in
module KIX32C.EXE at 0167:00411324.
Registers:
EAX=00fc0100 CS=0167 EIP=00411324 EFLGS=00010206
EBX=00560000 SS=016f ESP=0066e748 EBP=0066e76c
ECX=00fc0100 DS=016f ESI=8172bd74 FS=5437
EDX=00000000 ES=016f EDI=00000000 GS=0000
Bytes at CS:EIP:
0f be 02 83 f8 20 74 38 8b 4d 08 8b 51 18 0f be
Stack dump:
00000000 00000000 00000000 00000000
00000000 00000000 00840000 00000000
00000000 0066e77c 00411b70 00fc0100
00fc0100 0066e7c0 00409181 0000000a

Shawn.

[This message has been edited by Shawn (edited 22 April 2001).]

Top
#77644 - 2001-04-22 07:05 AM Re: BUG: Empty (no-op) functions cause invalid page fault
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Here's another one... This is perfectly legal syntax (according to the manual) ...

This script traps ...

code:

break on
clearscreen
exit


function clearscreen
cls
endfunction


But this script works...

code:

break on
clearscreen
exit


function clearscreen
cls
cls
endfunction


And this script works...

code:

break on
clearscreen
exit


function clearscreen()
cls
endfunction


Shawn.

[This message has been edited by Shawn (edited 22 April 2001).]

Top
#77645 - 2001-04-22 06:03 PM Re: BUG: Empty (no-op) functions cause invalid page fault
cj Offline
MM club member
*****

Registered: 2000-04-06
Posts: 1102
Loc: Brisbane, Australia
I noticed this too, when I was writing my manual. I forgot to mention it here, but recorded this in the manual:

code:

FUNCTION


Type
KiXtart 2001 only Command


Action Declares the name, arguments, and code that form the body of a Function procedure.


Syntax FUNCTION name[([OPTIONAL] arguments...)]
[statements]
[$name=expression]
ENDFUNCTION


Parameters name

Required string that defines the name of the function. KiXtart considers this to be a function just like and other KiXtart function. Built-in KiXtart functions cannot be replaced with this command.


arguments...
Optional comma separated variable declarations that are passed to this function when it is called.


statements
Optional script that will be executed when this function is called.


expression
Optional value returned to calling script.


OPTIONAL
Optional keyword that defines the following argument as optional, that is, it is not required. Every argument following the first optional argument must also be declared as optional.


Remarks A Function procedure is a separate procedure that can take arguments, perform a series of statements, and change the values of its arguments. A Function procedure can be used in an expression the same way KiXtart functions are. For example: $a=myfunction(1,2) The value of $a will be set to the return value of myfunction.

Function procedures have a global scope, that is, they are visible to all other scripts and procedures in the scripts. The value of local variables in a Function is not preserved between calls to the procedure.


Functions cannot be defined inside other functions. The RETURN and EXIT commands immediately exit the function and execution continues in the calling script.


Function procedures can be recursive, that is, they can call themselves to perform a given task, but excessive or continuous recursion can lead to stack overflow.


To return a value from a function, assign the value to the function name. Any number of such assignments can appear anywhere within the procedure. If no value is assigned to name, the procedure returns an empty value.


Variables defined within the function with DIM are always local to this function. Variables that are used but not declared in a function are declared as global variables and could conflict with other global variables. This rule does not apply to $name because this is the return value.


While statements and $name=expression are both optional, at least one of them is required at any one time. That is, they can’t both be missing.


Examples "The meaning to life is " ADD(13, 29) ; try this: ADD(11, 22, 9)
?
Function ADD($first, $second, OPTIONAL $third)
$ADD=$first + $second + $third
if $third $ADD=$ADD+$third endif
EndFunction


I couldn't decide whether to make it be FUNCTION name [ ( ) ] or FUNCTION name ( )


cj


 


[This message has been edited by cj (edited 22 April 2001).]

Top
#77646 - 2001-04-23 11:27 PM Re: BUG: Empty (no-op) functions cause invalid page fault
Anonymous
Unregistered


Good call, and just in time for beta 2.
Both issues have been fixed.

Thanks for the report,

Ruud

Top
Page 1 of 1 1


Moderator:  ShaneEP, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 509 anonymous users online.
Newest Members
min_seow, Audio, Hoschi, Comet, rrosell
17881 Registered Users

Generated in 0.049 seconds in which 0.021 seconds were spent on a total of 12 queries. Zlib compression enabled.