Skip to content

  • Projects
  • Groups
  • Snippets
  • Help
  • This project
    • Loading...
  • Sign in / Register
S
swiftshader
  • Project
    • Overview
    • Details
    • Activity
    • Cycle Analytics
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Charts
  • Issues 0
    • Issues 0
    • List
    • Board
    • Labels
    • Milestones
  • Merge Requests 0
    • Merge Requests 0
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Charts
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Chen Yisong
  • swiftshader
  • Repository

Switch branch/tag
  • swiftshader
  • src
  • System
  • Memory.cpp
Find file
BlameHistoryPermalink
  • Nicolas Capens's avatar
    Fix reporting VK_ERROR_OUT_OF_HOST_MEMORY · 4cd9767e
    Nicolas Capens authored Jul 11, 2019
    The regular C++ operator new calls the installed new-handler on
    out-of-memory, which by default throws std::bad_alloc when exception
    handling is enabled, or aborts when not. Under no circumstance is null
    returned. Furthermore, LLVM installs a new-handler itself, which also
    ends up aborting the program.
    
    Using the std::nothrow version of new does not work because it still
    calls the new-handler. Installing our own non-fatal new-handler is also
    futile because the new operator will re-attempt allocation.
    
    Setting the new-handler to nullptr will cause the nothrow version of new
    to return null on out-of-memory. However, this still overrides any new
    handler which the application may have installed, or, can be overridden
    by the application again at any point.
    
    Instead just use legacy malloc(), which is guaranteed to never throw and
    returns null on failure. This is already checked for by vk::Create() and
    it reports VK_ERROR_OUT_OF_HOST_MEMORY.
    
    Bug: b/137093675
    Change-Id: I6c9ccf738cfd21af9e52382d6e7755071d613d39
    Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/34028
    Presubmit-Ready: Nicolas Capens <nicolascapens@google.com>
    Reviewed-by: 's avatarBen Clayton <bclayton@google.com>
    Reviewed-by: 's avatarChris Forbes <chrisforbes@google.com>
    Tested-by: 's avatarNicolas Capens <nicolascapens@google.com>
    Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
    4cd9767e
Memory.cpp 3.58 KB
EditWeb IDE
×

Replace Memory.cpp

Attach a file by drag & drop or click to upload


Cancel
A new branch will be created in your fork and a new merge request will be started.