From 5449f7294711e7f478c1107c5a9dda1a2671701c Mon Sep 17 00:00:00 2001 From: Oguz Bastemur Date: Thu, 22 Dec 2016 17:47:18 +0100 Subject: [PATCH] asmjs: anonymous function crash --- lib/Jsrt/ChakraCore.h | 3 ++- lib/Runtime/Language/AsmJsModule.cpp | 5 +++++ test/AsmJs/bugGH2270.js | 11 +++++++++++ test/AsmJs/rlexe.xml | 3 +++ 4 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 test/AsmJs/bugGH2270.js diff --git a/lib/Jsrt/ChakraCore.h b/lib/Jsrt/ChakraCore.h index f4229bd1ce7..18aedbf33a8 100644 --- a/lib/Jsrt/ChakraCore.h +++ b/lib/Jsrt/ChakraCore.h @@ -163,6 +163,7 @@ JsGetModuleHostInfo( _In_ JsModuleHostInfoKind moduleHostInfo, _Outptr_result_maybenull_ void** hostInfo); +#ifdef CHAKRACOREBUILD_ /// /// Called by the runtime to load the source code of the serialized script. /// @@ -493,5 +494,5 @@ CHAKRA_API _In_ JsSourceContext sourceContext, _In_ JsValueRef sourceUrl, _Out_ JsValueRef *result); - +#endif // CHAKRACOREBUILD_ #endif // _CHAKRACORE_H_ diff --git a/lib/Runtime/Language/AsmJsModule.cpp b/lib/Runtime/Language/AsmJsModule.cpp index 1873a2d61da..a91a5383363 100644 --- a/lib/Runtime/Language/AsmJsModule.cpp +++ b/lib/Runtime/Language/AsmJsModule.cpp @@ -1080,6 +1080,11 @@ namespace Js AsmJsFunc* AsmJsModuleCompiler::CreateNewFunctionEntry( ParseNode* pnodeFnc ) { PropertyName name = ParserWrapper::FunctionName( pnodeFnc ); + if ( !name ) + { + return nullptr; + } + GetByteCodeGenerator()->AssignPropertyId(name); AsmJsFunc* func = Anew( &mAllocator, AsmJsFunc, name, pnodeFnc, &mAllocator, mCx->scriptContext ); if( func ) diff --git a/test/AsmJs/bugGH2270.js b/test/AsmJs/bugGH2270.js new file mode 100644 index 00000000000..4ad8a704778 --- /dev/null +++ b/test/AsmJs/bugGH2270.js @@ -0,0 +1,11 @@ +//------------------------------------------------------------------------------------------------------- +// Copyright (C) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information. +//------------------------------------------------------------------------------------------------------- + +(function() { + "use asm"; + (function(){}); +})(); + +print("Pass"); diff --git a/test/AsmJs/rlexe.xml b/test/AsmJs/rlexe.xml index 79533d18b8d..ddf0679696f 100644 --- a/test/AsmJs/rlexe.xml +++ b/test/AsmJs/rlexe.xml @@ -813,5 +813,8 @@ vardeclnorhs.baseline -testtrace:asmjs -maic:1 + + bugGH2270.js +