From a0f79867dcc4e58e0753af0644759025ad6e9749 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Thu, 19 Sep 2013 05:59:54 +0200 Subject: [PATCH] src: initialize c-ares task list on env init 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 | 1 + test/simple/test-dns-regress-6244.js | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 test/simple/test-dns-regress-6244.js diff --git a/src/env-inl.h b/src/env-inl.h index a8fcc586034..a53e6626893 100644 --- a/src/env-inl.h +++ b/src/env-inl.h @@ -165,6 +165,7 @@ inline Environment::Environment(v8::Local 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 index 00000000000..ca2957926e2 --- /dev/null +++ b/test/simple/test-dns-regress-6244.js @@ -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() { }));