This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author florin.papa
Recipients florin.papa, pitrou, r.david.murray, rhettinger, skrah, vstinner, zach.ware
Date 2015-10-08.07:06:45
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1444288005.97.0.796360356323.issue25300@psf.upfronthosting.co.za>
In-reply-to
Content
> Is there a runtime cost or does the hardware run the bounds checks in parallel with memory accesses?   Are the bounds set when malloc() is called or elsewhere?  I read the provided links but can't say I fully understand how it works exactly (which memory blocks are protected, where the bounds get set, when the registers are loaded, etc).

There is a runtime cost associated with MPX instrumentation, which is kept to a minimum due to the use of hardware instructions and registers. When "fcheck-pointer-bounds -mmpx" compilation flags are set, instrumentation is enabled for _all_ memory acceses in the code. This means that when you perform a malloc, the pointer bounds will be set inside the malloc call, and then passed on to your variable. Alternatively, you can manually instrument only regions of interest in your code using GCC functions described here [1].

> Also, I'm curious about whether we have direct controls over the bounds.  For example, in a listobject.c or _collections.c object could the bounds be tightened to only include the active data and excluded the unused part of the overallocation?

Please see __bnd_set_ptr_bounds here [1] for bound manipulation. In order to have a better understanding of what happens when using MPX, I suggest writing a simple C program and look at the assembly code generated (MPX instructions and registers begin with bnd). You can use the following steps:

gcc -g -c test.c -O2 -fcheck-pointer-bounds -mmpx
objdump -d -M intel -S test.o


[1] https://gcc.gnu.org/wiki/Intel%20MPX%20support%20in%20the%20GCC%20compiler#Compiler_intrinsics_and_attributes
History
Date User Action Args
2015-10-08 07:06:46florin.papasetrecipients: + florin.papa, rhettinger, pitrou, vstinner, r.david.murray, skrah, zach.ware
2015-10-08 07:06:45florin.papasetmessageid: <1444288005.97.0.796360356323.issue25300@psf.upfronthosting.co.za>
2015-10-08 07:06:45florin.papalinkissue25300 messages
2015-10-08 07:06:45florin.papacreate