Page 1 of 1 1
Topic Options
#209656 - 2014-11-18 12:45 PM "Stack overflow exception" bug in 4.64 not in 4.53
BillBarnard Offline
Starting to like KiXtart

Registered: 2007-03-14
Posts: 141
Loc: Leighton Buzzard, Bedfordshire...
I am receiving the following error in Kix32 version 4.64:-
Stack overflow exception.
The common cause for this type of exception is an endless recursive loop.
Please check your script(s) for endless loops.

If I run my program with kix32 version 4.53 my program works.
Basically, I am using a recursive function to fill a graphic area.
 Code:
Function FillBill($x, $y, $f, $r)
; If pixel colour at ($x,$y) is $f replace it with colour $r
If $form.point($x, $y) = $f
   Dim $c
   $c = $form.forecolor		; Save Forecolor
   $Form.forecolor = $r
   $form.pset($x, $y)
   FillBill($x+1, $y, $f, $r)
   FillBill($x-1, $y, $f, $r)
   FillBill($x, $y+1, $f, $r)
   FillBill($x, $y-1, $f, $r)
   $form.forecolor = $c		; Restore Forecolor
Endif

What is different with the latest version of kix32.exe from previous versions as regards to memory usage?
Please ignore the fact that the actual coding above does not fill in pixels in the 4 corner positions around the target pixel. It's only a test script.
I'm also using Kixforms 2.47.5.
Regards,
_________________________
Bill

Top
#209657 - 2014-11-18 01:08 PM Re: "Stack overflow exception" bug in 4.64 not in 4.53 [Re: BillBarnard]
BillBarnard Offline
Starting to like KiXtart

Registered: 2007-03-14
Posts: 141
Loc: Leighton Buzzard, Bedfordshire...
Further testing has revealed that this error was introduced in Kix32.exe versions 4.62 and 4.63.
Versions 4.60, 4.61 do not produce this error with my recursive fill function.
Please fix in 4.65.
Cheers,
_________________________
Bill

Top
#209658 - 2014-11-18 05:10 PM Re: "Stack overflow exception" bug in 4.64 not in 4.53 [Re: BillBarnard]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
uh oh... function calling itself sounds like infinite loop waiting to happen...

have you tried outputting something on the console to see how many times it is ran?

say, add a global var $test_runs = 0 at the start of your script and modify your fillbill to:
 Code:
Function FillBill($x, $y, $f, $r)
; If pixel colour at ($x,$y) is $f replace it with colour $r
If $form.point($x, $y) = $f
$test_runs=$test_runs+1 chr(13) $test_runs
   Dim $c
   $c = $form.forecolor		; Save Forecolor
   $Form.forecolor = $r
   $form.pset($x, $y)
   FillBill($x+1, $y, $f, $r)
   FillBill($x-1, $y, $f, $r)
   FillBill($x, $y+1, $f, $r)
   FillBill($x, $y-1, $f, $r)
   $form.forecolor = $c		; Restore Forecolor
Endif


what is the number at when it crashes?
_________________________
!

download KiXnet

Top
#209659 - 2014-11-19 12:04 PM Re: "Stack overflow exception" bug in 4.64 not in 4.53 [Re: Lonkero]
BillBarnard Offline
Starting to like KiXtart

Registered: 2007-03-14
Posts: 141
Loc: Leighton Buzzard, Bedfordshire...
Hi Lonkero,
I've created a simpler recursive function that produces a count.
 Code:
break on
$ = setoption("wrapateol","on")
recurs(1)
?
return
function recurs($i)
If $i<100000
   $i "  "
   recurs($i+1)
endif
endfunction

Kix 464 bombs out at 2116 whilst 453 bombs at 8356.
So this older version seems to have 4 times more stack space.
460, 461 both bomb out at 23768
462, 463 at 2169
So I think versions 460 and 461 had a lot more going for them.

Cheers,
_________________________
Bill

Top
#209666 - 2014-11-19 10:06 PM Re: "Stack overflow exception" bug in 4.64 not in 4.53 [Re: BillBarnard]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
what kind of memory usage we are talking about at that point?

indeed 2116 sounds really low.
_________________________
!

download KiXnet

Top
#209674 - 2014-11-20 02:07 PM Re: "Stack overflow exception" bug in 4.64 not in 4.53 [Re: Lonkero]
BillBarnard Offline
Starting to like KiXtart

Registered: 2007-03-14
Posts: 141
Loc: Leighton Buzzard, Bedfordshire...
The above program is all there is too it. A couple of variables and one function.
4.64 runs out of stack space quite quickly. Perhaps it needs to be more dynamic in the allocation of heap and stack space.
In Task manager you see Kix32 start briefly at 15,000K to 45,000K then as it terminates it displays 75,464K
Kix32 453 terminates at 259,820K
Kix32 460 terminates at 834,748K

So 4.64 must be under resourced.

Cheers,


Edited by BillBarnard (2014-11-20 02:10 PM)
_________________________
Bill

Top
#209710 - 2014-12-02 10:45 PM Re: "Stack overflow exception" bug in 4.64 not in 4.53 [Re: BillBarnard]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
I do not know why this is, maybe it's something Ruud has changed or maybe the defaults for the new visual studio version is different.

anyways, you can fix it by issuing:

editbin /stack:99999999 wkix32.exe


when you issue the command, editbin actually modifies the executable and this issue is fixed.
http://msdn.microsoft.com/en-us/library/xd3shwhf.aspx

install visual studio (express is fine) if you do not have it yet to use this tool.
_________________________
!

download KiXnet

Top
#209735 - 2014-12-12 03:50 PM Re: "Stack overflow exception" bug in 4.64 not in 4.53 [Re: Lonkero]
BillBarnard Offline
Starting to like KiXtart

Registered: 2007-03-14
Posts: 141
Loc: Leighton Buzzard, Bedfordshire...
Thanks Lonkero,
does this also work on kix32.exe ?
Happy Kixmas,
_________________________
Bill

Top
#209736 - 2014-12-12 09:56 PM Re: "Stack overflow exception" bug in 4.64 not in 4.53 [Re: BillBarnard]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
It works for any exe
_________________________
!

download KiXnet

Top
#209737 - 2014-12-15 12:51 PM Re: "Stack overflow exception" bug in 4.64 not in 4.53 [Re: Lonkero]
BillBarnard Offline
Starting to like KiXtart

Registered: 2007-03-14
Posts: 141
Loc: Leighton Buzzard, Bedfordshire...
Thanks.
Now got to find that Virtual Machine with all my test apps on.
_________________________
Bill

Top
#209743 - 2014-12-21 02:13 PM Re: "Stack overflow exception" bug in 4.64 not in 4.53 [Re: BillBarnard]
BillBarnard Offline
Starting to like KiXtart

Registered: 2007-03-14
Posts: 141
Loc: Leighton Buzzard, Bedfordshire...
Hi Lonkero,
I can't find editbin.exe in Visual Studio Express 2010.
I suppose I'll have to try 2013.
Cheers,
_________________________
Bill

Top
#209744 - 2014-12-21 05:30 PM Re: "Stack overflow exception" bug in 4.64 not in 4.53 [Re: BillBarnard]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
Hmm... I do also have windows 7 SDK on that computer. Might be it as well.
_________________________
!

download KiXnet

Top
#210396 - 2015-07-16 06:15 PM Re: "Stack overflow exception" bug in 4.64 not in 4.53 [Re: Lonkero]
Ruud van Velsen Moderator Offline
Developer
*****

Registered: 1999-05-06
Posts: 391
Loc: Amsterdam, The Netherlands
Thanks for this report, seems like I decreased the size of the stack somewhere.
I'll look at this for the Windows 10 update.

Ruud

Top
#210399 - 2015-07-17 08:15 AM Re: "Stack overflow exception" bug in 4.64 not in 4.53 [Re: Ruud van Velsen]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
hopefully that windows 10 update will also fix the failing move, del and rd...

thanks for staying with it, Ruud!
_________________________
!

download KiXnet

Top
#211946 - 2016-09-06 06:10 PM Re: "Stack overflow exception" bug in 4.64 not in 4.53 [Re: Lonkero]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
I haven't tested this with 4.67 beta, but I just ran out of memory with 4.66 trying to read a line from 800 meg text file...
_________________________
!

download KiXnet

Top
#211987 - 2016-10-03 07:51 PM Re: "Stack overflow exception" bug in 4.64 not in 4.53 [Re: Lonkero]
Ruud van Velsen Moderator Offline
Developer
*****

Registered: 1999-05-06
Posts: 391
Loc: Amsterdam, The Netherlands
Thanks for the heads up, I'll have a look to see what's up.

Can't promise I'll be able to fix in 4.67 as I want to release that in the coming days, but let's see.

Ruud

Top
#211989 - 2016-10-04 03:02 PM Re: "Stack overflow exception" bug in 4.64 not in 4.53 [Re: Ruud van Velsen]
Ruud van Velsen Moderator Offline
Developer
*****

Registered: 1999-05-06
Posts: 391
Loc: Amsterdam, The Netherlands
Ok, did some more tests: the stack in 4.62 through 4.65 was indeed (too) small.
In 4.66 and 4.67 it is larger than ever, and for example the recursive script above can achieve 52994 iterations.

So I'm considering this issue fixed. If anyone still has a reproducible problem: please start a new topic.

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
0 registered and 433 anonymous users online.
Newest Members
Raoul, Timothy, Jojo67, MaikSimon, kvn317
17875 Registered Users

Generated in 0.069 seconds in which 0.024 seconds were spent on a total of 13 queries. Zlib compression enabled.