Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't use try-except outside MSVC #2412

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions docs/src/fs.rst
Expand Up @@ -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)`.
Expand All @@ -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)`.
Expand Down
8 changes: 8 additions & 0 deletions src/win/fs.c
Expand Up @@ -786,17 +786,21 @@ 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)) {
SET_REQ_WIN32_ERROR(req, err);
UnmapViewOfFile(view);
return;
}
#endif
done_read += this_read_size;
}
assert(done_read == read_size);
Expand Down Expand Up @@ -978,17 +982,21 @@ 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)) {
SET_REQ_WIN32_ERROR(req, err);
UnmapViewOfFile(view);
return;
}
#endif
done_write += req->fs.info.bufs[index].len;
}
assert(done_write == write_size);
Expand Down