Segmentation Fault (4.2.6)
Closed this issue · 8 comments
Hi!
When trying to do a SRV lookup (can post code if necessary), on 4.2.6, I occasionally get a Segmentation Fault with no further explanation resulting in the app crashing.
Tried updating node to 6.2.2, now getting the following during build:
fes_1 | ../deps/cares/src/ares_parse_txt_reply.c: In function 'ares_parse_txt_reply':
fes_1 | ../deps/cares/src/ares_parse_txt_reply.c:153:23: error: 'struct ares_txt_reply' has no member named 'record_start'
fes_1 | txt_curr->record_start = strptr == aptr;
fes_1 | ^
fes_1 | make[1]: *** [Release/obj.target/cares/deps/cares/src/ares_parse_txt_reply.o] Error 1
fes_1 | make[1]: Leaving directory `/var/frontend/node_modules/cares/build'
fes_1 | gyp ERR! build error
fes_1 | gyp ERR! stack Error: `make` failed with exit code: 2
fes_1 | gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
fes_1 | gyp ERR! stack at emitTwo (events.js:106:13)
fes_1 | gyp ERR! stack at ChildProcess.emit (events.js:191:7)
fes_1 | gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:204:12)
fes_1 | gyp ERR! System Linux 4.1.13-boot2docker
fes_1 | gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--release"
fes_1 | gyp ERR! cwd /var/frontend/node_modules/cares
fes_1 | gyp ERR! node -v v6.2.2
fes_1 | gyp ERR! node-gyp -v v3.3.1
fes_1 | gyp ERR! not ok
fes_1 |
fes_1 | npm info lifecycle cares@1.1.3~install: Failed to exec install script```
Hi Dmitri,
- It would be great, if you could send me the code snippet, as it will help in debugging faster.
- This project is not working yet on >= 5.0.0 versions. I am working on getting this for higher versions and hopefully will push it soon.
Thanks and Regards,
Royal Pinto
Hi, @royalpinto
Thanks for the prompt response!
Below is the code snippet:
var cares = require('cares');
function discover(serviceName) {
var resolver = new cares.Resolver({
servers: ['192.168.99.100'],
udp_port: 8600,
timeout: 1000
});
resolver.query(
'_'+ serviceName +'._http.service.consul',
{
'class': cares.NS_C_IN,
'type': cares.NS_T_SRV,
},
function (err, response) {
if (err) {
console.error(err);
return;
}
console.log(response);
}
);
};
for (var i=0; i < 50; i++) {
discover('sample-service');
}
Regardless of the first few responses (either ETIMEOUT or proper response), after a few responses cares
fails with either:
[1] 2380 segmentation fault node testDns.js
or a more specific error:
[1] 2530 bus error node testDns.js
Although I have seen some other random errors related to malloc
. SegFault + Bus error seems to occur on MacOS, but I have seen the SegFault + malloc errors occur on Ubuntu 14.04.
Thanks @dmitrif for the detailed info, will check on this.
Hi @dmitrif ,
The issue of segmentation fault (and other crashes) has been resolved on version 1.1.4
.
It was crashing because, resolver instance was getting destroyed even before server returns the data and invokes the callback (parsing returned data internally requires resolver to be valid/available).
Let me know if you are still facing issues.
I think just for testing, you are using new instance of Resolver
( with same configuration) for every query. Ideally, a single Resolver
instance is enough to make all above queries (since they are using same config).
Thanks and Regards,
Royal Pinto
Thanks, @royalpinto . I will give this a try and report back!
Did you get a chance to publish it to the npm repo?
Yes, it is published as version 1.1.4
.
Hi @dmitrif ,
cares
latest version 1.1.5
now works on all major node versions:
- "0.10"
- "0.12"
- "4.."
- "5.."
- "6.."