Pages

Friday, 3 December 2010

Kernel crash!

Haven't had one of these in a while. Caps lock and scroll lock suddenly started flashing at me. No morse code though, unless it was meant to be just and endless ............ as in the Morse error symbol.

What was I doing? I was grabbing frames from the webcam. It had been going fine a while earlier, when I used a shell script to take one frame at a time, but now I'm trying to let webcam grab multiple frames separated by 0.2 seconds (hint: it can't - the delay parameter is an integer).

System info:

Linux bernd-desktop 2.6.31-22-generic #68-Ubuntu SMP Tue Oct 26 16:38:35 UTC 2010 i686 GNU/Linux

Modules:

Module Size Used by
binfmt_misc 8356 1
nfsd 241104 9
lockd 67724 1 nfsd
nfs_acl 2844 1 nfsd
auth_rpcgss 36672 1 nfsd
sunrpc 191776 8 nfsd,lockd,nfs_acl,auth_rpcgss
exportfs 4412 1 nfsd
snd_hda_codec_realtek 203328 1
snd_hda_intel 27016 2
snd_hda_codec 75708 2 snd_hda_codec_realtek,snd_hda_intel
snd_usb_audio 84224 2
snd_usb_lib 16284 1 snd_usb_audio
snd_pcm_oss 37920 0
snd_mixer_oss 16028 1 snd_pcm_oss
snd_seq_dummy 2656 0
snd_pcm 75296 4 snd_hda_intel,snd_hda_codec,snd_usb_audio,snd_pcm_oss
snd_hwdep 7200 2 snd_hda_codec,snd_usb_audio
snd_seq_oss 28608 0
snd_seq_midi 6464 0
snd_rawmidi 22176 2 snd_usb_lib,snd_seq_midi
snd_seq_midi_event 6940 2 snd_seq_oss,snd_seq_midi
snd_seq 50224 6 snd_seq_dummy,snd_seq_oss,snd_seq_midi,snd_seq_midi_event
snd_timer 22276 2 snd_pcm,snd_seq
snd_seq_device 6920 5 snd_seq_dummy,snd_seq_oss,snd_seq_midi,snd_rawmidi,snd_seq
snd 59236 21 snd_hda_codec_realtek,snd_hda_intel,snd_hda_codec,snd_usb_audio,snd_pcm_oss,snd_mixer_oss,snd_pcm,snd_hwdep,snd_seq_oss,snd_rawmidi,snd_seq,snd_timer,snd_seq_device
iptable_filter 3100 0
ppdev 6688 0
soundcore 7264 1 snd
parport_pc 31940 1
snd_page_alloc 9156 2 snd_hda_intel,snd_pcm
gspca_zc3xx 47580 0
ip_tables 11692 1 iptable_filter
x_tables 16544 1 ip_tables
gspca_main 22812 1 gspca_zc3xx
pwc 81632 0
videodev 36736 2 gspca_main,pwc
v4l1_compat 14336 1 videodev
psmouse 57332 0
serio_raw 5280 0
lp 8964 0
parport 35340 3 ppdev,parport_pc,lp
fbcon 36640 72
tileblit 2460 1 fbcon
font 8124 1 fbcon
bitblit 5372 1 fbcon
softcursor 1756 1 bitblit
floppy 54916 0
8139too 22620 0
8139cp 19260 0
mii 5212 2 8139too,8139cp
i915 227528 3
drm 160096 3 i915
i2c_algo_bit 5760 1 i915
video 19380 1 i915
output 2780 1 video
intel_agp 27996 2 i915
agpgart 34988 2 drm,intel_agp

And my ~/.webcamrc:

[grab]
device = /dev/video0
text = "%Y-%m-%d %H:%M:%S"
infofile = foo
fg_red = 255
fg_green = 255
fg_blue = 255
width = 640
height = 480
delay = 0.2
wait = 3
input = usb
#norm = pal
rotate = 0
top = 0
left = 0
bottom = -1
right = -1
quality = 75
trigger = 0
once = 0

[ftp]
host = localhost
user = webcam
pass = xxxxxx
dir = public_html/snapshots
file = webcam.jpeg
tmp = uploading.jpeg
passive = 1
debug = 1
auto = 0
local = 1
ssh = 0

Finally, the script:

#!/bin/sh

i=1
while true; do
sleep 0.1
webcam >/dev/null 2>&1 &
mv public_html/snapshots/webcam.jpeg `date +public_html/snapshots/webcam-%Y%m%d-%H%M%S-$i.jpeg` || continue
i=$(($i+1))
done

Astute readers will notice that it's a forkbomb-lite, spawning a new webcam process every 0.1 seconds! Still, no userland process should be able to make the kernel panic, right?

I don't really feel like investigating this too far. Reboots are SO disruptive!