src: initialize c-ares task list on env init
authorBen Noordhuis <info@bnoordhuis.nl>
Thu, 19 Sep 2013 03:59:54 +0000 (05:59 +0200)
committerTimothy J Fontaine <tjfontaine@gmail.com>
Fri, 20 Sep 2013 16:39:14 +0000 (09:39 -0700)
Don't forget to initialize the c-ares task tree head when creating a
new Environment.  Oversight from the multi-context work that landed
in commit 756b622.

Fixes #6244.

src/env-inl.h
test/simple/test-dns-regress-6244.js [new file with mode: 0644]

index a8fcc58..a53e662 100644 (file)
@@ -165,6 +165,7 @@ inline Environment::Environment(v8::Local<v8::Context> context)
   v8::HandleScope handle_scope(isolate());
   set_binding_cache_object(v8::Object::New());
   set_module_load_list_array(v8::Array::New());
+  RB_INIT(&cares_task_list_);
 }
 
 inline Environment::~Environment() {
diff --git a/test/simple/test-dns-regress-6244.js b/test/simple/test-dns-regress-6244.js
new file mode 100644 (file)
index 0000000..ca29579
--- /dev/null
@@ -0,0 +1,26 @@
+// Copyright Joyent, Inc. and other Node contributors.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to permit
+// persons to whom the Software is furnished to do so, subject to the
+// following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+// USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+var common = require('../common');
+var dns = require('dns');
+
+// Should not segfault, see #6244.
+dns.resolve4('127.0.0.1', common.mustCall(function() { }));