fix appveyor installer and build (#224)

* remove exception handler when function returns or throws

* revert to only reserving and not committing memory due to issues

* appveyor builds for release, caches more, only publish artifact once
This commit is contained in:
Mackenzie Clark
2019-03-01 13:16:32 -08:00
committed by GitHub
parent eed1c3b95b
commit bde2022b58
3 changed files with 28 additions and 21 deletions

View File

@ -14,34 +14,36 @@ environment:
cache: cache:
- 'C:\Users\appveyor\.cargo' - 'C:\Users\appveyor\.cargo'
- target
install: install:
- appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe # uncomment these lines if the cache is cleared, or if we must re-install rust for some reason
- rustup-init.exe -yv --default-host %target% # - appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe
# - rustup-init.exe -yv --default-host %target%
- set PATH=%PATH%;%USERPROFILE%\.cargo\bin - set PATH=%PATH%;%USERPROFILE%\.cargo\bin
- rustup default stable-%target%
- rustup update
- rustc -vV - rustc -vV
- cargo -vV - cargo -vV
# Install InnoSetup # Install InnoSetup
- appveyor-retry appveyor DownloadFile https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror/2017-08-22-is.exe - 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- - 2017-08-22-is.exe /VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-
- set PATH="C:\Program Files (x86)\Inno Setup 5";%PATH% - 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: build_script:
- cargo build --verbose - cargo build --release --verbose
test_script: test_script:
- set RUST_BACKTRACE=1 - cargo test --package wasmer-spectests
- cd ./lib/spectests && cargo test -- --test-threads 1 && cd ../..
before_deploy: after_build:
- cd ./src/installer - cd ./src/installer
- iscc wasmer.iss - iscc wasmer.iss
- copy /y .\WasmerInstaller.exe ..\..\WasmerInstaller-%APPVEYOR_REPO_TAG_NAME%.exe - copy /y .\WasmerInstaller.exe ..\..\WasmerInstaller-%APPVEYOR_REPO_TAG_NAME%.exe
- appveyor PushArtifact WasmerInstaller-%APPVEYOR_REPO_TAG_NAME%.exe - appveyor PushArtifact ..\..\WasmerInstaller-%APPVEYOR_REPO_TAG_NAME%.exe
- cd ..\..\
artifacts:
- path: WasmerInstaller-%APPVEYOR_REPO_TAG_NAME%.exe
name: WasmerInstaller.exe
deploy: deploy:
description: 'WasmerInstaller' description: 'WasmerInstaller'

View File

@ -33,7 +33,7 @@ impl Memory {
let protect = protection.to_protect_const(); 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() { if ptr.is_null() {
Err("unable to allocate memory".to_string()) 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 size = round_up_to_page_size(size, page_size::get());
let ptr = unsafe { let ptr = unsafe { VirtualAlloc(ptr::null_mut(), size, MEM_RESERVE, PAGE_NOACCESS) };
VirtualAlloc(
ptr::null_mut(),
size,
MEM_RESERVE | MEM_COMMIT,
PAGE_NOACCESS,
)
};
if ptr.is_null() { if ptr.is_null() {
Err(MemoryCreationError::VirtualMemoryAllocationFailed( Err(MemoryCreationError::VirtualMemoryAllocationFailed(

View File

@ -10,6 +10,7 @@ __declspec(thread) DWORD64 caughtInstructionPointer;
__declspec(thread) PVOID savedStackPointer; __declspec(thread) PVOID savedStackPointer;
__declspec(thread) BOOL exceptionHandlerInstalled = FALSE; __declspec(thread) BOOL exceptionHandlerInstalled = FALSE;
__declspec(thread) BOOL alreadyHandlingException = FALSE; __declspec(thread) BOOL alreadyHandlingException = FALSE;
__declspec(thread) PVOID handle;
void longjmpOutOfHere() { void longjmpOutOfHere() {
longjmp(jmpBuf, 1); longjmp(jmpBuf, 1);
@ -38,6 +39,14 @@ exceptionHandler(struct _EXCEPTION_POINTERS *ExceptionInfo) {
return EXCEPTION_CONTINUE_EXECUTION; return EXCEPTION_CONTINUE_EXECUTION;
} }
static void removeExceptionHandler() {
if (exceptionHandlerInstalled == FALSE) {
return;
}
RemoveVectoredExceptionHandler(handle);
exceptionHandlerInstalled = FALSE;
}
uint8_t callProtected(trampoline_t trampoline, uint8_t callProtected(trampoline_t trampoline,
const struct wasmer_instance_context_t* ctx, const struct wasmer_instance_context_t* ctx,
const struct func_t* func, const struct func_t* func,
@ -48,7 +57,7 @@ uint8_t callProtected(trampoline_t trampoline,
// install exception handler // install exception handler
if (exceptionHandlerInstalled == FALSE) { if (exceptionHandlerInstalled == FALSE) {
exceptionHandlerInstalled = TRUE; exceptionHandlerInstalled = TRUE;
AddVectoredExceptionHandler(CALL_FIRST, exceptionHandler); handle = AddVectoredExceptionHandler(CALL_FIRST, exceptionHandler);
} }
// jmp jmp jmp! // jmp jmp jmp!
@ -60,6 +69,8 @@ uint8_t callProtected(trampoline_t trampoline,
out_result->code = 0; out_result->code = 0;
out_result->exceptionAddress = 0; out_result->exceptionAddress = 0;
out_result->instructionPointer = 0; out_result->instructionPointer = 0;
removeExceptionHandler();
return TRUE; return TRUE;
} }
@ -70,5 +81,6 @@ uint8_t callProtected(trampoline_t trampoline,
caughtExceptionAddress = 0; caughtExceptionAddress = 0;
caughtInstructionPointer = 0; caughtInstructionPointer = 0;
removeExceptionHandler();
return FALSE; return FALSE;
} }