stash / Feersum

A PSGI engine for Perl based on EV/libev
http://search.cpan.org/~stash/Feersum/
74 stars 15 forks source link

Make error #1

Closed nmani closed 14 years ago

nmani commented 14 years ago

cp lib/Feersum.pm blib/lib/Feersum.pm /usr/bin/perl /usr/local/share/perl/5.10.0/ExtUtils/xsubpp -typemap /usr/share/perl/5.10/ExtUtils/typemap -typemap typemap Feersum.xs > Feersum.xsc && mv Feersum.xsc Feersum.c cc -c -I. -I/usr/local/lib/perl/5.10.0/EV -I/usr/local/lib/perl/5.10.0 -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g -DVERSION=\"0.02\" -DXS_VERSION=\"0.02\" -fPIC "-I/usr/lib/perl/5.10/CORE" Feersum.c Feersum.xs:13:47: error: picohttpparser-git/picohttpparser.c: No such file or directory Feersum.xs:59: error: array type has incomplete element type Feersum.xs: In function ‘new_feer_conn’: Feersum.xs:262: warning: format not a string literal and no format arguments Feersum.xs:265: warning: format ‘%ld’ expects type ‘long int’, but argument 4 has type ‘int’ Feersum.xs:265: warning: format ‘%ld’ expects type ‘long int’, but argument 4 has type ‘int’ Feersum.xs: In function ‘process_request_headers’: Feersum.xs:695: error: dereferencing pointer to incomplete type Feersum.xs:697: error: dereferencing pointer to incomplete type Feersum.xs:697: error: dereferencing pointer to incomplete type Feersum.xs:698: error: dereferencing pointer to incomplete type Feersum.xs:698: error: dereferencing pointer to incomplete type Feersum.xs: In function ‘XS_FeersumConnectionHandlepoll_cb’: Feersum.xs:1214: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘I32’ Feersum.xs: In function ‘XS_FeersumConnection_write_whole_body’: Feersum.xs:1337: warning: format not a string literal and no format arguments Feersum.xs: In function ‘XS_Feersum__Connection_env’: Feersum.xs:1442: error: dereferencing pointer to incomplete type Feersum.xs:1444: error: dereferencing pointer to incomplete type Feersum.xs:1444: error: dereferencing pointer to incomplete type Feersum.xs:1446: error: dereferencing pointer to incomplete type Feersum.xs:1446: error: dereferencing pointer to incomplete type Feersum.xs:1452: error: dereferencing pointer to incomplete type Feersum.xs:1452: error: dereferencing pointer to incomplete type Feersum.xs:1453: error: dereferencing pointer to incomplete type Feersum.xs:1455: error: dereferencing pointer to incomplete type Feersum.xs:1456: error: dereferencing pointer to incomplete type Feersum.xs:1460: error: dereferencing pointer to incomplete type Feersum.xs:1468: error: dereferencing pointer to incomplete type Feersum.xs:1468: error: dereferencing pointer to incomplete type Feersum.xs:1472: error: dereferencing pointer to incomplete type Feersum.xs:1472: error: dereferencing pointer to incomplete type Feersum.xs: In function ‘boot_Feersum’: Feersum.xs:1535: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘I32’ Feersum.xs:1535: warning: format ‘%d’ expects type ‘int’, but argument 3 has type ‘I32’ make: *\ [Feersum.o] Error 1

stash commented 14 years ago

Hi,

What's your perl configuration (run perl -V)?

Also you may need to run git submodule init then git submodule update to pull in picohttpparser.

Thanks!

nmani commented 14 years ago

I deleted the folder, re-pulled everything and it works now. It makes, the tests all pass, and the example works. My understanding of C + XS, w/ perl is very limited so sorry if I wasn't much of a help. I think that the submodule pull for the submodule didn't work the first time. Great server btw.

PS- You weren't kidding on the performance...

C2Duo 2.00Ghz ab -c 10 -t 1 -k http://localhost:10204/

Requests per second: 7911.98 #/sec Time per request: 1.264 ms Time per request: 0.126 [ms](mean, across all concurrent requests) Transfer rate: 741.75 [Kbytes/sec] received

It randomly seg. fault though after benchmarking several times w/ the settings above (specifically -t 1, I've found out): served 15681 served 15681 Segmentation fault

Using -c 10 -n 10000 -k works fine if you do it a couple of times, but the second you replace '-n ' with '-t 1' and do it more than 3 or 4 times, it'll seg. fault. Once again, very limited knowledge of XS/C + perl and web servers so sorry in advance if the reason is obvious. Just FYI.


make w/ make test: cp lib/Feersum.pm blib/lib/Feersum.pm /usr/bin/perl /usr/local/share/perl/5.10.0/ExtUtils/xsubpp -typemap /usr/share/perl/5.10/ExtUtils/typemap -typemap typemap Feersum.xs > Feersum.xsc && mv Feersum.xsc Feersum.c cc -c -I. -I/usr/local/lib/perl/5.10.0/EV -I/usr/local/lib/perl/5.10.0 -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g -DVERSION=\"0.02\" -DXS_VERSION=\"0.02\" -fPIC "-I/usr/lib/perl/5.10/CORE" Feersum.c Feersum.xs: In function ‘new_feer_conn’: Feersum.xs:262: warning: format not a string literal and no format arguments Feersum.xs:265: warning: format ‘%ld’ expects type ‘long int’, but argument 4 has type ‘int’ Feersum.xs:265: warning: format ‘%ld’ expects type ‘long int’, but argument 4 has type ‘int’ Feersum.xs: In function ‘XS_FeersumConnectionHandlepoll_cb’: Feersum.xs:1214: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘I32’ Feersum.xs: In function ‘XS_FeersumConnection_write_whole_body’: Feersum.xs:1337: warning: format not a string literal and no format arguments Feersum.xs: In function ‘boot_Feersum’: Feersum.xs:1535: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘I32’ Feersum.xs:1535: warning: format ‘%d’ expects type ‘int’, but argument 3 has type ‘I32’ Running Mkbootstrap for Feersum () chmod 644 Feersum.bs rm -f blib/arch/auto/Feersum/Feersum.so cc -shared -O2 -g -L/usr/local/lib Feersum.o -o blib/arch/auto/Feersum/Feersum.so \ \

chmod 755 blib/arch/auto/Feersum/Feersum.so cp Feersum.bs blib/arch/auto/Feersum/Feersum.bs chmod 644 blib/arch/auto/Feersum/Feersum.bs PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t t/01-simple.t ............. 1/30 Feersum: ignoring content-length header in the response at /tmp/Feersum/blib/lib/Feersum.pm line 226. Feersum: ignoring content-length header in the response at /tmp/Feersum/blib/lib/Feersum.pm line 226. t/01-simple.t ............. ok
t/02-array-body.t ......... ok
t/03-env-hash.t ........... ok
t/04-died.t ............... ok
t/05-streaming.t .......... ok
t/06-input.t .............. ok
t/07-graceful-shutdown.t .. ok
t/08-read-timeout.t ....... ok
All tests successful. Files=8, Tests=471, 13 wallclock secs ( 0.09 usr 0.02 sys + 0.94 cusr 0.10 csys = 1.15 CPU) Result: PASS

perl -V: Summary of my perl5 (revision 5 version 10 subversion 0) configuration: Platform: osname=linux, osvers=2.6.24-23-server, archname=i486-linux-gnu-thread-multi uname='linux vernadsky 2.6.24-23-server #1 smp wed apr 1 22:22:14 utc 2009 i686 gnulinux ' config_args='-Dusethreads -Duselargefiles -Dccflags=-DDEBIAN -Dcccdlflags=-fPIC -Darchname=i486-linux-gnu -Dprefix=/usr -Dprivlib=/usr/share/perl/5.10 -Darchlib=/usr/lib/perl/5.10 -Dvendorprefix=/usr -Dvendorlib=/usr/share/perl5 -Dvendorarch=/usr/lib/perl5 -Dsiteprefix=/usr/local -Dsitelib=/usr/local/share/perl/5.10.0 -Dsitearch=/usr/local/lib/perl/5.10.0 -Dman1dir=/usr/share/man/man1 -Dman3dir=/usr/share/man/man3 -Dsiteman1dir=/usr/local/man/man1 -Dsiteman3dir=/usr/local/man/man3 -Dman1ext=1 -Dman3ext=3perl -Dpager=/usr/bin/sensible-pager -Uafs -Ud_csh -Ud_ualarm -Uusesfio -Uusenm -DDEBUGGING=-g -Doptimize=-O2 -Duseshrplib -Dlibperl=libperl.so.5.10.0 -Dd_dosuid -des' hint=recommended, useposix=true, d_sigaction=define useithreads=define, usemultiplicity=define useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef use64bitint=undef, use64bitall=undef, uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64', optimize='-O2 -g', cppflags='-D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fno-strict-aliasing -pipe -I/usr/local/include' ccversion='', gccversion='4.4.1', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=4, prototype=define Linker and Libraries: ld='cc', ldflags =' -L/usr/local/lib' libpth=/usr/local/lib /lib /usr/lib /usr/lib64 libs=-lgdbm -lgdbm_compat -ldb -ldl -lm -lpthread -lc -lcrypt perllibs=-ldl -lm -lpthread -lc -lcrypt libc=/lib/libc-2.10.1.so, so=so, useshrplib=true, libperl=libperl.so.5.10.0 gnulibc_version='2.10.1' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E' cccdlflags='-fPIC', lddlflags='-shared -O2 -g -L/usr/local/lib'

Characteristics of this binary (from libperl): Compile-time options: MULTIPLICITY PERL_DONT_CREATE_GVSV PERL_IMPLICIT_CONTEXT PERL_MALLOC_WRAP USE_ITHREADS USE_LARGE_FILES USE_PERLIO USE_REENTRANT_API Built under linux Compiled at Oct 1 2009 22:19:26 @INC: /etc/perl /usr/local/lib/perl/5.10.0 /usr/local/share/perl/5.10.0 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.10 /usr/share/perl/5.10 /usr/local/lib/site_perl .

stash commented 14 years ago

nmani,

Glad to hear you got it building. Those are certainly impressive times. I'm seeing some odd results with apache-bench over localhost, but haven't been able to track those down yet. I think it's due to Feersum not yet supporting keep-alives (the -k flag for ab) and how ephemeral ports work in most TCP stacks. If you know anything about that, let me know :)

Regarding the segfault, I could use your help in tracking it down. Here's a few things to try.

First, can you try run the Feersum example script under gdb? Looks like you're running ubuntu or debian, so try first install the perl-debug package. Then run gdb debugperl. Once you're in gdb type run example/hello.pl. Once that starts ticking, start ab. A segfault should cause gdb to drop back to a command line, enter bt to get a stack backtrace. Having that output could help me fix the problem.

You can also try compiling Feersum with debug output (this will produce a lot of output) by running perl Makefile.PL OPTIMIZE='-DDEBUG -g' and then make. Let me know the last 200 lines or so before the segfault.

Thanks very much in advance.

Cheers, ~stash

nmani commented 14 years ago

LOL. My understanding of TCP / web servers is at layman level. The low level, practical stuff confuses me. I just learned to parse a Websocket handshake like a day ago. Will I ever write code to do it? Almost certainly not. LOL. =D

served 16355 served 16355 served 21688 served 23248 served 24790

Program received signal SIGSEGV, Segmentation fault. 0x0030bf34 in ev_feed_event (loop=0x31d340, w=0x8589884, revents=256) at libev/ev.c:825

825 pendings [pri][w_->pending - 1].events |= revents;

Using DEBUG on Makefile.PL version, last 200 lines:

Feersum.xs:394: idle! head=0 Feersum.xs:377: prepare! Feersum.xs:387: check! head=0 Feersum.xs:412: going to write 27 96 85f53a4 Feersum.xs:416: wrote 96 bytes to 27 Feersum.xs:426: All done with 27 Feersum.xs:449: ref dec after write 27 Feersum.xs:1489: DESTROY conn 27 85941c4 SV = PVMG(0x82b9594) at 0x859273c REFCNT = 1 FLAGS = (OBJECT,IOK,POK,READONLY,pIOK,pPOK) IV = 27 NV = 0 PV = 0x85941c4 "27"\0 CUR = 2 LEN = 224 STASH = 0x8345b94 "Feersum::Connection" Feersum.xs:412: going to write 28 96 85f3394 Feersum.xs:416: wrote 96 bytes to 28 Feersum.xs:426: All done with 28 Feersum.xs:449: ref dec after write 28 Feersum.xs:1489: DESTROY conn 28 85d9b14 SV = PVMG(0x82b94b4) at 0x859252c REFCNT = 1 FLAGS = (OBJECT,IOK,POK,READONLY,pIOK,pPOK) IV = 28 NV = 0 PV = 0x85d9b14 "28"\0 CUR = 2 LEN = 224 STASH = 0x8345b94 "Feersum::Connection" Feersum.xs:412: going to write 29 96 85b0544 Feersum.xs:416: wrote 96 bytes to 29 Feersum.xs:426: All done with 29 Feersum.xs:449: ref dec after write 29 Feersum.xs:1489: DESTROY conn 29 85d9c64 SV = PVMG(0x82b9578) at 0x85929cc REFCNT = 1 FLAGS = (OBJECT,IOK,POK,READONLY,pIOK,pPOK) IV = 29 NV = 0 PV = 0x85d9c64 "29"\0 CUR = 2 LEN = 224 STASH = 0x8345b94 "Feersum::Connection" Feersum.xs:412: going to write 30 96 85ae534 Feersum.xs:416: wrote 96 bytes to 30 Feersum.xs:426: All done with 30 Feersum.xs:449: ref dec after write 30 Feersum.xs:1489: DESTROY conn 30 85d9db4 SV = PVMG(0x82b95cc) at 0x8592b9c REFCNT = 1 FLAGS = (OBJECT,IOK,POK,READONLY,pIOK,pPOK) IV = 30 NV = 0 PV = 0x85d9db4 "30"\0 CUR = 2 LEN = 224 STASH = 0x8345b94 "Feersum::Connection" Feersum.xs:377: prepare! Feersum.xs:387: check! head=0 Feersum.xs:609: accept! revents=0x00000001 Feersum.xs:292: made conn fd=27 self=8592bbc, c=859385c, cur=2, len=224 Feersum.xs:292: made conn fd=28 self=8592f2c, c=85939ac, cur=2, len=224 Feersum.xs:292: made conn fd=29 self=8592e9c, c=8593afc, cur=2, len=224 Feersum.xs:292: made conn fd=30 self=8592fbc, c=859341c, cur=2, len=224 Feersum.xs:292: made conn fd=31 self=859303c, c=859356c, cur=2, len=224 Feersum.xs:292: made conn fd=32 self=8592f4c, c=85936bc, cur=2, len=224 Feersum.xs:292: made conn fd=33 self=8592fdc, c=85d9f64, cur=2, len=224 Feersum.xs:377: prepare! Feersum.xs:387: check! head=0 Feersum.xs:486: try read 33 Feersum.xs:489: init rbuf for 33 Feersum.xs:513: read 33 83 Feersum.xs:653: body follows headers, making new rbuf Feersum.xs:638: rinq push: c=85d9f64, head=0 Feersum.xs:486: try read 32 Feersum.xs:489: init rbuf for 32 Feersum.xs:513: read 32 83 Feersum.xs:653: body follows headers, making new rbuf Feersum.xs:638: rinq push: c=85936bc, head=8509408 Feersum.xs:486: try read 31 Feersum.xs:489: init rbuf for 31 Feersum.xs:513: read 31 83 Feersum.xs:653: body follows headers, making new rbuf Feersum.xs:638: rinq push: c=859356c, head=8509408 Feersum.xs:486: try read 30 Feersum.xs:489: init rbuf for 30 Feersum.xs:513: read 30 83 Feersum.xs:653: body follows headers, making new rbuf Feersum.xs:638: rinq push: c=859341c, head=8509408 Feersum.xs:486: try read 29 Feersum.xs:489: init rbuf for 29 Feersum.xs:513: read 29 83 Feersum.xs:653: body follows headers, making new rbuf Feersum.xs:638: rinq push: c=8593afc, head=8509408 Feersum.xs:486: try read 28 Feersum.xs:489: init rbuf for 28 Feersum.xs:513: read 28 83 Feersum.xs:653: body follows headers, making new rbuf Feersum.xs:638: rinq push: c=85939ac, head=8509408 Feersum.xs:486: try read 27 Feersum.xs:489: init rbuf for 27 Feersum.xs:513: read 27 83 Feersum.xs:653: body follows headers, making new rbuf Feersum.xs:638: rinq push: c=859385c, head=8509408 Feersum.xs:377: prepare! Feersum.xs:387: check! head=8509408 Feersum.xs:362: rinq shifted c=85d9f64, head=853dde8 Feersum.xs:312: c->self not yet an object, SvCUR:2 Feersum.xs:931: request callback c=85d9f64 self=859338c Feersum.xs:939: calling request callback, errsv? 0 Feersum.xs:1462: adding header to env HTTP_HOST: localhost:10204 Feersum.xs:1462: adding header to env HTTP_USER_AGENT: ApacheBench/2.3 Feersum.xs:1462: adding header to env HTTPACCEPT: /_ Feersum.xs:1230: start_response fd=33 streaming=0 Feersum.xs:324: sv 2 conn_handle Feersum.xs:1072: DESTROY handle fd=33, class=Feersum::Connection::Reader Feersum.xs:945: called request callback, errsv? 0 Feersum.xs:961: leaving request callback Feersum.xs:362: rinq shifted c=85936bc, head=85578a8 Feersum.xs:312: c->self not yet an object, SvCUR:2 Feersum.xs:931: request callback c=85936bc self=85f73e4 Feersum.xs:939: calling request callback, errsv? 0 Feersum.xs:1462: adding header to env HTTP_HOST: localhost:10204 Feersum.xs:1462: adding header to env HTTP_USER_AGENT: ApacheBench/2.3 Feersum.xs:1462: adding header to env HTTPACCEPT: /_ Feersum.xs:1230: start_response fd=32 streaming=0 Feersum.xs:324: sv 2 conn_handle Feersum.xs:1072: DESTROY handle fd=32, class=Feersum::Connection::Reader Feersum.xs:945: called request callback, errsv? 0 Feersum.xs:961: leaving request callback Feersum.xs:362: rinq shifted c=859356c, head=853d738 Feersum.xs:312: c->self not yet an object, SvCUR:2 Feersum.xs:931: request callback c=859356c self=85f74e4 Feersum.xs:939: calling request callback, errsv? 0 Feersum.xs:1462: adding header to env HTTP_HOST: localhost:10204 Feersum.xs:1462: adding header to env HTTP_USER_AGENT: ApacheBench/2.3 Feersum.xs:1462: adding header to env HTTPACCEPT: /_ Feersum.xs:1230: start_response fd=31 streaming=0 Feersum.xs:324: sv 2 conn_handle Feersum.xs:1072: DESTROY handle fd=31, class=Feersum::Connection::Reader Feersum.xs:945: called request callback, errsv? 0 Feersum.xs:961: leaving request callback Feersum.xs:362: rinq shifted c=859341c, head=8552a30 Feersum.xs:312: c->self not yet an object, SvCUR:2 Feersum.xs:931: request callback c=859341c self=85f7404 Feersum.xs:939: calling request callback, errsv? 0 Feersum.xs:1462: adding header to env HTTP_HOST: localhost:10204 Feersum.xs:1462: adding header to env HTTP_USER_AGENT: ApacheBench/2.3 Feersum.xs:1462: adding header to env HTTPACCEPT: /_ Feersum.xs:1230: start_response fd=30 streaming=0 Feersum.xs:324: sv 2 conn_handle Feersum.xs:1072: DESTROY handle fd=30, class=Feersum::Connection::Reader Feersum.xs:945: called request callback, errsv? 0 Feersum.xs:961: leaving request callback Feersum.xs:362: rinq shifted c=8593afc, head=84570f8 Feersum.xs:312: c->self not yet an object, SvCUR:2 Feersum.xs:931: request callback c=8593afc self=85f7524 Feersum.xs:939: calling request callback, errsv? 0 Feersum.xs:1462: adding header to env HTTP_HOST: localhost:10204 Feersum.xs:1462: adding header to env HTTP_USER_AGENT: ApacheBench/2.3 Feersum.xs:1462: adding header to env HTTPACCEPT: /_ Feersum.xs:1230: start_response fd=29 streaming=0 Feersum.xs:324: sv 2 conn_handle Feersum.xs:1072: DESTROY handle fd=29, class=Feersum::Connection::Reader Feersum.xs:945: called request callback, errsv? 0 Feersum.xs:961: leaving request callback Feersum.xs:362: rinq shifted c=85939ac, head=84d0b08 Feersum.xs:312: c->self not yet an object, SvCUR:2 Feersum.xs:931: request callback c=85939ac self=85f7484 Feersum.xs:939: calling request callback, errsv? 0 Feersum.xs:1462: adding header to env HTTP_HOST: localhost:10204 Feersum.xs:1462: adding header to env HTTP_USER_AGENT: ApacheBench/2.3 Feersum.xs:1462: adding header to env HTTPACCEPT: /_ Feersum.xs:1230: start_response fd=28 streaming=0 Feersum.xs:324: sv 2 conn_handle Feersum.xs:1072: DESTROY handle fd=28, class=Feersum::Connection::Reader Feersum.xs:945: called request callback, errsv? 0 Feersum.xs:961: leaving request callback Feersum.xs:362: rinq shifted c=859385c, head=0 Feersum.xs:312: c->self not yet an object, SvCUR:2 Feersum.xs:931: request callback c=859385c self=85f7514 Feersum.xs:939: calling request callback, errsv? 0 Feersum.xs:1462: adding header to env HTTP_HOST: localhost:10204 Feersum.xs:1462: adding header to env HTTP_USER_AGENT: ApacheBench/2.3 Feersum.xs:1462: adding header to env HTTPACCEPT: /_ Feersum.xs:1230: start_response fd=27 streaming=0 Feersum.xs:324: sv 2 conn_handle Feersum.xs:1072: DESTROY handle fd=27, class=Feersum::Connection::Reader Feersum.xs:945: called request callback, errsv? 0 Feersum.xs:961: leaving request callback Feersum.xs:394: idle! head=0 Feersum.xs:377: prepare!

Program received signal SIGSEGV, Segmentation fault. 0x0030bf30 in ev_feedevent (loop=0x31d340, w=0x84da544, revents=256) at libev/ev.c:825 825 pendings [pri][w->pending - 1].events |= revents;

stash commented 14 years ago

Great, this is just what i needed. I see the same error in my development environment so hopefully i can get this fixed soon.

Thanks again, ~stash

stash commented 14 years ago

OK, found the cause, i think; i wasn't stopping the read timeout timer properly. Should be fixed as of 2be787c325ab29d5145a7cb5caeb88bf77e5fff5

~stash

nmani commented 14 years ago

No more seg. fault. GJ.