最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - node.js and Segmentation fault - Stack Overflow

programmeradmin2浏览0评论

is it possible to inspect the javascript stack trace when node.js goes in Segmentation fault?

The current situation is the following: I am running a script which has a few nested async.eachSeries, which caused for some weird reason a RangeError: Maximum call stack size exceeded. Hence, I have increased the stack size via node --stack-size=1000000 and I am left with the Segmentation fault.

Here is the source code of the script: .html

Update

I also tried segfault-handler, but for some inscrutable reason it is not catching my segfault.

is it possible to inspect the javascript stack trace when node.js goes in Segmentation fault?

The current situation is the following: I am running a script which has a few nested async.eachSeries, which caused for some weird reason a RangeError: Maximum call stack size exceeded. Hence, I have increased the stack size via node --stack-size=1000000 and I am left with the Segmentation fault.

Here is the source code of the script: http://nopaste.info/ca0c118591.html

Update

I also tried segfault-handler, but for some inscrutable reason it is not catching my segfault.

Share edited Dec 5, 2014 at 13:45 fstab asked Dec 5, 2014 at 13:22 fstabfstab 5,0399 gold badges39 silver badges70 bronze badges 5
  • You might consider posting your code. – mscdex Commented Dec 5, 2014 at 13:35
  • here is the source code of the script: nopaste.info/ca0c118591.html – fstab Commented Dec 5, 2014 at 13:45
  • Which version of node? – zhon Commented Apr 5, 2015 at 13:29
  • @zhon: ha, this is an old post. I think the version that was the latest at the 5th of december 2014 – fstab Commented Apr 5, 2015 at 21:21
  • Try rewriting your task so that it calls its callback asynchronously, i.e. instead of doTask(task, done); write doTask(task, function(err, res) { setImmediate(done, err, res); });. – David Knipe Commented Aug 4, 2016 at 10:34
Add a ment  | 

2 Answers 2

Reset to default 2

There is the segfault-handler module which catches segfaults on non-Windows platforms and generates a stack trace. But if you're getting a RangeError, that's not a segfault.

This likely means you have recursivety somewhere in your code. Since V8 removed support for TCO (Tail Call Optimization) the call size will grow until it explodes.

Using --stack_size would seem like a natural solution, but it doesn't actually increase the stack size, it is tells V8 to assume there is a bigger stack size when in reality this is controlled by the OS.

Sources:

  • https://github./nodejs/node-v0.x-archive/issues/5669
  • https://github./nodejs/node/issues/6360
  • Node.js tail-call optimization: possible or not?

So for now ( with Node.js 8.x ) the best solution is simple to stop using recursive functions.

发布评论

评论列表(0)

  1. 暂无评论