Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Solaris directory watching resource leak / segfault bug fix #654

Closed
wants to merge 3 commits into from

2 participants

@ashaffer

Libuv doesn't properly clean up directory watches on solaris if they are in the PORT_LOADED state. I encountered this problem in node.js. To reproduce it, execute the following in a node console on solaris:

fs = require('fs');
h = fs.watch(<directory>);
h.close();

Then in a separate shell (without closing the node shell, of course) touch the folder you watched and you should get a seg fault.

@bnoordhuis

The change itself LGTM but would it be possible to add a regression test?

@ashaffer

Added.

@bnoordhuis

Thanks. Can you sign the CLA? I believe you're not on the list yet.

@ashaffer

Ok, signed.

@bnoordhuis

Thanks Andrew, landed in 4997738. It'll be part of the next v0.8 node release.

@bnoordhuis bnoordhuis closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 13, 2012
  1. @ashaffer

    Update src/unix/sunos.c

    ashaffer authored
  2. @ashaffer

    Update test/test-fs-event.c

    ashaffer authored
  3. @ashaffer

    Update test/test-list.h

    ashaffer authored
This page is out of date. Refresh to see the latest.
Showing with 34 additions and 1 deletion.
  1. +1 −1  src/unix/sunos.c
  2. +31 −0 test/test-fs-event.c
  3. +2 −0  test/test-list.h
View
2  src/unix/sunos.c
@@ -376,7 +376,7 @@ int uv_fs_event_init(uv_loop_t* loop,
void uv__fs_event_close(uv_fs_event_t* handle) {
- if (handle->fd == PORT_FIRED) {
+ if (handle->fd == PORT_FIRED || handle->fd == PORT_LOADED) {
port_dissociate(handle->loop->fs_fd, PORT_SOURCE_FILE, (uintptr_t)&handle->fo);
}
handle->fd = PORT_DELETED;
View
31 test/test-fs-event.c
@@ -296,6 +296,37 @@ TEST_IMPL(fs_event_watch_file_current_dir) {
return 0;
}
+TEST_IMPL(fs_event_no_callback_after_close) {
+ uv_loop_t* loop = uv_default_loop();
+ int r;
+
+ /* Setup */
+ remove("watch_dir/file1");
+ remove("watch_dir/");
+ create_dir(loop, "watch_dir");
+ create_file(loop, "watch_dir/file1");
+
+ r = uv_fs_event_init(loop,
+ &fs_event,
+ "watch_dir/file1",
+ fs_event_cb_file,
+ 0);
+ ASSERT(r != -1);
+
+ uv_close((uv_handle_t*)&fs_event, close_cb);
+ touch_file(loop, "watch_dir/file1");
+ uv_run(loop);
+
+ ASSERT(fs_event_cb_called == 0);
+ ASSERT(close_cb_called == 1);
+
+ /* Cleanup */
+ remove("watch_dir/file1");
+ remove("watch_dir/");
+
+ MAKE_VALGRIND_HAPPY();
+ return 0;
+}
TEST_IMPL(fs_event_no_callback_on_close) {
uv_loop_t* loop = uv_default_loop();
View
2  test/test-list.h
@@ -176,6 +176,7 @@ TEST_DECLARE (fs_event_watch_dir)
TEST_DECLARE (fs_event_watch_file)
TEST_DECLARE (fs_event_watch_file_twice)
TEST_DECLARE (fs_event_watch_file_current_dir)
+TEST_DECLARE (fs_event_no_callback_after_close)
TEST_DECLARE (fs_event_no_callback_on_close)
TEST_DECLARE (fs_event_immediate_close)
TEST_DECLARE (fs_event_close_with_pending_event)
@@ -446,6 +447,7 @@ TASK_LIST_START
TEST_ENTRY (fs_event_watch_file)
TEST_ENTRY (fs_event_watch_file_twice)
TEST_ENTRY (fs_event_watch_file_current_dir)
+ TEST_ENTRY (fs_event_no_callback_after_close)
TEST_ENTRY (fs_event_no_callback_on_close)
TEST_ENTRY (fs_event_immediate_close)
TEST_ENTRY (fs_event_close_with_pending_event)
Something went wrong with that request. Please try again.