1.2RC2 'recusion overflow (in T-Lisp)' gives bad error

Bug reports for the different beta versions of transcendence.
Post Reply
User avatar
Aury
Fleet Admiral
Fleet Admiral
Posts: 5421
Joined: Tue Feb 05, 2008 1:10 am
Location: Somewhere in the Frontier on a Hycrotan station, working on new ships.

Say I make a recursive function such as this one (I was explicitly testing to see how deeply i could nest lambdas:

Code: Select all

	(block Nil
		(setq TST_printRecurse (lambda (iter)
			(block Nil
				(printTo 'log iter)
				(TST_printRecurse (add iter 1))
			)
		))
	)
it gives this error:

Code: Select all

Exception in printTo; arg = (log 1945)
OnCreate [George-class recursion test ship]: Exception in printTo; arg = (log 1945) [(log 1945)] ### (printTo "log" iter) ###
It should give an error about overflow instead (Note that those messages are from it failing after the 1944th successful recursive call.)
(shpOrder gPlayership 'barrelRoll)
(plySetGenome gPlayer (list 'Varalyn 'nonBinary))
Homelab Servers: Xeon Silver 4110, 16GB | Via Quadcore C4650, 16GB | Athlon 200GE, 8GB | i7 7800X, 32GB | Threadripper 1950X, 32GB | Atom x5 8350, 4GB | Opteron 8174, 16GB | Xeon E5 2620 v3, 8GB | 2x Xeon Silver 4116, 96GB, 2x 1080ti | i7 8700, 32GB, 6500XT
Workstations & Render machines: Threadripper 3990X, 128GB, 6900XT | Threadripper 2990WX, 32GB, 1080ti | Xeon Platinum 8173M, 48GB, 1070ti | R9 3900X, 16GB, Vega64 | 2x E5 2430L v2, 24GB, 970 | R7 3700X, 32GB, A6000
Gaming Systems: R9 5950X, 32GB, 6700XT
Office Systems: Xeon 5318Y, 256GB, A4000
Misc Systems: R5 3500U, 20GB | R5 2400G, 16GB | i5 7640X, 16GB, Vega56 | E5 2620, 8GB, R5 260 | P4 1.8ghz, 0.75GB, Voodoo 5 5500 | Athlon 64 x2 4400+, 1.5GB, FX 5800 Ultra | Pentium D 3.2ghz, 4GB, 7600gt | Celeron g460, 8GB, 730gt | 2x Athlon FX 74, 8GB, 8800gts 512 | FX 9590, 16GB, R9 295x2 | E350, 8GB | Phenom X4 2.6ghz, 16GB, 8800gt | random core2 duo/atom/i5/i7 laptops
kay.py
Militia Lieutenant
Militia Lieutenant
Posts: 139
Joined: Mon Dec 28, 2009 10:33 am

The behaviour isn't wrong, its just not giving details of the exception. This particular recursion test is inevitably going to fail on the call to printTo, because if it has enough stack to get the printTo done then it has enough stack for another TST_printRecurse call.

So you get an (unlabelled) overflow exception on the printTo that breaks the camels back.

Hmm. Does Transcendence lisp support tail call recursion?
User avatar
Aury
Fleet Admiral
Fleet Admiral
Posts: 5421
Joined: Tue Feb 05, 2008 1:10 am
Location: Somewhere in the Frontier on a Hycrotan station, working on new ships.

Yes, this test was designed to fail - the fact it failed was correct - what is wrong is that it gave an inappropriate error message.
(shpOrder gPlayership 'barrelRoll)
(plySetGenome gPlayer (list 'Varalyn 'nonBinary))
Homelab Servers: Xeon Silver 4110, 16GB | Via Quadcore C4650, 16GB | Athlon 200GE, 8GB | i7 7800X, 32GB | Threadripper 1950X, 32GB | Atom x5 8350, 4GB | Opteron 8174, 16GB | Xeon E5 2620 v3, 8GB | 2x Xeon Silver 4116, 96GB, 2x 1080ti | i7 8700, 32GB, 6500XT
Workstations & Render machines: Threadripper 3990X, 128GB, 6900XT | Threadripper 2990WX, 32GB, 1080ti | Xeon Platinum 8173M, 48GB, 1070ti | R9 3900X, 16GB, Vega64 | 2x E5 2430L v2, 24GB, 970 | R7 3700X, 32GB, A6000
Gaming Systems: R9 5950X, 32GB, 6700XT
Office Systems: Xeon 5318Y, 256GB, A4000
Misc Systems: R5 3500U, 20GB | R5 2400G, 16GB | i5 7640X, 16GB, Vega56 | E5 2620, 8GB, R5 260 | P4 1.8ghz, 0.75GB, Voodoo 5 5500 | Athlon 64 x2 4400+, 1.5GB, FX 5800 Ultra | Pentium D 3.2ghz, 4GB, 7600gt | Celeron g460, 8GB, 730gt | 2x Athlon FX 74, 8GB, 8800gts 512 | FX 9590, 16GB, R9 295x2 | E350, 8GB | Phenom X4 2.6ghz, 16GB, 8800gt | random core2 duo/atom/i5/i7 laptops
User avatar
digdug
Fleet Admiral
Fleet Admiral
Posts: 2620
Joined: Mon Oct 29, 2007 9:23 pm
Location: Decoding hieroglyphics on Tan-Ru-Dorem

mmhh, I'm no programmer, and I have little understanding of recursion.
From my point of view, all that I want to know is how not to have Transcendence crash on my code.

Question: does it mean that the function loop is going to crash after 1944 loops ?
kay.py
Militia Lieutenant
Militia Lieutenant
Posts: 139
Joined: Mon Dec 28, 2009 10:33 am

digdug wrote:Question: does it mean that the function loop is going to crash after 1944 loops ?
Pretty much, but it isnt due to the loop-like nature, but to the repeated nesting of function calls

If function1 calls function2 which calls function3 which calls
<I am not going to type ~2000 of these>
which calls function2000

then it will throw an exception (the game should continue, but the functions leading up to the exception will be aborted).

In a rough sense: when a function returns, it needs to know where to return to. That means storing the "return here" details for each function call, and that storage can run out of room. The exact time at which it runs out varies depending on circumstances. Working directly from the Debug Console, I got about 2050 recursions before the exception.
george moromisato
Developer
Developer
Posts: 2997
Joined: Thu Jul 24, 2003 9:53 pm
Contact:

I'll see if I can figure out the kind of exception. Stack overflows trigger a different exception, so I can always generate a recursion problem message. This is low priority, however, probably something for later.
Post Reply