#690171 dies: "segfault at 0 ip 00007fe892f3b1d7 sp 00007fe88b4c9f80 error 6 in libjpeg.so.8.4.0[7fe892f11000+3a000]"

Package:
motion
Source:
motion
Description:
V4L capture program supporting motion detection
Submitter:
Julius Seemayer
Date:
2015-07-12 23:21:08 UTC
Severity:
important
#690171#5
Date:
2012-10-10 18:02:35 UTC
From:
To:
Trying to get a older Tevion MD40820 digital camera work in webcam mode,
lsusb:

  Bus 009 Device 008: ID 08ca:2022 Aiptek International, Inc. Slim 3200

I needed to load the gspca_sunplus module:

% lsmod | grep sunplus
gspca_sunplus          17540  0
gspca_main             22764  1 gspca_sunplus
usbcore               128498  9 ehci_hcd,xhci_hcd,ohci_hcd,usbhid,uas,usb_storage,gspca_main,gspca_sunplus

The syslog stuff can be found at [syslog1].

A /dev/video0 appeared with 0600 root:root, I changed it to 0660 root:video
(wasn't this udev's job?). Then VLC was able to display the webcam stream
properly. Motion was not, it preferres the segfault death (end of [syslog2]).

The changes in /etc/motion/motion.conf where insignificant:

  @@ -11 +11 @@
  -daemon on
  +daemon off
  @@ -407 +407 @@ webcam_quality 50
  -webcam_motion off
  +webcam_motion on

deamon mode got disabled to debug with a motion:-shell, the webcam mode was
to test the function. The segfault happenes even with the default config.

I strace'd with motion$ strace -ff motion #; the output can be found at
[strace1].

This bug seems related to #536422, but I think it's somehow different. Hope
this helps.

#690171#10
Date:
2014-10-21 10:18:18 UTC
From:
To:
Hi,

I am having what I believe is the same issue as reported in this bugreport.

libjpeg segfaults, which leads to motion stopping.
At the same time a completely grey (but date & time-stamped) frame is generated, this frame has no jpeg encoding errors.

Note that some of the packages listed below are from the wheezy-backports archive.

#690171#15
Date:
2015-04-01 14:13:35 UTC
From:
To:
I have met a similar crash too:
motion[4059]: segfault at b444513f ip b769ee8a sp b5440b40 error 4 in
libjpeg.so.8.4.0[b7682000+38000]

I think that in my case the problem was that width and height in config did
not match resolution supported by my camera.

I had "800x608" in config, which worked until I started to pause/resume
detection or disconnect/reconnect my camera while motion was running. My
suspicion was that motion mmaps buffer for picture according to camera
supported resolution, but passes that buffer with config resolution to
libjpeg. E.g. allocates 800x600, and then passes it to libjpeg with 800x608.

I re-compiled motion with -g3 and -O0 and captured a core when this
happened:
(gdb) bt

#0  jpeg_fdct_ifast (data=data@entry=0xb5d36b90,
sample_data=sample_data@entry=0xb5d36fa8,

    start_col=start_col@entry=0) at jfdctfst.c:132

#1  0xb7f7e92c in forward_DCT (cinfo=cinfo@entry=0xb5d36df0,
compptr=compptr@entry=0x80c16bc,
    sample_data=0xb5d36fa8, coef_blocks=0x80c224c, start_row=start_row@entry=0,
start_col=start_col@entry=0,
    num_blocks=num_blocks@entry=1) at jcdctmgr.c:82

#2  0xb7f7dd6c in compress_data (cinfo=0xb5d36df0, input_buf=0xb5d36f9c) at
jccoefct.c:181
#3  0xb7f7bc07 in jpeg_write_raw_data (cinfo=0xb5d36df0, data=0xb5d36f9c,
num_lines=16) at jcapistd.c:153

#4  0x080674f0 in put_jpeg_yuv420p_file (fp=0x80c1440,


    image=0xb4c8b008
"\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200"...,
width=800, height=600, quality=85) at picture.c:264
#5  0x08067d7c in put_picture_fd (cnt=0x80ba7d8, picture=0x80c1440,
    image=0xb4c8b008
"\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200"...,
quality=85) at picture.c:517
#6  0x08067eb7 in put_picture (cnt=0x80ba7d8, file=0xb5d3a11c
"/motion/01-20150326165903-snapshot.jpg",
    image=0xb4c8b008
"\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200"...,
ftype=2) at picture.c:550
---Type <return> to continue, or q <return> to quit---
#7  0x08066028 in event_image_snapshot (cnt=0x80ba7d8, type=1024,
    img=0xb4c8b008
"\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200"...,
dummy1=0x0, dummy2=0x0, currenttime_tm=0x80c11f4) at event.c:315
#8  0x08066d4d in event (cnt=0x80ba7d8, type=1024,
    image=0xb4c8b008
"\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200"...,
filename=0x0, eventdata=0x0, tm=0x80c11f4) at event.c:713
#9  0x0804f505 in motion_loop (arg=0x80ba7d8) at motion.c:1692
#10 0xb7fb6c39 in start_thread (arg=0xb5d3cb70) at pthread_create.c:304
#11 0xb6d80c6e in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:130
(gdb) frame 0
#0  jpeg_fdct_ifast (data=data@entry=0xb5d36b90,
sample_data=sample_data@entry=0xb5d36fa8,
    start_col=start_col@entry=0) at jfdctfst.c:132
132         tmp0 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[7]);
(gdb) list
127       dataptr = data;
128       for (ctr = 0; ctr < DCTSIZE; ctr++) {
129         elemptr = sample_data[ctr] + start_col;
130
131         /* Load data into workspace */
132         tmp0 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[7]);
133         tmp7 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[7]);
134         tmp1 = GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[6]);
135         tmp6 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[6]);
136         tmp2 = GETJSAMPLE(elemptr[2]) + GETJSAMPLE(elemptr[5]);
(gdb) p sample_data[0]
$1 = (
    JSAMPROW) 0xb4d3a648
"\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200"...
(gdb) p sample_data[1]
$2 = (
    JSAMPROW) 0xb4d3a7d8
"\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200"...
(gdb) p sample_data[2]
$3 = (
    JSAMPROW) 0xb4d3a968
"\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200"...
(gdb) p sample_data[3]
$4 = (
    JSAMPROW) 0xb4d3aaf8
"\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200"...
(gdb) p sample_data[4]
$5 = (JSAMPROW) 0xb4d3ac88 ""
(gdb) p sample_data[5]
$6 = (JSAMPROW) 0xb4d3ae18 ""
(gdb) p sample_data[6]
$7 = (JSAMPROW) 0xb4d3afa8 ""
(gdb) p sample_data[7]
$8 = (JSAMPROW) 0xb4d3b138 <Address 0xb4d3b138 out of bounds>
(gdb) p elemptr
$9 = (JSAMPROW) 0xb4d3b138 <Address 0xb4d3b138 out of bounds>

(gdb) main info sec
...
    0xb4200000->0xb4d3b000 at 0x0014df80: load4 ALLOC LOAD HAS_CONTENTS
    0xb4d3c000->0xb553c000 at 0x00c88f80: load5 ALLOC LOAD HAS_CONTENTS
...