nicolasff / webdis

A Redis HTTP interface with JSON output
https://webd.is
BSD 2-Clause "Simplified" License
2.83k stars 304 forks source link

Dies when sending a message to a client listening through a websocket #31

Open okko opened 12 years ago

okko commented 12 years ago

Test page:

<script type="text/javascript"> 
function testJSON() {
    var jsonSocket = new WebSocket("ws://localhost:7379/.json");
    jsonSocket.onopen = function() {

        console.log("JSON socket connected!");
        jsonSocket.send(JSON.stringify(["SUBSCRIBE", "chan"]));
    };
    jsonSocket.onmessage = function(messageEvent) {
        console.log("JSON received:", messageEvent.data);
    };
}
testJSON();
</script>

1) Loaded test page on Google Chrome 2) WIth another connection to Redis sent the message: PUBLISH chan Moo4

Webdis shuts down, this is what gets printed:

{"":["message","chan","Moo4"]}?*** glibc detected *** ./webdis: double free or corruption (fasttop): 0x00007f8e440011a0 *** ======= Backtrace: ========= /lib64/libc.so.6(+0x75386)[0x7f8e4eb6b386] ./webdis[0x408b5d] ./webdis[0x407bb1] ./webdis[0x4103b2] /usr/lib64/libevent-1.4.so.2(event_base_loop+0x3e4)[0x7f8e4f08bb44] ./webdis[0x402f1f] /lib64/libpthread.so.0(+0x77e1)[0x7f8e4ee6f7e1] /lib64/libc.so.6(clone+0x6d)[0x7f8e4ebd727d] ======= Memory map: ======== 00400000-0041f000 r-xp 00000000 ca:01 151681 /tmp/webdis/webdis 0061f000-00620000 rw-p 0001f000 ca:01 151681 /tmp/webdis/webdis 0093b000-0095c000 rw-p 00000000 00:00 0 [heap] 7f8e38000000-7f8e38021000 rw-p 00000000 00:00 0 7f8e38021000-7f8e3c000000 ---p 00000000 00:00 0 7f8e40000000-7f8e40021000 rw-p 00000000 00:00 0 7f8e40021000-7f8e44000000 ---p 00000000 00:00 0 7f8e44000000-7f8e44021000 rw-p 00000000 00:00 0 7f8e44021000-7f8e48000000 ---p 00000000 00:00 0 7f8e48000000-7f8e48021000 rw-p 00000000 00:00 0 7f8e48021000-7f8e4c000000 ---p 00000000 00:00 0 7f8e4c2a1000-7f8e4c2b7000 r-xp 00000000 ca:01 428 /lib64/libgcc_s-4.4.4-20100726.so.1 7f8e4c2b7000-7f8e4c4b6000 ---p 00016000 ca:01 428 /lib64/libgcc_s-4.4.4-20100726.so.1 7f8e4c4b6000-7f8e4c4b7000 rw-p 00015000 ca:01 428 /lib64/libgcc_s-4.4.4-20100726.so.1 7f8e4c4b7000-7f8e4c4b8000 ---p 00000000 00:00 0 7f8e4c4b8000-7f8e4ccb8000 rw-p 00000000 00:00 0 7f8e4ccb8000-7f8e4ccb9000 ---p 00000000 00:00 0 7f8e4ccb9000-7f8e4d4b9000 rw-p 00000000 00:00 0 7f8e4d4b9000-7f8e4d4ba000 ---p 00000000 00:00 0 7f8e4d4ba000-7f8e4dcba000 rw-p 00000000 00:00 0 7f8e4dcba000-7f8e4dcbb000 ---p 00000000 00:00 0 7f8e4dcbb000-7f8e4e4bb000 rw-p 00000000 00:00 0 7f8e4e4bb000-7f8e4e4d1000 r-xp 00000000 ca:01 8115 /lib64/libresolv-2.12.so 7f8e4e4d1000-7f8e4e6d1000 ---p 00016000 ca:01 8115 /lib64/libresolv-2.12.so 7f8e4e6d1000-7f8e4e6d2000 r--p 00016000 ca:01 8115 /lib64/libresolv-2.12.so 7f8e4e6d2000-7f8e4e6d3000 rw-p 00017000 ca:01 8115 /lib64/libresolv-2.12.so 7f8e4e6d3000-7f8e4e6d5000 rw-p 00000000 00:00 0 7f8e4e6d5000-7f8e4e6dc000 r-xp 00000000 ca:01 8117 /lib64/librt-2.12.so 7f8e4e6dc000-7f8e4e8db000 ---p 00007000 ca:01 8117 /lib64/librt-2.12.so 7f8e4e8db000-7f8e4e8dc000 r--p 00006000 ca:01 8117 /lib64/librt-2.12.so 7f8e4e8dc000-7f8e4e8dd000 rw-p 00007000 ca:01 8117 /lib64/librt-2.12.so 7f8e4e8dd000-7f8e4e8f3000 r-xp 00000000 ca:01 8099 /lib64/libnsl-2.12.so 7f8e4e8f3000-7f8e4eaf2000 ---p 00016000 ca:01 8099 /lib64/libnsl-2.12.so 7f8e4eaf2000-7f8e4eaf3000 r--p 00015000 ca:01 8099 /lib64/libnsl-2.12.so 7f8e4eaf3000-7f8e4eaf4000 rw-p 00016000 ca:01 8099 /lib64/libnsl-2.12.so 7f8e4eaf4000-7f8e4eaf6000 rw-p 00000000 00:00 0 7f8e4eaf6000-7f8e4ec5f000 r-xp 00000000 ca:01 8089 /lib64/libc-2.12.so 7f8e4ec5f000-7f8e4ee5e000 ---p 00169000 ca:01 8089 /lib64/libc-2.12.so 7f8e4ee5e000-7f8e4ee62000 r--p 00168000 ca:01 8089 /lib64/libc-2.12.so 7f8e4ee62000-7f8e4ee63000 rw-p 0016c000 ca:01 8089 /lib64/libc-2.12.so 7f8e4ee63000-7f8e4ee68000 rw-p 00000000 00:00 0 7f8e4ee68000-7f8e4ee7f000 r-xp 00000000 ca:01 8113 /lib64/libpthread-2.12.so 7f8e4ee7f000-7f8e4f07f000 ---p 00017000 ca:01 8113 /lib64/libpthread-2.12.so 7f8e4f07f000-7f8e4f080000 r--p 00017000 ca:01 8113 /lib64/libpthread-2.12.so 7f8e4f080000-7f8e4f081000 rw-p 00018000 ca:01 8113 /lib64/libpthread-2.12.so 7f8e4f081000-7f8e4f085000 rw-p 00000000 00:00 0 7f8e4f085000-7f8e4f09e000 r-xp 00000000 ca:01 9887 /usr/lib64/libevent-1.4.so.2.1.3 7f8e4f09e000-7f8e4f29e000 ---p 00019000 ca:01 9887 /usr/lib64/libevent-1.4.so.2.1.3 7f8e4f29e000-7f8e4f29f000 rw-p 00019000 ca:01 9887 /usr/lib64/libevent-1.4.so.2.1.3 7f8e4f29f000-7f8e4f2a0000 rw-p 00000000 00:00 0 7f8e4f2a0000-7f8e4f2be000 r-xp 00000000 ca:01 8081 /lib64/ld-2.12.so 7f8e4f4b0000-7f8e4f4b5000 rw-p 00000000 00:00 0 7f8e4f4bd000-7f8e4f4be000 rw-p 00000000 00:00 0 7f8e4f4be000-7f8e4f4bf000 r--p 0001e000 ca:01 8081 /lib64/ld-2.12.so 7f8e4f4bf000-7f8e4f4c0000 rw-p 0001f000 ca:01 8081 /lib64/ld-2.12.so 7f8e4f4c0000-7f8e4f4c1000 rw-p 00000000 00:00 0 7fff239d1000-7fff239f2000 rw-p 00000000 00:00 0 [stack] 7fff239ff000-7fff23a00000 r-xp 00000000 00:00 0 [vdso] ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]

okko commented 12 years ago

This is with the latest version in the master branch - is websockets still a work in progress?

nicolasff commented 12 years ago

Thank you for reporting this issue. WebSocket support is still in progress, mainly due to the fact that there is no final WebSocket standard yet. What browser were you using?

I will add a flag to disable them, and work to resolve this issue. You can follow the websocket branch on Github to track the progress of this feature. My implementation is based on the latest version of the WebSocket protocol, but should be compatible with Firefox 6 which uses version 7.

okko commented 12 years ago

Thanks for a prompt reply! I was using Google Chrome 13.0.782.112 on Mac OSX.

PhE commented 12 years ago

Same issue when using PUBLISH to a websocket SUBSCRIBEd channel : seg fault I was using Chromium 13.0.782.215 on Ubuntu 11.04 64bits

ghost commented 12 years ago

I've at least partially fixed this.