You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Working with raw buffers is extremely unsafe because all typed loads/store assume alignment, but there's no way to check for and adjust alignment short of retrieving the baseAddress' bitPattern.
Some folks have insisted that specifying the alignment at buffer allocation time mitigates some of the unsafety. I completely disagree. Alignment needs to be ensured at the point that the buffer is used, not when it is allocated.
We should have an API that allows the user to ask for a raw slice of the raw buffer while rounding up to the nearest alignment for T. This API could return a new type, say
RawMemorySlice<T>
which can be used to reinterpret the aligned raw buffer slice as T without binding/rebinding the buffer's memory.
The text was updated successfully, but these errors were encountered:
This should be handled when we introduce something like a ReinterpretedPointer<T> type. We should be able to easily ask for an aligned buffer. There's no need for a separate bug for this.
Additional Detail from JIRA
md5: 2969ba87c3e5b85a010514753e681262
Issue Description:
Working with raw buffers is extremely unsafe because all typed loads/store assume alignment, but there's no way to check for and adjust alignment short of retrieving the baseAddress' bitPattern.
Some folks have insisted that specifying the alignment at buffer allocation time mitigates some of the unsafety. I completely disagree. Alignment needs to be ensured at the point that the buffer is used, not when it is allocated.
We should have an API that allows the user to ask for a raw slice of the raw buffer while rounding up to the nearest alignment for T. This API could return a new type, say
which can be used to reinterpret the aligned raw buffer slice as T without binding/rebinding the buffer's memory.
The text was updated successfully, but these errors were encountered: