Feature/divide by zero investigation

The changes below provoke a zmq_assert() in tests/test_security_plain.
I am compiling with g++ 4.8 on a Linux Mint development box.

./autogen.sh 
./configure --enable-debug  --prefix=/usr/local
make -j8
cd tests;  make test_security_plain.log
(other test cases pass)

We have had a related bug (divide by zero) in production with zeromq3-x.

The log file from this test run is...


=>      fq_cons thread=47120183285440 this=0x1476338 seq=1 active=0
=>      lb_cons thread=47120183285440 this=0x1476378 seq=1 active=0
=>      fq_cons thread=47120224872192 this=0x2adb0c000da8 seq=2 active=0
=>  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=3 active=0
<=  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=3 active=0
=>      fq_cons thread=47120183285440 this=0x14783d8 seq=4 active=0
=>      lb_cons thread=47120183285440 this=0x1478418 seq=2 active=0
=>  lb_sendpipe thread=47120183285440 this=0x1478418 seq=3 active=1
=>  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=5 active=1
<=  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=5 active=1
=>  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=6 active=1
<=  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=6 active=1
=>  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=7 active=1
<=  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=7 active=1
=>  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=8 active=1
<=  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=8 active=1
=>  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=9 active=1
<=  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=9 active=1
=>  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=10 active=1
<=  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=10 active=1
=>  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=11 active=1
<=  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=11 active=1
=>  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=12 active=1
<=  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=12 active=1
=>  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=13 active=1
<=  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=13 active=1
=>  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=14 active=1
<=  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=14 active=0
<=  lb_sendpipe thread=47120183285440 this=0x1478418 seq=3 active=1
=>  lb_sendpipe thread=47120183285440 this=0x1478418 seq=4 active=1
<=  lb_sendpipe thread=47120183285440 this=0x1478418 seq=4 active=1
=>  fq_recvpipe thread=47120183285440 this=0x1476338 seq=15 active=0
<=  fq_recvpipe thread=47120183285440 this=0x1476338 seq=15 active=0
=>  fq_recvpipe thread=47120183285440 this=0x1476338 seq=16 active=1
<=  fq_recvpipe thread=47120183285440 this=0x1476338 seq=16 active=0
=>  fq_recvpipe thread=47120183285440 this=0x1476338 seq=17 active=1
<=  fq_recvpipe thread=47120183285440 this=0x1476338 seq=17 active=1
=>  fq_recvpipe thread=47120183285440 this=0x1476338 seq=18 active=1
<=  fq_recvpipe thread=47120183285440 this=0x1476338 seq=18 active=1
=>  lb_sendpipe thread=47120183285440 this=0x1476378 seq=5 active=1
<=  lb_sendpipe thread=47120183285440 this=0x1476378 seq=5 active=1
=>  lb_sendpipe thread=47120183285440 this=0x1476378 seq=6 active=1
<=  lb_sendpipe thread=47120183285440 this=0x1476378 seq=6 active=1
=>  fq_recvpipe thread=47120183285440 this=0x14783d8 seq=19 active=1
<=  fq_recvpipe thread=47120183285440 this=0x14783d8 seq=19 active=0
=>  fq_recvpipe thread=47120183285440 this=0x14783d8 seq=20 active=0
<=  fq_recvpipe thread=47120183285440 this=0x14783d8 seq=20 active=0
=>  fq_recvpipe thread=47120183285440 this=0x14783d8 seq=21 active=1
<=  fq_recvpipe thread=47120183285440 this=0x14783d8 seq=21 active=1
=>  fq_recvpipe thread=47120183285440 this=0x14783d8 seq=22 active=1
<=  fq_recvpipe thread=47120183285440 this=0x14783d8 seq=22 active=1
=>      fq_cons thread=47120183285440 this=0x147e1b8 seq=23 active=0
=>      lb_cons thread=47120183285440 this=0x147e1f8 seq=7 active=0
=>  lb_sendpipe thread=47120183285440 this=0x147e1f8 seq=8 active=1
=>      fq_term thread=47120226973440 this=0x14783d8 seq=24 active=1
<=      fq_term thread=47120226973440 this=0x14783d8 seq=24 active=0
=>      lb_term thread=47120226973440 this=0x1478418 seq=9 active=1
<=      lb_term thread=47120226973440 this=0x1478418 seq=9 active=0
=>  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=25 active=1
<=  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=25 active=0
=>      fq_term thread=47120224872192 this=0x2adb0c000da8 seq=26 active=0
<=      fq_term thread=47120224872192 this=0x2adb0c000da8 seq=26 active=0
=>  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=27 active=0
<=  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=27 active=0
<=  lb_sendpipe thread=47120183285440 this=0x147e1f8 seq=8 active=1
=>  lb_sendpipe thread=47120183285440 this=0x147e1f8 seq=10 active=1
<=  lb_sendpipe thread=47120183285440 this=0x147e1f8 seq=10 active=1
=>  fq_recvpipe thread=47120183285440 this=0x1476338 seq=28 active=1
<=  fq_recvpipe thread=47120183285440 this=0x1476338 seq=28 active=0
=>  fq_recvpipe thread=47120183285440 this=0x1476338 seq=29 active=1
<=  fq_recvpipe thread=47120183285440 this=0x1476338 seq=29 active=0
=>      fq_term thread=47120183285440 this=0x1476338 seq=30 active=0
<=      fq_term thread=47120183285440 this=0x1476338 seq=30 active=0
=>      lb_term thread=47120183285440 this=0x1476378 seq=11 active=2
<=      lb_term thread=47120183285440 this=0x1476378 seq=11 active=1
=>  fq_recvpipe thread=47120183285440 this=0x1476338 seq=31 active=0
<=  fq_recvpipe thread=47120183285440 this=0x1476338 seq=31 active=0
=>  fq_recvpipe thread=47120183285440 this=0x1476338 seq=32 active=0
<=  fq_recvpipe thread=47120183285440 this=0x1476338 seq=32 active=0
=>  lb_sendpipe thread=47120183285440 this=0x1476378 seq=12 active=1
<=  lb_sendpipe thread=47120183285440 this=0x1476378 seq=12 active=1
=>  lb_sendpipe thread=47120183285440 this=0x1476378 seq=13 active=1
<=  lb_sendpipe thread=47120183285440 this=0x1476378 seq=13 active=1
=>  fq_recvpipe thread=47120183285440 this=0x147e1b8 seq=33 active=1
<=  fq_recvpipe thread=47120183285440 this=0x147e1b8 seq=33 active=0
=>  fq_recvpipe thread=47120183285440 this=0x147e1b8 seq=34 active=0
<=  fq_recvpipe thread=47120183285440 this=0x147e1b8 seq=34 active=0
=>      fq_cons thread=47120183285440 this=0x14783d8 seq=35 active=0
=>      lb_cons thread=47120183285440 this=0x1478418 seq=14 active=0
=>  lb_sendpipe thread=47120183285440 this=0x1478418 seq=15 active=1
=>      fq_term thread=47120226973440 this=0x147e1b8 seq=36 active=0
<=      fq_term thread=47120226973440 this=0x147e1b8 seq=36 active=0
=>      lb_term thread=47120226973440 this=0x147e1f8 seq=16 active=1
<=      lb_term thread=47120226973440 this=0x147e1f8 seq=16 active=0
=>  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=37 active=1
<=  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=37 active=1
=>  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=38 active=1
<=  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=38 active=1
=>  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=39 active=1
<=  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=39 active=1
=>  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=40 active=1
<=  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=40 active=1
=>  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=41 active=1
<=  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=41 active=1
=>  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=42 active=1
<=  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=42 active=1
=>  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=43 active=1
<=  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=43 active=1
=>  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=44 active=1
<=  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=44 active=1
=>  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=45 active=1
<=  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=45 active=1
=>  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=46 active=1
<=  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=46 active=0
=>  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=47 active=1
<=  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=47 active=0
=>      fq_term thread=47120224872192 this=0x2adb0c000da8 seq=48 active=0
<=      fq_term thread=47120224872192 this=0x2adb0c000da8 seq=48 active=0
=>  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=49 active=0
<=  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=49 active=0
<=  lb_sendpipe thread=47120183285440 this=0x1478418 seq=15 active=1
=>  lb_sendpipe thread=47120183285440 this=0x1478418 seq=17 active=1
<=  lb_sendpipe thread=47120183285440 this=0x1478418 seq=17 active=1
=>  fq_recvpipe thread=47120183285440 this=0x1476338 seq=50 active=0
<=  fq_recvpipe thread=47120183285440 this=0x1476338 seq=50 active=0
=>  fq_recvpipe thread=47120183285440 this=0x1476338 seq=51 active=2
<=  fq_recvpipe thread=47120183285440 this=0x1476338 seq=51 active=0
=>      fq_term thread=47120183285440 this=0x1476338 seq=52 active=0
<=      fq_term thread=47120183285440 this=0x1476338 seq=52 active=0
=>      lb_term thread=47120183285440 this=0x1476378 seq=18 active=2
<=      lb_term thread=47120183285440 this=0x1476378 seq=18 active=1
=>      fq_term thread=47120183285440 this=0x1476338 seq=53 active=0
<=      fq_term thread=47120183285440 this=0x1476338 seq=53 active=0
=>      lb_term thread=47120183285440 this=0x1476378 seq=19 active=1
<=      lb_term thread=47120183285440 this=0x1476378 seq=19 active=0
=>  fq_recvpipe thread=47120183285440 this=0x1476338 seq=54 active=0
<=  fq_recvpipe thread=47120183285440 this=0x1476338 seq=54 active=0
=>  fq_recvpipe thread=47120183285440 this=0x1476338 seq=55 active=1
<=  fq_recvpipe thread=47120183285440 this=0x1476338 seq=55 active=0
=>  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=56 active=1
<=  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=56 active=1
=>  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=57 active=1
<=  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=57 active=1
=>  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=58 active=1
<=  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=58 active=1
=>  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=59 active=1
<=  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=59 active=1
=>  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=60 active=1
<=  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=60 active=1
=>  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=61 active=1
<=  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=61 active=1
=>  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=62 active=1
<=  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=62 active=1
=>  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=63 active=1
<=  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=63 active=1
=>  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=64 active=1
<=  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=64 active=1
=>  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=65 active=1
<=  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=65 active=0
=>  fq_recvpipe thread=47120183285440 this=0x1476338 seq=66 active=1
=>  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=67 active=1
<=  fq_recvpipe thread=47120183285440 this=0x1476338 seq=66 active=0
=>      fq_term thread=47120183285440 this=0x1476338 seq=68 active=0
<=      fq_term thread=47120183285440 this=0x1476338 seq=68 active=0
=>      lb_term thread=47120183285440 this=0x1476378 seq=20 active=1
<=      lb_term thread=47120183285440 this=0x1476378 seq=20 active=0
<=  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=67 active=0
=>  fq_recvpipe thread=47120183285440 this=0x1476338 seq=69 active=0
<=  fq_recvpipe thread=47120183285440 this=0x1476338 seq=69 active=0
=>      fq_term thread=47120224872192 this=0x2adb0c000da8 seq=70 active=0
<=      fq_term thread=47120224872192 this=0x2adb0c000da8 seq=70 active=0
=>  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=71 active=0
<=  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=71 active=0
=>  fq_recvpipe thread=47120183285440 this=0x1476338 seq=72 active=0
<=  fq_recvpipe thread=47120183285440 this=0x1476338 seq=72 active=0
=>  lb_sendpipe thread=47120183285440 this=0x1476378 seq=21 active=0
<=  lb_sendpipe thread=47120183285440 this=0x1476378 seq=21 active=0
=>  lb_sendpipe thread=47120183285440 this=0x1476378 seq=22 active=1
=>  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=73 active=1
<=  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=73 active=1
=>  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=74 active=1
<=  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=74 active=1
=>  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=75 active=1
<=  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=75 active=1
=>  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=76 active=1
<=  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=76 active=1
=>  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=77 active=1
<=  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=77 active=1
=>  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=78 active=1
<=  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=78 active=1
=>  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=79 active=1
<=  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=79 active=1
=>  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=80 active=1
<=  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=80 active=1
=>  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=81 active=1
<=  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=81 active=1
=>  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=82 active=1
<=  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=82 active=0
=>  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=83 active=1
<=  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=83 active=0
=>      fq_term thread=47120224872192 this=0x2adb0c000da8 seq=84 active=0
<=      fq_term thread=47120224872192 this=0x2adb0c000da8 seq=84 active=0
=>  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=85 active=0
<=  fq_recvpipe thread=47120224872192 this=0x2adb0c000da8 seq=85 active=0
<=  lb_sendpipe thread=47120183285440 this=0x1476378 seq=22 active=1
=>  lb_sendpipe thread=47120183285440 this=0x1476378 seq=23 active=1
=>    lb_assert thread=47120183285440 this=0x1476378 seq=24 active=1
Assertion failed: !more (lb.cpp:128)