Optix 6.5 SDK samples "optixDynamicGeometry" error

I have download and build optix 6.5 SDK. Then i run the “optixDynamicGeometry” sample and change the default parameter “LayoutType” from SEPARATE_ACCELS to REBUILD_LAYOUT, it runs error.

The error is showed below.

Creating geometry ... OptiX Error: 'Invalid value (Details: Function "_rtGeometryInstanceGetGeometry" caught exception: Attached object is not a Geometry)'

The code triggers the error is:

Mesh mesh;
    mesh.start_pos = mesh.last_pos = pos0;
    mesh.end_pos   = pos1;
    mesh.move_start_time = 0.0;
    <b>mesh.vertices  = omesh.geom_instance->getGeometry()->queryVariable( "vertex_buffer" )->getBuffer();</b>
    assert( mesh.vertices );
    m_meshes.push_back( mesh );

My running environment is below:
OS: windows 10
GPU:GeForce 2080 ti
Driver version:441.08
IDE:VS 2019

Solved!

The variable “vertex_buffer” was set to GeometryInstanse like below:

optix_mesh.geom_instance[ "vertex_buffer"   ]->setBuffer( buffers.positions   );

So, change the code from

mesh.vertices  = omesh.geom_instance->getGeometry()->queryVariable( "vertex_buffer" )->getBuffer();

to

mesh.vertices  = omesh.geom_instance->queryVariable( "vertex_buffer" )->getBuffer();

Then it runs good.