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

New define in mem.c DEBUG_USE_AFTER_FREE_ON_WINDOWS which helps catch use-after-free issues in a debugger on Windows #737

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

joedrago
Copy link
Collaborator

This is a low priority PR, but this was how I successfully reproduced PR #736 in a debugger, so I figured it would be good to have it checked-in, in case we need to repro use-after-free issues in the future.

… use-after-free issues in a debugger on Windows
{
void * ptr;
size_t originalSize;
size_t size;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional: If I understand the MSDN pages for VirtualAlloc() and VirtualProtect() correctly, we can just pass the original size to these two functions and they will round the size up to the next page boundary for us.

Copy link
Collaborator

@wantehchang wantehchang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Joe:

This PR is not needed if AddressSanitizer is available. I just installed Visual Studio 2019 Community Edition on a new Windows 10 computer last weekend, and I saw AddressSanitizer in the installer. Here is the MSDN page:
https://docs.microsoft.com/en-us/cpp/sanitizers/asan?view=msvc-160

I will let you decide if you want to merge this PR.

@wantehchang
Copy link
Collaborator

Here is a screen shot of Visual Studio installer showing "C++ AddressSanitizer" under "Desktop development with C++":

Visual Studio Installer 9_7_2021 3_23_32 PM

@joedrago
Copy link
Collaborator Author

joedrago commented Sep 7, 2021

This PR can sit for a while. I'd want to make sure I could catch #736 in the debugger when using this VS feature first.

One advantage of this PR is it doesn't require any special VS magic; simply building against the Win32 API and it busts in the right spot.

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

Successfully merging this pull request may close these issues.

2 participants