Skip Menu |

This queue is for tickets about the Catalyst-Action-REST CPAN distribution.

Report information
The Basics
Id: 68202
Status: rejected
Priority: 0/
Queue: Catalyst-Action-REST

People
Owner: Nobody in particular
Requestors: ihh [...] berkeley.edu
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Re: Catalyst::Controller::REST crashes on POST
Date: Sat, 14 May 2011 10:38:44 -0700
To: bug-Catalyst-Action-REST [...] rt.cpan.org
From: Ian Holmes <ihh [...] berkeley.edu>
Update: this now appears to be an XML::Simple bug, triggered on deserialization. % cat >! test <test><a>blah</a></test> % perl -e 'use XML::Simple;my $xs = XML::Simple->new();my $rdata = $xs->XMLin("test")' Segmentation fault Note this works fine if the XML is quoted % perl -e 'use XML::Simple;my $xs = XML::Simple->new();my$rdata = $xs->XMLin( "<test><a>blah</a></test>" );print $rdata' HASH(0x1009c4470) Anyway - it appears not to be a Catalyst bug. On 5/14/11 9:57 AM, Ian Holmes wrote: Show quoted text
> Hi, this is a repost of a question posted at stackoverflow; as it > appears to be a bug, rafl on #catalyst suggested I direct it here. > > Unfortunately, I can only reproduce this on one of my machines, so I > think it may be of limited use. Here it is anyway. > > http://stackoverflow.com/questions/5987810/why-does-a-curl-post-request-crash-my-catalystcontrollerrest-controller > > > So, I'm using Catalyst to build a RESTful web service, so I create a > Catalyst controller in the usual way > > script/myapp_create.pl controller MyApp::Controller > > I then fire up the catalyst test server > > script/zoo_server.pl -rd > > So far so good - I can now go to http://localhost:3000/user and see the > message "Matched MyApp::Controller::User in User." > > I then replace the BEGIN line in lib/MyApp/Controller/User.pm with the > following line > > BEGIN { extends 'Catalyst::Controller::REST' } > > Before doing anything else, I want to check my ability to execute a POST > request and watch the response. So in another terminal window, I type > > curl http://localhost:3000/user --verbose --data > "<test><m>whatever</m></test>" -H "Content-Type: text/xml" > > At this point, since I have not implemented any POST methods, I am > expecting to see a "405 Method Not Allowed" response. Instead, what I > see from curl is this: > > * About to connect() to localhost port 3000 (#0) > * Trying 127.0.0.1... connected > * Connected to localhost (127.0.0.1) port 3000 (#0)
> > POST /user HTTP/1.1 > > User-Agent: curl/7.19.6 (i386-apple-darwin10.0.0) libcurl/7.19.6
> zlib/1.2.5
> > Host: localhost:3000 > > Accept: */* > > Content-Type: text/xml > > Content-Length: 28 > >
> * Empty reply from server > * Connection #0 to host localhost left intact > curl: (52) Empty reply from server > * Closing connection #0 > > This then appears to crash catalyst's test server. The server does not > log anything, but future attempts to contact the server, e.g. doing > another GET request to "localhost:3000/user", results in "couldn't > connect to host" errors from curl. > > I note that this only happens if I use Catalyst::Controller::REST. If I > just make a regular controller, POSTing to it does not crash anything. > So I'm assuming it happens on the deserialization action, which will be > delegated to XML::Simple (as per the default for > Catalyst::Controller::REST). Any ideas? > > What I eventually want to do, by the way, is create a method like sub > thing :Local :ActionClass('REST') ..., and a corresponding sub > thing_POST. My understanding is that POST requests to /user/thing > containing XML should then automatically get deserialized and put it > into $c->request->data, before thing_POST is called. The above tests are > a preliminary to this - designed to check what happens if no POST method > is defined. (For what it's worth, I get exactly the same behavior if I > create sub thing and sub thing_POST, and then use curl to issue a POST > request to /user/thing.)
Subject: Re: [rt.cpan.org #68202] AutoReply: Re: Catalyst::Controller::REST crashes on POST
Date: Sat, 14 May 2011 11:02:24 -0700
To: bug-Catalyst-Action-REST [...] rt.cpan.org
From: Ian Holmes <ihh [...] berkeley.edu>
FWIW, I have now traced this to my XML::SAX installation: % cat >! ~/tmp/test <test><a>blah</a></test> % perl -d:bt -e 'use XML::SAX;my $sp = XML::SAX::ParserFactory->parser;my $tree = $sp->parse_uri("test")' #0 0x00007fff88a9a650 in __wait4 () #1 0x000000010017a679 in signal_handler () #2 <signal handler called> #3 0x00007fff88a4e7f3 in strncmp () #4 0x0000000100435434 in __xmlParserInputBufferCreateFilename () #5 0x000000010040a1fd in xmlNewInputFromFile () #6 0x000000010040ca77 in xmlCreateURLParserCtxt () #7 0x0000000100199078 in XS_XML__LibXML__parse_sax_file () #8 0x0000000100073bdc in Perl_pp_entersub () #9 0x000000010006c126 in Perl_runops_standard () #10 0x00000001000688f6 in perl_run () #11 0x00000001000014ec in main () Abort On 5/14/11 10:38 AM, Bugs in Catalyst-Action-REST via RT wrote: Show quoted text
> > Greetings, > > This message has been automatically generated in response to the > creation of a trouble ticket regarding: > "Re: Catalyst::Controller::REST crashes on POST", > a summary of which appears below. > > There is no need to reply to this message right now. Your ticket has been > assigned an ID of [rt.cpan.org #68202]. Your ticket is accessible > on the web at: > > https://rt.cpan.org/Ticket/Display.html?id=68202 > > Please include the string: > > [rt.cpan.org #68202] > > in the subject line of all future correspondence about this issue. To do so, > you may reply to this message. > > Thank you, > bug-Catalyst-Action-REST@rt.cpan.org > > ------------------------------------------------------------------------- > Update: this now appears to be an XML::Simple bug, triggered on > deserialization. > > % cat>! test > <test><a>blah</a></test> > % perl -e 'use XML::Simple;my $xs = XML::Simple->new();my $rdata = > $xs->XMLin("test")' > Segmentation fault > > > Note this works fine if the XML is quoted > % perl -e 'use XML::Simple;my $xs = XML::Simple->new();my$rdata = > $xs->XMLin( "<test><a>blah</a></test>" );print $rdata' > HASH(0x1009c4470) > > > Anyway - it appears not to be a Catalyst bug. > > > On 5/14/11 9:57 AM, Ian Holmes wrote:
>> Hi, this is a repost of a question posted at stackoverflow; as it >> appears to be a bug, rafl on #catalyst suggested I direct it here. >> >> Unfortunately, I can only reproduce this on one of my machines, so I >> think it may be of limited use. Here it is anyway. >> >> http://stackoverflow.com/questions/5987810/why-does-a-curl-post-request-crash-my-catalystcontrollerrest-controller >> >> >> So, I'm using Catalyst to build a RESTful web service, so I create a >> Catalyst controller in the usual way >> >> script/myapp_create.pl controller MyApp::Controller >> >> I then fire up the catalyst test server >> >> script/zoo_server.pl -rd >> >> So far so good - I can now go to http://localhost:3000/user and see the >> message "Matched MyApp::Controller::User in User." >> >> I then replace the BEGIN line in lib/MyApp/Controller/User.pm with the >> following line >> >> BEGIN { extends 'Catalyst::Controller::REST' } >> >> Before doing anything else, I want to check my ability to execute a POST >> request and watch the response. So in another terminal window, I type >> >> curl http://localhost:3000/user --verbose --data >> "<test><m>whatever</m></test>" -H "Content-Type: text/xml" >> >> At this point, since I have not implemented any POST methods, I am >> expecting to see a "405 Method Not Allowed" response. Instead, what I >> see from curl is this: >> >> * About to connect() to localhost port 3000 (#0) >> * Trying 127.0.0.1... connected >> * Connected to localhost (127.0.0.1) port 3000 (#0)
>> > POST /user HTTP/1.1 >> > User-Agent: curl/7.19.6 (i386-apple-darwin10.0.0) libcurl/7.19.6
>> zlib/1.2.5
>> > Host: localhost:3000 >> > Accept: */* >> > Content-Type: text/xml >> > Content-Length: 28 >> >
>> * Empty reply from server >> * Connection #0 to host localhost left intact >> curl: (52) Empty reply from server >> * Closing connection #0 >> >> This then appears to crash catalyst's test server. The server does not >> log anything, but future attempts to contact the server, e.g. doing >> another GET request to "localhost:3000/user", results in "couldn't >> connect to host" errors from curl. >> >> I note that this only happens if I use Catalyst::Controller::REST. If I >> just make a regular controller, POSTing to it does not crash anything. >> So I'm assuming it happens on the deserialization action, which will be >> delegated to XML::Simple (as per the default for >> Catalyst::Controller::REST). Any ideas? >> >> What I eventually want to do, by the way, is create a method like sub >> thing :Local :ActionClass('REST') ..., and a corresponding sub >> thing_POST. My understanding is that POST requests to /user/thing >> containing XML should then automatically get deserialized and put it >> into $c->request->data, before thing_POST is called. The above tests are >> a preliminary to this - designed to check what happens if no POST method >> is defined. (For what it's worth, I get exactly the same behavior if I >> create sub thing and sub thing_POST, and then use curl to issue a POST >> request to /user/thing.)
According to this backtrace, this is a bug in libxml2. The same code works fine on different versions of libxml2. There's nothing we can do about this - apparently it's an already fixed bug in libxml2.