@@ -675,6 +675,67 @@ struct Wasm_test : public beast::unit_test::suite
675675 }
676676 }
677677
678+ void
679+ testInfiniteLoop ()
680+ {
681+ testcase (" infinite loop" );
682+
683+ using namespace test ::jtx;
684+ Env env{*this };
685+
686+ /*
687+ void
688+ loop()
689+ {
690+ int volatile x = 0;
691+ while (1)
692+ x++;
693+ }
694+ */
695+ static std::string const infiniteWasmHex =
696+ " 0061736d01000000010401600000030302000005030100020638097f004180080b"
697+ " 7f004180"
698+ " 080b7f004180080b7f00418088040b7f004180080b7f00418088040b7f00418080"
699+ " 080b7f00"
700+ " 41000b7f0041010b07a8010c066d656d6f72790200115f5f7761736d5f63616c6c"
701+ " 5f63746f"
702+ " 72730000046c6f6f7000010c5f5f64736f5f68616e646c6503000a5f5f64617461"
703+ " 5f656e64"
704+ " 03010b5f5f737461636b5f6c6f7703020c5f5f737461636b5f6869676803030d5f"
705+ " 5f676c6f"
706+ " 62616c5f6261736503040b5f5f686561705f6261736503050a5f5f686561705f65"
707+ " 6e640306"
708+ " 0d5f5f6d656d6f72795f6261736503070c5f5f7461626c655f6261736503080a27"
709+ " 0202000b"
710+ " 220041fc87044100360200034041fc870441fc870428020041016a3602000c000b"
711+ " 000b007f"
712+ " 0970726f647563657273010c70726f6365737365642d62790105636c616e675f31"
713+ " 392e312e"
714+ " 352d776173692d73646b202868747470733a2f2f6769746875622e636f6d2f6c6c"
715+ " 766d2f6c"
716+ " 6c766d2d70726f6a65637420616234623561326462353832393538616631656533"
717+ " 30386137"
718+ " 3930636664623432626432343732302900490f7461726765745f66656174757265"
719+ " 73042b0f"
720+ " 6d757461626c652d676c6f62616c732b087369676e2d6578742b0f726566657265"
721+ " 6e63652d"
722+ " 74797065732b0a6d756c746976616c7565" ;
723+ auto const wasmStr = boost::algorithm::unhex (infiniteWasmHex);
724+ Bytes wasm (wasmStr.begin (), wasmStr.end ());
725+ std::string const funcName (" infinite" );
726+ TestHostFunctions hfs (env, 0 );
727+
728+ {
729+ // f32 set constant, opcode disabled exception
730+ auto const re =
731+ runEscrowWasm (wasm, funcName, {}, &hfs, 1'000'000 , env.journal );
732+ if (BEAST_EXPECT (!re.has_value ()))
733+ {
734+ BEAST_EXPECT (re.error () == tecFAILED_PROCESSING);
735+ }
736+ }
737+ }
738+
678739 void
679740 run () override
680741 {
@@ -700,6 +761,7 @@ struct Wasm_test : public beast::unit_test::suite
700761
701762 testCodecovWasm ();
702763 testDisabledFloat ();
764+ testInfiniteLoop ();
703765
704766 // perfTest();
705767 }
0 commit comments