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 feature - force memory allocation to be above 4GB (for 64bit only) #298

Closed
mikecopperwhite opened this issue Jan 29, 2017 · 2 comments
Closed

Comments

@mikecopperwhite
Copy link
Collaborator

mikecopperwhite commented Jan 29, 2017

Add a persisted entry to the options menu to the 64bit version of GSN only. If enabled all memory allocations are forced to be above 4GB to help test for 64bit pointer truncation bugs in filters. This will require a restart of GSN before it has any effect.

Adding a similar feature to the 32bit version to force allocations above 2GB to test large address aware 32bit filters is less useful because it limits the total memory available and graphs may fail to run if some filters are not flagged as large address aware in the linker flags. I have no need for this feature personally either.
https://msdn.microsoft.com/en-us/library/wz223b1z.aspx

64bit pointer truncation bugs are hard to find because they only are apparent when the pointer happens to be an address above 4GB.

This technique https://randomascii.wordpress.com/2012/02/14/64-bit-made-easy/ seems to work best for forcing allocated memory above 4GB. The blog author has given permission for his code to be used with a credit. We just need to run a small piece of code in GSN at startup.

There are a few different techniques to force allocated memory to be > 4GB. There is a global AllocationPreference Windows registry entry but that is global in effect, requires a reboot and can cause slow system performance and system instability if you have buggy 64bit apps installed.

Code addresses are less likely to be affected by pointer truncation. I'm not aware of any techniques for controlling the base address when loading a DLL or creating a COM object instance. There is a 'high entropy VA' linker flag which loads DLLs high in the 64bit memory space but this may be ignored if there are DLLs in the process that flag that they can't be relocated or don't support address space randomization. Not sure GSN can do much to help here.
https://msdn.microsoft.com/en-us/library/bb384887.aspx
https://msdn.microsoft.com/en-us/library/dn195771.aspx

I'm not aware of any techniques for controlling the address of the stack to force this above 4GB. To be of any use we'd also need to the same for threads created by filters and DirectShow itself.

@mikecopperwhite
Copy link
Collaborator Author

Option reserves below 2GB on 32bit builds for testing LargeAddressAware code
Option reserves below 4GB on 32bit builds for testing pointer truncation in 64bit code
The 32bit and 64bit options are stored under separate registry key as have quite different effects.

@mikecopperwhite
Copy link
Collaborator Author

The 32bit reserve below 2GB option on the 32bit application can break filters quite easily, perhaps because the filter DLLs aren't flagged as large address aware. The corresponding 64bit option is less likely to break filters unless there are actual pointer truncation bugs.

On my system switching on reserve below 2GB stops the Video Renderer from instantiating due to lack of memory. The Enhanced Video Renderer works fine though.

Perhaps this could be flagged on the UI more emphatically as a 'dangerous' diagnostic feature that may break filters (by design).

mikecopperwhite added a commit that referenced this issue Apr 20, 2017
New option to reserve memory below 4GB (for 64bit version) or 2GB (for 32bit version)
Source: Bruce Dawson https://randomascii.wordpress.com/2012/02/14/64-bit-made-easy/ - used with permission
mikecopperwhite added a commit that referenced this issue Apr 20, 2017
…rformance test dialog. Previous revision was also for this change - log message re issue #298 is wrong.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant