Skip to content

Commit

Permalink
mapped_file_handle::read() and write() was not detecting when VA spac…
Browse files Browse the repository at this point in the history
…e had been exhausted, and was incorrectly segfaulting the process rather than returning errc::not_enough_memory.
  • Loading branch information
ned14 committed Feb 17, 2021
1 parent d23bb97 commit 74e7106
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions include/llfio/v2.0/mapped_file_handle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,14 @@ class LLFIO_DECL mapped_file_handle : public file_handle
}
LLFIO_HEADERS_ONLY_VIRTUAL_SPEC io_result<buffers_type> _do_read(io_request<buffers_type> reqs, deadline d = deadline()) noexcept override
{
if(_mh.address() == nullptr)
{
OUTCOME_TRY(auto &&length, _sh.length());
if(length > 0)
{
return errc::not_enough_memory; // reserve() failed probably due to VMA exhaustion
}
}
return _mh.read(reqs, d);
}
LLFIO_HEADERS_ONLY_VIRTUAL_SPEC io_result<const_buffers_type> _do_write(io_request<const_buffers_type> reqs, deadline d = deadline()) noexcept override
Expand Down Expand Up @@ -229,6 +237,14 @@ class LLFIO_DECL mapped_file_handle : public file_handle
}
return reqs.buffers;
}
if(_mh.address() == nullptr)
{
OUTCOME_TRY(auto &&length, _sh.length());
if(length > 0)
{
return errc::not_enough_memory; // reserve() failed probably due to VMA exhaustion
}
}
return _mh.write(reqs, d);
}

Expand Down

0 comments on commit 74e7106

Please sign in to comment.