hxcpp icon indicating copy to clipboard operation
hxcpp copied to clipboard

LessThanEq change causes hanging process

Open AlexHaxe opened this issue 5 years ago • 5 comments

I noticed that when compiling formatter with hxcpp 4.0.19 or git version the resulting binary will use 100% CPU and execution will not reach main function.

I managed to drill it down to the following sample code:

class Main {
	static function main() {
		new haxeparser.HaxeLexer(null, "foo");
	}
}

use Haxe 4.0 rc3 - haxeparser git - hxparse git

When launching binary loops endlessly in LexEngine::cunion. It uses <= on two Int values located inside a structure, which apparently uses code changed by https://github.com/HaxeFoundation/hxcpp/commit/74464027c02556104e6d50aced5adafdeb1dde73 As soon as I reverse those changes everything runs fine.

AlexHaxe avatar Jun 28 '19 23:06 AlexHaxe

Which ints? Is one of them a Dynamic or Null<Int> or similar?

hughsando avatar Jun 29 '19 01:06 hughsando

if( a.min <= b.min ) { LexEngine.hx#L308 gets transpiled into

HXLINE( 308)			if (hx::IsLessEq( a->__Field(HX_("min",92,11,53,00),hx::paccDynamic),b->__Field(HX_("min",92,11,53,00),hx::paccDynamic) )) {

a and b are elements of private typedef Charset = Array<{ min : Int, max : Int }>; LexEngine.hx#L440

AlexHaxe avatar Jun 29 '19 06:06 AlexHaxe

(While there's a hxcpp problem here for sure, this should also be optimized in hxparse...)

Simn avatar Jun 29 '19 06:06 Simn

Yes on both counts.

On Sat, Jun 29, 2019 at 2:39 PM Simon Krajewski [email protected] wrote:

(While there's a hxcpp problem here for sure, this should also be optimized in hxparse...)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/HaxeFoundation/hxcpp/issues/822?email_source=notifications&email_token=AAMWTVSUQ6URH2WHIS23I2TP437TFA5CNFSM4H4JB2JKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODY3S4WQ#issuecomment-506932826, or mute the thread https://github.com/notifications/unsubscribe-auth/AAMWTVVS5T5EYZDN2QMNZQTP437TFANCNFSM4H4JB2JA .

hughsando avatar Jun 29 '19 08:06 hughsando

This should fix it: https://github.com/HaxeFoundation/hxcpp/commit/8f4396940a8d580b35bc10a9557c0c35581a2900

This should show the error:

   static function getAnon(val:Int) return { val:val };
   static function getDynamicAnon(val:Dynamic) : Dynamic return { val : val};

   public static function main()
   {
      var a = getDynamicAnon(2);
      var b = getAnon(1);
      trace( Std.string(b.val)+"<="+Std.string(a.val));
      trace(b.val<=a.val);
   }

hughsando avatar Jul 07 '19 03:07 hughsando