You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Our application crashes V8 when running with node:6.9.2-alpine but not with node:6.9.2-slim. Is there anything I can do to help diagnose the cause of this issue?
The Dockerfile itself is pretty simple but I can't share our code so it wouldn't be much use. If I had an idea of where to start looking, I'd work on creating a stand alone, minimal reproducer, but I'm not sure where to even start with that since I'm not sure what's causing the crash.
It would be good to know what modules you are using in your app. This could be a v8 issue under Alpine, given that your app works fine using the slim variant (debian).
I've been unable to make a minimal reproducer because the point at which it crashes jumps around in our code, but it only happens when using ajv to validate GeoJSON using the schema from http://json.schemastore.org/geojson and that's the most I've been able to isolate the issue.
Is any of the dependencies using pre-built binaries, those sometimes have issues. I think the ecosystem in general isn't familiar with alpine and musl yet so a lot of the prebuilt binaries don't work in alpine and you sometimes have to compile them from source.
As far as I can tell, ajv and it's dependencies are pure Javascript so I don't believe it's an issue with pre-built binaries.
If I removed the GeoJSON validation and just ran more data through, then the crash still happens. I also ran the tests from ajv against the Alpine base image in hopes that it would reveal something, but all of the tests passed except for one that relies on an unavailable module (see ajv-validator/ajv#404).
FROM node:6.10.0-alpine
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
RUN yarn add ajv csv-parse lodash
COPY test_ajv.js /usr/src/app
CMD [ "node", "test_ajv.js" ]
make_ajv_test_csv.py
import random
import csv
random.seed(123456789)
WORDS = ['this', 'works', 'well', 'as', 'a', 'reproducer']
S_COLS = 100
out = csv.DictWriter(open('test_ajv.csv', 'w'), ['n'] + ['s{}'.format(i) for i in range(S_COLS)])
out.writeheader()
for n in range(500):
row = {'n': n}
for i in range(S_COLS):
row['s{}'.format(i)] = ' '.join((random.choice(WORDS) for _ in range(random.randint(1, 20))))
out.writerow(row)
I'm not familiar with how v8/node executes things, but from looking at the backtrace from the core dump, it looks like it's getting stuck in a recursive call and exhausting the stack. Here's the backtrace from gdb with a lot of the repeated calls removed:
#0 0x0000564f3d67e63e in v8::internal::HGlobalValueNumberingPhase::CollectSideEffectsOnPathsToDominatedBlock(v8::internal::HBasicBlock*, v8::internal::HBasicBlock*) ()
#1 0x0000564f3d67e6da in v8::internal::HGlobalValueNumberingPhase::CollectSideEffectsOnPathsToDominatedBlock(v8::internal::HBasicBlock*, v8::internal::HBasicBlock*) ()
#2 0x0000564f3d67e6da in v8::internal::HGlobalValueNumberingPhase::CollectSideEffectsOnPathsToDominatedBlock(v8::internal::HBasicBlock*, v8::internal::HBasicBlock*) ()
...
#1287 0x0000564f3d67e6da in v8::internal::HGlobalValueNumberingPhase::CollectSideEffectsOnPathsToDominatedBlock(v8::internal::HBasicBlock*, v8::internal::HBasicBlock*) ()
#1288 0x0000564f3d67e6da in v8::internal::HGlobalValueNumberingPhase::CollectSideEffectsOnPathsToDominatedBlock(v8::internal::HBasicBlock*, v8::internal::HBasicBlock*) ()
#1289 0x0000564f3d67e6da in v8::internal::HGlobalValueNumberingPhase::CollectSideEffectsOnPathsToDominatedBlock(v8::internal::HBasicBlock*, v8::internal::HBasicBlock*) ()
#1290 0x0000564f3d68020c in v8::internal::HGlobalValueNumberingPhase::AnalyzeGraph() ()
#1291 0x0000564f3d6807dd in v8::internal::HGlobalValueNumberingPhase::Run() ()
#1292 0x0000564f3d6b13c5 in void v8::internal::HGraph::Run<v8::internal::HGlobalValueNumberingPhase>() ()
#1293 0x0000564f3d6be624 in v8::internal::HGraph::Optimize(v8::internal::BailoutReason*) ()
#1294 0x0000564f3d640aec in v8::internal::OptimizedCompileJob::OptimizeGraph() ()
#1295 0x0000564f3d8cc379 in v8::internal::OptimizingCompileDispatcher::CompileTask::Run() ()
#1296 0x0000564f3dc67329 in v8::platform::WorkerThread::Run() ()
#1297 0x0000564f3de923b0 in v8::base::ThreadEntry(void*) ()
#1298 0x00007f97cec3a655 in ?? () from /lib/ld-musl-x86_64.so.1
#1299 0x0000000000000000 in ?? ()
Activity
LaurentGoderre commentedon Dec 9, 2016
What happens when you run docker logs?
daveisfera commentedon Dec 9, 2016
There's nothing in the logs for the container, but this is in the dmesg logs on the host:
LaurentGoderre commentedon Dec 12, 2016
Is there a way you can share the Dockerfile?
daveisfera commentedon Dec 12, 2016
The Dockerfile itself is pretty simple but I can't share our code so it wouldn't be much use. If I had an idea of where to start looking, I'd work on creating a stand alone, minimal reproducer, but I'm not sure where to even start with that since I'm not sure what's causing the crash.
chorrell commentedon Dec 12, 2016
It would be good to know what modules you are using in your app. This could be a v8 issue under Alpine, given that your app works fine using the slim variant (debian).
pesho commentedon Dec 12, 2016
You can try to isolate if a specific require/import or other action in your application is causing the crash.
LaurentGoderre commentedon Dec 12, 2016
Do you use node-gyp in your alpine Dockerfile?
daveisfera commentedon Dec 12, 2016
Not in the container that's crashing.
daveisfera commentedon Jan 25, 2017
I've been unable to make a minimal reproducer because the point at which it crashes jumps around in our code, but it only happens when using
ajvto validate GeoJSON using the schema from http://json.schemastore.org/geojson and that's the most I've been able to isolate the issue.LaurentGoderre commentedon Jan 25, 2017
Is any of the dependencies using pre-built binaries, those sometimes have issues. I think the ecosystem in general isn't familiar with alpine and musl yet so a lot of the prebuilt binaries don't work in alpine and you sometimes have to compile them from source.
daveisfera commentedon Jan 25, 2017
As far as I can tell,
ajvand it's dependencies are pure Javascript so I don't believe it's an issue with pre-built binaries.If I removed the GeoJSON validation and just ran more data through, then the crash still happens. I also ran the tests from
ajvagainst the Alpine base image in hopes that it would reveal something, but all of the tests passed except for one that relies on an unavailable module (see ajv-validator/ajv#404).daveisfera commentedon Mar 8, 2017
I'm not sure what fixed the issue, but I can no longer reproduce this.
daveisfera commentedon Mar 14, 2017
The crashes started happening again and I was able to make a reproducer:
test_ajv.js
Dockerfile
make_ajv_test_csv.py
And then I ran the following:
NOTE: I made the test not use the
wordsfile from the OS so it's platform independent.[-]Crash with node:6.9.2-alpine but not node:6.9.2-slim[/-][+]Crash with node alpine but not node slim[/+]daveisfera commentedon Mar 17, 2017
Here's a completely self contained reproducer that doesn't require reading a CSV file:
Here's the Dockerfile:
Then run:
LaurentGoderre commentedon Mar 17, 2017
I am wondering if the issue could be because PhantomJS used in ajv....I couldn't get PhantomJS to work in alpine without custom building it.
daveisfera commentedon Mar 17, 2017
PhantomJS is used in the tests of
ajvbut not in the code itself. If you look at thepackage.jsonfile, it's a devDependency ( https://github.com/epoberezkin/ajv/blob/071b81099edd30b0eba96afb6ae1e289b77db163/package.json#L93 ).LaurentGoderre commentedon Mar 17, 2017
It's so weird.....I add
console.log(value);and the script finishesLaurentGoderre commentedon Mar 17, 2017
Hmmm, nevermind, it crashes at line 443 out of 500
LaurentGoderre commentedon Mar 17, 2017
It actually seems like a race condition.....
daveisfera commentedon Mar 20, 2017
I'm not familiar with how
v8/nodeexecutes things, but from looking at the backtrace from the core dump, it looks like it's getting stuck in a recursive call and exhausting the stack. Here's the backtrace from gdb with a lot of the repeated calls removed:daveisfera commentedon Mar 22, 2017
Here's a further simplified reproducer and it crashes when 81 columns and 394 rows are used:
daveisfera commentedon Apr 4, 2017
I just tried with node 6.10.2 and it now crashes with a smaller number of columns (70) but the same number of rows is required (394).
daveisfera commentedon Apr 25, 2017
A fix has been committed upstream: nodejs/node#11991 (comment)