diff --git a/.appveyor.yml b/.appveyor.yml index 4ec05f8c7d5..2a67567e476 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -14,34 +14,36 @@ environment: cache: - 'C:\Users\appveyor\.cargo' + - target install: - - appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe - - rustup-init.exe -yv --default-host %target% + # uncomment these lines if the cache is cleared, or if we must re-install rust for some reason + # - appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe + # - rustup-init.exe -yv --default-host %target% - set PATH=%PATH%;%USERPROFILE%\.cargo\bin + - rustup default stable-%target% + - rustup update - rustc -vV - cargo -vV # Install InnoSetup - appveyor-retry appveyor DownloadFile https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror/2017-08-22-is.exe - 2017-08-22-is.exe /VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP- - set PATH="C:\Program Files (x86)\Inno Setup 5";%PATH% +# uncomment to RDP to appveyor +# - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) build_script: - - cargo build --verbose + - cargo build --release --verbose test_script: - - set RUST_BACKTRACE=1 - - cd ./lib/spectests && cargo test -- --test-threads 1 && cd ../.. + - cargo test --package wasmer-spectests -before_deploy: +after_build: - cd ./src/installer - iscc wasmer.iss - copy /y .\WasmerInstaller.exe ..\..\WasmerInstaller-%APPVEYOR_REPO_TAG_NAME%.exe - - appveyor PushArtifact WasmerInstaller-%APPVEYOR_REPO_TAG_NAME%.exe - -artifacts: - - path: WasmerInstaller-%APPVEYOR_REPO_TAG_NAME%.exe - name: WasmerInstaller.exe + - appveyor PushArtifact ..\..\WasmerInstaller-%APPVEYOR_REPO_TAG_NAME%.exe + - cd ..\..\ deploy: description: 'WasmerInstaller' diff --git a/lib/runtime-core/src/sys/windows/memory.rs b/lib/runtime-core/src/sys/windows/memory.rs index 3ca86bec935..d47388170d2 100644 --- a/lib/runtime-core/src/sys/windows/memory.rs +++ b/lib/runtime-core/src/sys/windows/memory.rs @@ -33,7 +33,7 @@ impl Memory { let protect = protection.to_protect_const(); - let ptr = unsafe { VirtualAlloc(ptr::null_mut(), size, MEM_RESERVE | MEM_COMMIT, protect) }; + let ptr = unsafe { VirtualAlloc(ptr::null_mut(), size, MEM_RESERVE, protect) }; if ptr.is_null() { Err("unable to allocate memory".to_string()) @@ -57,14 +57,7 @@ impl Memory { let size = round_up_to_page_size(size, page_size::get()); - let ptr = unsafe { - VirtualAlloc( - ptr::null_mut(), - size, - MEM_RESERVE | MEM_COMMIT, - PAGE_NOACCESS, - ) - }; + let ptr = unsafe { VirtualAlloc(ptr::null_mut(), size, MEM_RESERVE, PAGE_NOACCESS) }; if ptr.is_null() { Err(MemoryCreationError::VirtualMemoryAllocationFailed( diff --git a/lib/win-exception-handler/exception_handling/exception_handling.c b/lib/win-exception-handler/exception_handling/exception_handling.c index 3284034cc23..eb45b204de0 100644 --- a/lib/win-exception-handler/exception_handling/exception_handling.c +++ b/lib/win-exception-handler/exception_handling/exception_handling.c @@ -10,6 +10,7 @@ __declspec(thread) DWORD64 caughtInstructionPointer; __declspec(thread) PVOID savedStackPointer; __declspec(thread) BOOL exceptionHandlerInstalled = FALSE; __declspec(thread) BOOL alreadyHandlingException = FALSE; +__declspec(thread) PVOID handle; void longjmpOutOfHere() { longjmp(jmpBuf, 1); @@ -38,6 +39,14 @@ exceptionHandler(struct _EXCEPTION_POINTERS *ExceptionInfo) { return EXCEPTION_CONTINUE_EXECUTION; } +static void removeExceptionHandler() { + if (exceptionHandlerInstalled == FALSE) { + return; + } + RemoveVectoredExceptionHandler(handle); + exceptionHandlerInstalled = FALSE; +} + uint8_t callProtected(trampoline_t trampoline, const struct wasmer_instance_context_t* ctx, const struct func_t* func, @@ -48,7 +57,7 @@ uint8_t callProtected(trampoline_t trampoline, // install exception handler if (exceptionHandlerInstalled == FALSE) { exceptionHandlerInstalled = TRUE; - AddVectoredExceptionHandler(CALL_FIRST, exceptionHandler); + handle = AddVectoredExceptionHandler(CALL_FIRST, exceptionHandler); } // jmp jmp jmp! @@ -60,6 +69,8 @@ uint8_t callProtected(trampoline_t trampoline, out_result->code = 0; out_result->exceptionAddress = 0; out_result->instructionPointer = 0; + + removeExceptionHandler(); return TRUE; } @@ -70,5 +81,6 @@ uint8_t callProtected(trampoline_t trampoline, caughtExceptionAddress = 0; caughtInstructionPointer = 0; + removeExceptionHandler(); return FALSE; }