Bugzilla – Bug 1759
dce httpd example stops working with big files (~1MB)
Last modified: 2014-01-09 18:47:11 EST
When running the provided example dce-httpd ./waf --run dce-httpd this only works with a small file. Any large file results in SIGSEGV. Command ['/home/ted/work/ns3/dce/dce/source/ns-3-dce/build/myscripts/httpd/bin/dce-httpd'] terminated with signal SIGSEGV. Run it under a debugger to get more information (./waf --run <program> --command-template="gdb --args %s <args>"). Running with dce-ns3-1.1 , not the dce-linux-1.1 which cannot work due to: msg="fcntl not implemented on socket", file=../model/linux-socket-fd.cc, line=183 NB: despite the wscript want to build it only for linux kernel stack (I commented the line: if bld.env['KERNEL_STACK']: to compile it) Bug reproducibility: always. Just add the following code: FILE *fp=fopen("files-0/index.html", "wb"); int i; for (i=0; i<500000; i++) {fprintf(fp,"%d\n",i);}fclose(fp); in source/ns-3-dce/myscripts/httpd/dce-httpd.cc after line 51: // CreateFiles (); NB: the bug is present also if a big file named index.html is directly added to the folder files-0 Already debugged a bit, but could not solve it: - it is not an issue with wget (tried also with a simple C program to send HTTP request and write down the result, same error) - thttpd 2.25b (dce version) works perfectly if run standalone with wget 1.14 (dce version) on the same big file. - also compiled thttpd with -U_FORTIFY_SOURCE (not mentioned in source/ns-3-dce/myscripts/httpd/README) - also checked thttpd with valgrind, replaced overlapping strcpy() calls (which might have undefined behavior) with memmove() patch: see http://marc.info/?l=thttpd&m=107035015925670&w=2 : no valgrind warning but still not working
thanks for reporting. what distribution (of Linux, e.g. Ubuntu 12.XX, 32bits or 64bits) are you using ?
Ubuntu 12.04.1 LTS, 64bits By the way with simpler HTTP server such as this very simple "toy server" like https://github.com/stackbox/code/tree/master/tinyhttpd-0.1.0 everything works well even with big files. So probably there is some usage of socket functions by thttpd-2.25b that creates problems. Unfortunately I was not so good to debug it with the gdb command.
(In reply to comment #2) > Ubuntu 12.04.1 LTS, 64bits thanks. I will try to reproduce it. > By the way with simpler HTTP server such as this very simple "toy server" like > https://github.com/stackbox/code/tree/master/tinyhttpd-0.1.0 > everything works well even with big files. > So probably there is some usage of socket functions by thttpd-2.25b that > creates problems. Unfortunately I was not so good to debug it with the gdb > command. thanks for the info. just curious: did you rung tinyhttpd over DCE ?
fixed in changeset 98f8c21e069f http://code.nsnam.org/ns-3-dce/rev/98f8c21e069f the root cause is not by thttpd itself, but dce_writev () implemented in ns-3-dce had an issue of buffer overflow.
writev has degraded by the changeset 98f8c21e069f. will fix asap.
Created attachment 1698 [details] writev() degraded proposed fix
fixed again on changeset: 10f560475c48
(In reply to comment #7) > fixed again on changeset: 10f560475c48 In fact the patch solves the bug. Many thanks and sorry for the late answer!
(In reply to comment #3) > (In reply to comment #2) > > Ubuntu 12.04.1 LTS, 64bits > > thanks. I will try to reproduce it. > > > By the way with simpler HTTP server such as this very simple "toy server" like > > https://github.com/stackbox/code/tree/master/tinyhttpd-0.1.0 > > everything works well even with big files. > > So probably there is some usage of socket functions by thttpd-2.25b that > > creates problems. Unfortunately I was not so good to debug it with the gdb > > command. > > thanks for the info. > just curious: did you rung tinyhttpd over DCE ? (In reply to comment #3) > (In reply to comment #2) > > Ubuntu 12.04.1 LTS, 64bits > > thanks. I will try to reproduce it. > > > By the way with simpler HTTP server such as this very simple "toy server" like > > https://github.com/stackbox/code/tree/master/tinyhttpd-0.1.0 > > everything works well even with big files. > > So probably there is some usage of socket functions by thttpd-2.25b that > > creates problems. Unfortunately I was not so good to debug it with the gdb > > command. > > thanks for the info. > just curious: did you rung tinyhttpd over DCE ? Yes: just compile with (e.g.): gcc -fPIC -U_FORTIFY_SOURCE -Wall -o httpd httpd.c -pie -lpthread Also, to simplify things, I removed the option to run "cgi" scripts in the httpd.c source code: from line 118 on, just leave the serve_file(client, path); call, and remove the check if the file is executable etc. Thanks for your help!