4commerce-technologies-AG / meteor

This is a fork of Meteor.js to support not yet official enabled architectures with an universal bundler. Meteor is an ultra-simple, database-everywhere, data-on-the-wire, pure-Javascript web framework. Read additional information about this fork at:
http://meteor-universal.tumblr.com/
Other
195 stars 16 forks source link

FIXED: Segmentation fault when running through a loop on Raspberry-Pi2 #21

Closed Dev1an closed 8 years ago

Dev1an commented 9 years ago

I installed your latest pre-build meteor from release-1.1.0.2-universal on my Raspberry Pi 2 and the todos example works great. But when I start a new project and write a for loop like this (on the server)

// file at './server/forloop.js'
for (var i = 0; i<1000; ++i) {console.log(i)}

The meteor program crashes after the 121st iteration. On Ubuntu I get an error Segmentation fault, on Debian it just crashes without an error message.

Is anyone else seeing this, or am I doing something wrong?

Reproduction

To reproduce the bug

TomFreudenberg commented 9 years ago

Hi Damiaan ( @Dev1an )

I can confirm this seg-fault also on ubuntu running core 14.04

Never seen that before - I will do some tests but not sure where this problems come from.

TomFreudenberg commented 9 years ago

Result from testing:

Problem occurs for any type of loops, e.g.

var i = 0;
do {
  console.log(i);
} while (i++ < 2000);

Same crash

TomFreudenberg commented 9 years ago

Problem only occurs while using meteor during development.

Build application will run without any issue

Do for test:

$ meteor build --directory ../app-build

$ cd ../app-build/bundle

# install missing npms
$ cd programs/server
$ npm install
$ cd ../..

# run app in production mode
MONGO_URL='mongodb://localhost/segfault' ROOT_URL='http://localhost' PORT=3000 node main.js

You should get all 2000 log statements and the server is in run-mode

Stop with Strg-C

TomFreudenberg commented 9 years ago

It must be something in case of async fibers which meteor is using and console.log. I am not sure yet if the development version of meteor may add / change the console.log statement. May there are some debugging options which exceed ???

I have rewritten the code using:

if (Meteor.isServer) {
  var i=0;

  function myLog() {
    console.log(i);
    if (i < 2000) {
      i++;
      Meteor.setTimeout(function() { myLog() }, 10);
    }
  }

  myLog()
}

For times lower than 10ms I get also SegFaults but not always at value 120

TomFreudenberg commented 9 years ago

Hi David ( @dweldon )

Do you have any idea on this issue?

Thanks for your attention Tom

Dev1an commented 9 years ago

Hi Tom (@TomFreudenberg), thank you for this quick response. The 'for loop example' is a distilled version of a problem I'm having in an other app I'm working on.

I don't think it is directly related to console.log neither to for loops because where it happens in my app is when I need to respond to incoming UDP packets very quickly. When there are lots of packets coming in on the same time the app crashes like it does with the for loop example. My real app even crashes in production. I know it doesn't crash with the for loop app (running in production), but I will try to find another example where it does.

TomFreudenberg commented 9 years ago

Hi Damiaan ( @Dev1an )

this is a pretty tricky issue. I do not have a real idea this is relying to. I tested a bit also with my linux stack sizes like ulimit but could not yet get some success.

If you use ulimit -c unlimited and start meteor afterwards, it will generate a core file which you can use with gdb.

I do not have enough time yet to start deep debugging but will keep with you on that thread.

What version of node you are running?


I am looking forward to the new meteor v1.2 release which will be ready in the next couple of weeks. This will also support newer nodejs v12.x.

Maybe this issue will be "blow out" then.

If a find the time I will try to make a first "v1.2 beta" from the current devel branch so that we can test.


Sorry for not having a final solution yet.

Tom

Dev1an commented 9 years ago

I'm using node v0.10.38

TomFreudenberg commented 9 years ago

Ok, same as I use

TomFreudenberg commented 9 years ago

Hi Damiaan ( @Dev1an )

did you get some updates? I checked with meteor 1.2 rc.4 but this will use node v0.10.x trunk as well. So same problem occurs on my environment.

Thanks for your feedback Tom

TomFreudenberg commented 8 years ago

Hi Damiaan ( @Dev1an )

tonight I updated this fork for meteor release 1.2.0.1 and node v0.10.40.

Symptoms are the same, after 121 lines, I get a segmentation fault.

Still spooky

TomFreudenberg commented 8 years ago

Hi Damiaan ( @Dev1an )

next non working test :-( I have build a new installer archive for meteor on arm including a build of the patched versions of node and mongo from MDG.

But ... still does not work with your testing code. I had run this on an ARM server from SCALEWAY (4Core) but it still breaks after showing value 120

Damned!

TomFreudenberg commented 8 years ago

After a next few google activities I found that issue:

https://github.com/laverdet/node-fibers/issues/108

This points out the same error (step 1 pool.js)

Maybe this is more a fiber issue

TomFreudenberg commented 8 years ago

Hi Damiaan ( @Dev1an )

great news from node-fibers! As @laverdet has detected, this happens while special arm compiler setting in

https://github.com/laverdet/node-fibers/blob/master/binding.gyp#L47-L48

I will create a fork from the meteor fibers fork to be compatible as close as possible to the meteor ones.

https://github.com/meteor/node-fibers

Thanks for pointing that out here Tom

P.S.: Thanks to Marcel ( @laverdet ) for your support on this.

TomFreudenberg commented 8 years ago

This is solved with release 1.2.0.2

Thanks to all

TomFreudenberg commented 8 years ago

Seems that this patch isn't necessary anymore on meteor release 1.3.3.1