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.
The two commits fix a MSCV compiler error, compiler warning and crash.
Commit 63073d3 - MSCV does not support variable length arrays (VLAs), so instead use alloca when using MSVC.
Commit 1783b9c - Usage of the VOIDPTR_AT macro results in compiler error (or warning) C4146, "unary minus operator applied to unsigned type, result still unsigned". If you manually expand the macro, it becomes (for line 1162):
VOIDPTR_AT(msg, -sizeof(upb_msg_internal))
(void*)(char*)(msg, (int)-sizeof(upb_msg_internal));
size_of returns size_t, which in MSVC is defined as typedef unsigned __int64 size_t. So you are taking the negative value of an unsigned type.
This change simply stops using the macro removing the (int)-sizeof bit causing this issue.
In addition, before this change I would randomly (but frequently) get segmentation faults when loading ruby generated protobuf classes (so just requiring the ruby files, not processing any data). The error was always a pointer at 0xFFFFFFFF. This change fixed the error.
Note I did try and go back to replicate the original crash (I have been running with this patch for about a week), but failed to do.