From 813264add0c3b5fba782e4bb849bffad4701ecf6 Mon Sep 17 00:00:00 2001 From: Crunkle Date: Thu, 8 Aug 2019 12:20:16 +0100 Subject: [PATCH] win: remove try-except outside MSVC MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: https://github.com/libuv/libuv/issues/2407 PR-URL: https://github.com/libuv/libuv/pull/2412 Reviewed-By: Saúl Ibarra Corretgé Reviewed-By: Ben Noordhuis Reviewed-By: Colin Ihrig Reviewed-By: João Reis --- docs/src/fs.rst | 10 ++++++++++ src/win/fs.c | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/docs/src/fs.rst b/docs/src/fs.rst index deaf0b13..aabe49b3 100644 --- a/docs/src/fs.rst +++ b/docs/src/fs.rst @@ -218,6 +218,11 @@ API Equivalent to :man:`preadv(2)`. + .. warning:: + On Windows, under non-MSVC environments (e.g. when GCC or Clang is used + to build libuv), files opened using ``UV_FS_O_FILEMAP`` may cause a fatal + crash if the memory mapped read operation fails. + .. c:function:: int uv_fs_unlink(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) Equivalent to :man:`unlink(2)`. @@ -226,6 +231,11 @@ API Equivalent to :man:`pwritev(2)`. + .. warning:: + On Windows, under non-MSVC environments (e.g. when GCC or Clang is used + to build libuv), files opened using ``UV_FS_O_FILEMAP`` may cause a fatal + crash if the memory mapped write operation fails. + .. c:function:: int uv_fs_mkdir(uv_loop_t* loop, uv_fs_t* req, const char* path, int mode, uv_fs_cb cb) Equivalent to :man:`mkdir(2)`. diff --git a/src/win/fs.c b/src/win/fs.c index 83dfdca9..5dccca77 100644 --- a/src/win/fs.c +++ b/src/win/fs.c @@ -786,10 +786,13 @@ void fs__read_filemap(uv_fs_t* req, struct uv__fd_info_s* fd_info) { int err = 0; size_t this_read_size = MIN(req->fs.info.bufs[index].len, read_size - done_read); +#ifdef _MSC_VER __try { +#endif memcpy(req->fs.info.bufs[index].base, (char*)view + view_offset + done_read, this_read_size); +#ifdef _MSC_VER } __except (fs__filemap_ex_filter(GetExceptionCode(), GetExceptionInformation(), &err)) { @@ -797,6 +800,7 @@ void fs__read_filemap(uv_fs_t* req, struct uv__fd_info_s* fd_info) { UnmapViewOfFile(view); return; } +#endif done_read += this_read_size; } assert(done_read == read_size); @@ -978,10 +982,13 @@ void fs__write_filemap(uv_fs_t* req, HANDLE file, done_write = 0; for (index = 0; index < req->fs.info.nbufs; ++index) { int err = 0; +#ifdef _MSC_VER __try { +#endif memcpy((char*)view + view_offset + done_write, req->fs.info.bufs[index].base, req->fs.info.bufs[index].len); +#ifdef _MSC_VER } __except (fs__filemap_ex_filter(GetExceptionCode(), GetExceptionInformation(), &err)) { @@ -989,6 +996,7 @@ void fs__write_filemap(uv_fs_t* req, HANDLE file, UnmapViewOfFile(view); return; } +#endif done_write += req->fs.info.bufs[index].len; } assert(done_write == write_size);