Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ruby - Fixes for Microsoft VC #6761

Closed
wants to merge 0 commits into from
Closed

Conversation

cfis
Copy link

@cfis cfis commented Oct 14, 2019

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.

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@cfis cfis changed the title Fixes for Microsoft VC Ruby - Fixes for Microsoft VC Oct 14, 2019
@cfis
Copy link
Author

cfis commented Oct 14, 2019

@googlebot I signed it!

@googlebot
Copy link

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and then comment @googlebot I fixed it.. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

@cfis cfis force-pushed the master branch 2 times, most recently from 7d45cbd to 1783b9c Compare October 14, 2019 08:01
@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants