Segmentation fault

Dear,

In one of our test devices we use a logitech usb webcam to capture images and read them in a node js application. After every x images the node container segfaults and restarts. It could be that their is an issue with the usb cable (bad contact) but either way it shouldn’t lead to segfaults.

I can also reproduce the issue by manually removing the usb camera. Then it also segfaults.

Any idea what the problem could be?

Kind regards,
Brett

—webcam code used—
NodeWebcam.capture(“test_picture”, ds.config.camera.settings, function (err, data) {
console.log(typeof data !== ‘undefined’);

            if (err === null && typeof data !== 'undefined') {
                ds['currentAction'].picture = data;
            }else {
                if (ds.config.dev.connectedToCamera) {
                    serverSocket.logToServer('error', 'cameraFailure', {error: err, data: data});
                }
            }
    }

—logs—
PID 207 received SIGSEGV for address: 0x0
18.09.18 16:05:05 (+0200) main signal
18.09.18 16:05:05 (+0200) main 11
18.09.18 16:05:05 (+0200) main address
18.09.18 16:05:05 (+0200) main 0
18.09.18 16:05:05 (+0200) main stack
18.09.18 16:05:05 (+0200) main []
18.09.18 16:05:05 (+0200) main Segmentation fault (core dumped)
18.09.18 16:05:05 (+0200) main npm ERR! code ELIFECYCLE
18.09.18 16:05:05 (+0200) main npm ERR! errno 139
18.09.18 16:05:05 (+0200) main npm ERR! xx@1.0.0 start: node dist/app.js
18.09.18 16:05:05 (+0200) main npm ERR! Exit status 139
18.09.18 16:05:05 (+0200) main npm ERR!
18.09.18 16:05:05 (+0200) main npm ERR! Failed at the xx@1.0.0 start script.
18.09.18 16:05:05 (+0200) main npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
18.09.18 16:05:05 (+0200) main
18.09.18 16:05:05 (+0200) main npm ERR! A complete log of this run can be found in:
18.09.18 16:05:05 (+0200) main npm ERR! /root/.npm/_logs/2018-09-18T14_05_05_686Z-debug.log

0 info it worked if it ends with ok
1 verbose cli [ ‘/usr/local/bin/node’, ‘/usr/local/bin/npm’, ‘start’ ]
2 info using npm@5.6.0
3 info using node@v8.11.4
4 verbose run-script [ ‘prestart’, ‘start’, ‘poststart’ ]
5 info lifecycle xx@1.0.0~prestart: xx@1.0.0
6 info lifecycle xx@1.0.0~start: xx@1.0.0
7 verbose lifecycle xx@1.0.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle xx@1.0.0~start: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/usr/src/app/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
9 verbose lifecycle xx@1.0.0~start: CWD: /usr/src/app
10 silly lifecycle xx@1.0.0~start: Args: [ ‘-c’, ‘node dist/app.js’ ]
11 silly lifecycle xx@1.0.0~start: Returned: code: 139 signal: null
12 info lifecycle xx@1.0.0~start: Failed to exec start script
13 verbose stack Error: xx@1.0.0 start: node dist/app.js
13 verbose stack Exit status 139
13 verbose stack at EventEmitter. (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:285:16)
13 verbose stack at emitTwo (events.js:126:13)
13 verbose stack at EventEmitter.emit (events.js:214:7)
13 verbose stack at ChildProcess. (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at emitTwo (events.js:126:13)
13 verbose stack at ChildProcess.emit (events.js:214:7)
13 verbose stack at maybeClose (internal/child_process.js:925:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
14 verbose pkgid xx@1.0.0
15 verbose cwd /usr/src/app
16 verbose Linux 4.14.39
17 verbose argv “/usr/local/bin/node” “/usr/local/bin/npm” “start”
18 verbose node v8.11.4
19 verbose npm v5.6.0
20 error code ELIFECYCLE
21 error errno 139
22 error xx@1.0.0 start: node dist/app.js
22 error Exit status 139
23 error Failed at the xx@1.0.0 start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 139, true ]

bump.

It is a blocking issue for my application.

Hi,
That’s unexpected.
Could you wrap your NodeWebcam.capture() call in a try {} catch {}?
If that doesn’t work either, then the segmentation fault could be in the C++ layers of the NodeWebcam library, in which case you might better open an issue in their repo.

This was indeed the solution.