Skip to content

DeviceBuffer::reserve()/upload() keep capacity without storage after a failed allocation #390

Open

Description

@jeffamstutz

Problem

CudaMemoryAllocation(size_t bytes) (devices/rtx/device/utility/MemoryAllocation.cpp) sets m_bytes and then calls cudaMalloc without checking the result. When the allocation fails:

  • DeviceBuffer::bytes() reports the requested size, but ptr() is null.
  • The next reserve() / upload() for the same size or smaller sees enough capacity and skips allocating, so the buffer stays null and never recovers.
  • upload() goes on to cudaMemcpy into a null pointer.
  • The cudaErrorMemoryAllocation stays pending, so the next CUDA call that checks errors (often unrelated) reports it.

Affected callers on next_release

DeviceBuffer::reserve() / upload() in, among others:

  • frame/Frame.cu (accumulation, denoise and trim buffers)
  • frame/Denoiser.cu
  • geometry/ComputeTangent.cu
  • geometry/IsosurfaceBricks.cu, geometry/Isosurface.cpp
  • geometry/Sphere.cu
  • array/Array.cpp (staging)
  • utility/CDF.cu, utility/HostDeviceArray.h

Suggested direction

Add a checked reserve that reports failures, and move these callers to it. On failure it resets the buffer, consumes the runtime error and returns a cudaError_t. Each caller can then fail its own object or frame with a message instead of continuing with a null pointer. PR #387 adds this pattern for the geometry preparation sites; this issue covers the code that predates it.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions