Re: Catching 'out of memory' using pcall()

  • From: Mike Pall <mike-1403@xxxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Mon, 17 Mar 2014 20:09:59 +0100

Dmitri Shubin wrote:
> Could it lead crash with the following backtrace:

That backtrace doesn't look quite right. Because an out-of-memory
error in the interpreter (in BC_TDUP) should be caught by pcall
and it shouldn't crash, either.

A simple test works for me:

$ luajit -joff -e "collectgarbage('stop'); print(pcall(function() for i=1,1e9 
do t={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20} end end))"
false   not enough memory

--Mike

Other related posts: