EcmaScriptCompiler.WriteExpression cause StackOverflowException

Hi,

Stack in IIS and Console application seem to be dfferently deepest, code don’t work into IIS but work into Console app
Recursion is 51 levels deep.

This is whole project:

https://docs.google.com/file/d/0B7fBZ8aCHKJRVWxfWkRGekI1NEk/view

Here is code which is executed into IIS:

    using (EcmaScriptComponent eng = new EcmaScriptComponent())
    {
        eng.Debug = false;
        string scr = System.IO.File.ReadAllText(Server.MapPath("/1.txt"));
        var cmp = eng.GlobalObject.InnerCompile(false, scr);
    }

Here is JavaScript:

with (doc) {
if (doc.getState() == 1) 
{
var sql = "begin B6_Bisera.MT103_МBUJ( "+
	"iUniqDoc => :p0, "+
	"iRings => :p1, "+
	"iBIC_Pol => :p2, "+
	"iIBan_Pol => :p3, "+
	"iIme_Pol => :p4, "+
	"iIBan_Pla => :p5, "+
	"iIme_Pla => :p6, "+
	"iVidPla => :p7, "+
	"iBUL => :p8, "+
	"iEGN => :p9, "+
	"iLNC => :p10, "+
	"iIME_zad_lice => :p11,"+
                "i1Suma => :p12,"+
	"i1VidPla => :p13, "+
	"i1Osn1 => :p14, "+
	"i1Osn2 => :p15, "+
	"i1DOC_Vid => :p16, "+
	"i1DOC_Nomer => :p17, "+
	"i1DOC_DataYYMMDD => to_char( to_date(:p18), 'yymmdd'), "+
	"i1DATA_OtYYMMDD =>  to_char( to_date(:p19), 'yymmdd'), "+
	"i1DATA_DoYYMMDD =>  to_char( to_date(:p20), 'yymmdd'), "+
                "i2Suma => :p21,"+
	"i2VidPla => :p22, "+
	"i2Osn1=> :p23, "+
	"i2Osn2 => :p24, "+
	"i2DOC_Vid => :p25, "+
	"i2DOC_Nomer => :p26, "+
	"i2DOC_DataYYMMDD => to_char( to_date(:p27), 'yymmdd'), "+
	"i2DATA_OtYYMMDD =>  to_char( to_date(:p28), 'yymmdd'), "+
	"i2DATA_DoYYMMDD =>  to_char( to_date(:p29), 'yymmdd'), "+
                "i3Suma => :p30,"+
	"i3VidPla => :p31, "+
	"i3Osn1=> :p32, "+
	"i3Osn2 => :p33, "+
	"i3DOC_Vid => :p34, "+
	"i3DOC_Nomer => :p35, "+
	"i3DOC_DataYYMMDD => to_char( to_date(:p36), 'yymmdd'), "+
	"i3DATA_OtYYMMDD =>  to_char( to_date(:p37), 'yymmdd'), "+
	"i3DATA_DoYYMMDD =>  to_char( to_date(:p38), 'yymmdd'), "+
                "i4Suma => :p39,"+
	"i4VidPla => :p40, "+
	"i4Osn1=> :p41, "+
	"i4Osn2 => :p42, "+
	"i4DOC_Vid => :p43, "+
	"i4DOC_Nomer => :p44, "+
	"i4DOC_DataYYMMDD => to_char( to_date(:p45), 'yymmdd'), "+
	"i4DATA_OtYYMMDD =>  to_char( to_date(:p46), 'yymmdd'), "+
	"i4DATA_DoYYMMDD =>  to_char( to_date(:p47), 'yymmdd'), "+
	"iVidPla50K   => :p48 );end;";
	
db.execSQLEx(sql,
	getDocID(),
	p('PaySys').toString(),
	'',
	p('IBANPol').iban(),
	p('NamePol').toString().substr( 0, 35),
	p('IBANPla').iban(),
	p('Depositor').toString().substr( 0, 35),
	p('OVidPla').toString(),
	p('Bulstat').toString(),
	p('EgnPla').toString(),
	p('LNCPla').toString(),
	p('NamePla').toString(),
	p('Suma1').toString(),
	p('VidPla').toString(),
	p('Reason').toString(),
	p('ReasonEx').toString(),
	p('TypeDoc').toString(),
	p('DocNum').toString(),
	p('DocDate').value(),
	p('FDate').value(),
	p('TDate').value(),
	p('Suma2').toString(),
	p('VidPla2').toString(),
	p('Reason2').toString(),
	p('ReasonEx2').toString(),
	p('TypeDoc2').toString(),
	p('DocNum2').toString(),
	p('DocDate2').value(),
	p('FDate2').value(),
	p('TDate2').value(),
	p('Suma3').toString(),
	p('VidPla3').toString(),
	p('Reason3').toString(),
	p('ReasonEx3').toString(),
	p('TypeDoc3').toString(),
	p('DocNum3').toString(),
	p('DocDate3').value(),
	p('FDate3').value(),
	p('TDate3').value(),
	p('Suma4').toString(),
	p('VidPla4').toString(),
	p('Reason4').toString(),
	p('ReasonEx4').toString(),
	p('TypeDoc4').toString(),
	p('DocNum4').toString(),
	p('DocDate4').value(),
	p('FDate4').value(),
	p('TDate4').value(),
	p('VidPlaNar').toString());

	// за превод от валутна сметка
if( !p('IBANPla').isBgl()){
	var m = doc.iDoc();
	if ( m.r(3).when() ){
		var course_buy  = (m.r(3).iso()=='100'?m.r(3).course('fix'):m.r(3).course('by'));
		var course_sell = (m.r(6).iso()=='100'?m.r(6).course('fix'):m.r(6).course('sel'));
			db.paramsClear();
		db.add('iDocId',getDocID(), db.consts().ORAPARM_INPUT, db.consts().ORATYPE_NUMBER);
		db.add('valBuy',m.r(3).iso(), db.consts().ORAPARM_INPUT, db.consts().ORATYPE_VARCHAR2);
		db.add('sumBuy',m.r(3).qty(), db.consts().ORAPARM_INPUT, db.consts().ORATYPE_NUMBER);
		db.add('courseBuy',course_buy, db.consts().ORAPARM_INPUT, db.consts().ORATYPE_NUMBER);
		db.add('valSell',m.r(6).iso(), db.consts().ORAPARM_INPUT, db.consts().ORATYPE_VARCHAR2);
		db.add('sumSell',m.r(6).qty(), db.consts().ORAPARM_INPUT, db.consts().ORATYPE_NUMBER);
		db.add('courseSell',course_sell, db.consts().ORAPARM_INPUT, db.consts().ORATYPE_NUMBER);
		db.add('CourseOper',null, db.consts().ORAPARM_INPUT, db.consts().ORATYPE_NUMBER);
		db.add('anUniq',p('IBANPla').uniq(), db.consts().ORAPARM_INPUT, db.consts().ORATYPE_NUMBER);
		db.execSQL( 'begin bacb_vdeals.insAccDeal(:iDocId,:valBuy,:sumBuy,:courseBuy,:valSell,:sumSell,:courseSell,:CourseOper,:anUniq); end;' )
			
	}
}

}
true
}

Hello.

Unfortunately, it is hard to say the cause of the problem for sure. Can you send us small testcase with the problem to investigate it in details and provide a solution?

Thanks in advance

Hi,

Is this don’t work for you as test case, you can download it. Have you some problem with download

https://docs.google.com/file/d/0B7fBZ8aCHKJRVWxfWkRGekI1NEk/view

I think too deep recursion (51 levels) exhaust stack at some point,
I made tests with code from GitHub

Into previous version of http://talk.remobjects.com/ there was option to attach file, now I can’t see it

Hello.

Thank you. I have reproduced the problem. Corresponding issue is registered as #65534: “RO.Script: StackOverflowException if compile a script with InnerCompile function”.

Thanks

Is there plans to fix it soon

Thanks

Hello.

Script for .NET parser/compiler is a fairly complex, and it uses recursive calls to parse script expressions.
Given that stack size of IIS-running threads is reduced dramatically it just cannot successfully process a single statement with around 50 string concatenations. Easiest workaround is just to split this expression into 2 smaller.

We have rewritten the Script’s internal code emitter, reducing its need in recursive calls. While we’re doing internal tests of these changes (as they touched around 1200 lines of code lines) we can provide you a pre-built Script dll so you’d be able to test it in your environment with real-world scripts. Contact us via support@ in case you want us to send the dll.

Thanks

Hello,

Thanks for reply,
I will send email at support@ if I need it
for now I will wait