Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Exception handling is broken for visualcpp toolchain, if using C++ source files.
The issue is the the
/EHsc
cxx flag. From MSDN /EH docs, this 'tells the compiler to assume that functions declared as extern "C" never throw a C++ exception.'The problem with that is that all of the functions in vm.c are extern "C". See this block from
mrb_funcall_with_block
cl.exe
(Microsoft C/C++ Version 18.00.31101 for x86) looks at this block, sees thatmrb_funcall_with_block
isextern "C"
and assumes - like it's been told - that this function cannot throw a C++ exception. The exception handler is then removed from the generated code.However, MRB_THROW is defined to throw an exception with the cxx_abi is enabled. The effect is that at runtime an exception is thrown out of this block. The stack is not processed, and mrb->jmp is not cleared.
Changing the flag to
/EHs
allows the exception handling to work as intended.I have run
ruby ./minirake test
with both GCC & VisualCPP, and all tests pass with this change.I don't have a test written for this change, but you can see my usage here: