Raw pointer buffer access detected.

Hi all,
I am getting an exception

Unknown errorwith code:-1
main error occurred with error code -1 and message Unknown error (Details: Function "RTresult _rtContextLaunch3D(RTcontext, unsigned int, RTsize, RTsize, RTsize)" caught exception: Encountered a CUDA error: cudaDriver().CuMemcpyDtoHAsync( dstHost, srcDevice, byteCount, hStream.get() ) returned (700): Illegal address
================================================================================
Backtrace:      
        (0) () +0x711547 
        (1) () +0x70f8fb
        (2) () +0x30fe51  
        (3) () +0x5bb6f3  
        (4) () +0x5bc4c4  
        (5) () +0x1c81bf  
        (6) () +0x1c8946  
        (7) () +0x1c9557  
        (8) () +0x17a92d  
        (9) rtContextLaunch3D() +0x2e5      
        (10) optix::ContextObj::launch(unsigned int, unsigned long, unsigned long, unsigned long) +0x4c
        (11) opal::OpalSceneManager::transmit(int, float, optix::float3, optix::float3) +0x1f3
        (12) seqParallelTxTest(std::unique_ptr<opal::OpalSceneManager, std::default_delete<opal::OpalSceneManager> >) +0x186e
        (13) main() +0x95 
        (14) __libc_start_main() +0xe7
        (15) _start() +0x2a

It seems to be related to some buffer I am accessing but I am not able to debug it after going through my code and print calls. If I set a usageReport as in the samples provided I get this WARNING:Raw pointer buffer access detected

[2][INFO        ] Launch index 77.          
[2][SCENE STAT  ]     Node graph object summary:
[2][SCENE STAT  ]         RTprogram         : 20
[2][SCENE STAT  ]         RTbuffer          : 33
[2][SCENE STAT  ]         RTtexturesampler  : 0
[2][SCENE STAT  ]         RTacceleration    : 3
[2][SCENE STAT  ]         RTgroup           : 1
[2][SCENE STAT  ]         RTgeometrygroup   : 2
[2][SCENE STAT  ]         RTtransform       : 0
[2][SCENE STAT  ]         RTselector        : 0
[2][SCENE STAT  ]         RTgeometryinstance: 6
[2][SCENE STAT  ]         RTgeometry        : 6
[2][SCENE STAT  ]             Total prim: 249
[2][SCENE STAT  ]         RTmaterial        : 2
[2][TIMING      ]     Acceleration update time: 0.0 ms      
[2][MEM USAGE   ]     Buffer GPU memory usage:  
[2][MEM USAGE   ]     |         Category |  Count |  Total MByte |
[2][MEM USAGE   ]     |           buffer |     31 |         81.8 |
[2][MEM USAGE   ]     |          texture |      0 |          0.0 |
[2][MEM USAGE   ]     |      gfx interop |      0 |          0.0 |
[2][MEM USAGE   ]     |     cuda interop |      0 |          0.0 |
[2][MEM USAGE   ]     |   optix internal |     17 |          0.1 |
[2][MEM USAGE   ]     Buffer host memory usage: 0.8 Mbytes
[2][MEM USAGE   ]     WARNING: Raw pointer buffer access detected.
[2][MEM USAGE   ]     Local memory for all threads (CUDA device: 0): 33.1 MBytes

This is something I did not get in previous tests, so it has to be related to some changes I have done in the buffers.
How can I debug this problem? Is there any way to know what is that raw pointer access?
Thanks a lot

The illegal address thing can be about anything, including bugs in OptiX.

If you suspect this to related to your own buffer accesses, check if all your variables and structure offsets are adhering to the CUDA clignment rules. I posted links an recommendations yesterday in this thread: [url]https://devtalk.nvidia.com/default/topic/1037798/optix/optix-time-for-launch/[/url]

Note that pointer arithmetic on OptiX buffers in device code is not allowed.
Always use operator to access a single element of a buffer.
See this post: [url]https://devtalk.nvidia.com/default/topic/1004680/?comment=5130885[/url]

When reporting such issues pleas always include the following system configuration information:
OS version, installed GPU(s), display driver version, OptiX version (major.minor.micro), CUDA toolkit version, host compiler version.

Hi again,

the problem occurs if I use a rtPrintf in my closesHitProgram. Otherwise, everything seems to work OK. The Raw pointer access warning still appears, but results seem to be correct and I do not get the exception.

My system configuration is:
Ubuntu 18.04,
gcc version 7.3.0 (Ubuntu 7.3.0-16ubuntu3)
Target: x86_64-linux-gnu
CUDA Version 9.2.148

[1][SYS INFO    ]
OptiX Version:[5.1.0] Branch:[rel5.1] Build Number:[24109458] CUDA Version:[9.0] 64-bit 2018-05-09
Display driver: 396.37
Devices available:
CUDA device: 0
    0000:01:00.0
    GeForce GTX 970
    SM count: 13
    SM arch: 52
    SM clock: 1240 KHz
    GPU memory: 4040 MB
    TCC driver: 0

I also get the same problem on a Windows 10 machine
with Visual Studio Entreprise 2017, version 15.4.5
Cuda version 9.1

OptiX Version:[5.0.1] Branch:[rel5.0] Build Number:[23705867] CUDA Version:[9.0] 64-bit 2018-03-09
Display driver: 398.36
Devices available:
CUDA device: 0
    GeForce GTX 980M
    SM count: 12
    SM arch: 52
    SM clock: 1126 KHz
    GPU memory: 8192 MB
    TCC driver: 0

Thanks again

Neither CUDA 9.1 nor 9.2 are officially supported by the OptiX 5.1.0 release.
If possible try CUDA 9.0.
There have been some incompatibilities reported with different MSVS 2017 versions, but that should also come with the MSVS 2015 tool chain included.

If that doesn’t help we would need a minimal reproduce which shows the error.

“OptiX Version:[5.0.1]”
Please upgrade to OptiX 5.1.0.

I have “solved” this problem. I do not really know the exact reason. I just want to post it here, just in case someone has some related issue. And to improve my knowledge if an explanation is provided.

The problem seems to be in an atomicExch to the buffer. That is, I declare this buffer (which is correctly created and initialized as I have checked)

rtBuffer<rtBufferId<float2, 3>,1> bufferMinEx;

Afterwards, in the closest hit program I do (some lines are missing, but all the variables used are correctly declared and assigned, including that reflections-1 which is never less than zero)

rtBufferId<float2,3>&  min_e_transmitter =bufferMinE [receiverLaunchIndex.z];
uint3 idmd = make_uint3(reflections-1, hitPayload.faceId, receiverId);

float Eprevx = atomicExch(&min_e_transmitter[idmd].x, E.x);
float Eprevy = atomicExch(&min_e_transmitter[idmd].y, E.y);

Then I get the “WARNING: Raw pointer buffer access detected” and apparently random illegal address expections, depending on my use of rtPrintf

If I just replace the above buffer declaration with two different ones as

rtBuffer<rtBufferId<float, 3>,1> bufferMinEx; 
rtBuffer<rtBufferId<float, 3>,1> bufferMinEy;

and then do

uint3 idmd = make_uint3(reflections-1, hitPayload.faceId, receiverId);
float Eprevx = atomicExch(&bufferMinEx[transmitterId][idmd], E.x);
float Eprevy = atomicExch(&bufferMinEy[transmitterId][idmd], E.y);

Everything is Ok and the “WARNING: Raw pointer buffer access detected” disappears. I have checked the alignment rules and so on. I do not know if I am inadvertently doing pointer arithmetic.