Skip to content

Instantly share code, notes, and snippets.

@syoyo
Created September 25, 2020 10:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save syoyo/2e80c2027278e7cde2107bdb2747d472 to your computer and use it in GitHub Desktop.
Save syoyo/2e80c2027278e7cde2107bdb2747d472 to your computer and use it in GitHub Desktop.
OptiX 7.1 illegal memory access issue
// Issue
// * Allocate and provice insufficient data size(e.g. vertex data) fo GAS input.
// * Call `optixAccelBuild` with "correct" buffer size(e.g. `buildInput.triangleArray.numVertices`)
// * Build GAS against invalid data but no error report at this time
// * Some memory object causes 'illegal memory access' error when freeing(also happens in CUDA driver API)
// How to reprocible
//
// OptiX 7.1 optixHair SDK sample
// Uncomment following in Util.h
//template <typename T>
//void copyToDevice( const std::vector<T>& source, CUdeviceptr destination )
//{
// CUDA_CHECK( cudaMemcpy( reinterpret_cast<void*>( destination ), source.data(), source.size() * sizeof( T ), cudaMemcpyHostToDevice ) );
//}
//
//template <typename T>
//void createOnDevice( const std::vector<T>& source, CUdeviceptr* destination )
//{
// CUDA_CHECK( cudaMalloc( reinterpret_cast<void**>( destination ), source.size() * sizeof( T ) ) );
// copyToDevice( source, *destination );
//}
// => now createOnDevice, copyToDevice allocates the object of `std::vector` object itself(24 bytes in Linux/gcc) and send only 24 bytes of memory to the device.
// Run optixHair will give
```
CUDA call (cudaFree( reinterpret_cast<void*>( m_buffer ) ) ) failed with error: 'an illegal memory access was encountered' (/home/syoyo/local/NVIDIA-OptiX-SDK-7.1.0-linux64-x86_64/SDK/optixHair/Head.cpp:197)
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment