|
Boost Users : |
From: Andreas Bruckmeier (dev_at_[hidden])
Date: 2008-03-06 16:59:04
Hi out there,
after searching for the cause of segmentation faults in my program
i figured out that it happens while parsing my grammar with spirit.
But this happens only if i run multiple threads,
with only one thread all works as expected.
I used the current boost trunk, gcc 4.1.2 and option D_REENTRANT
Does anybody have a clue what happens inside parse(...)
that could cause this segfault?
Best regards
Andi
calling code: ('buf' is a zero-terminated string)
--------------------------------------------------------
HttpRequestGrammar parser;
parse_info<const char*> parserInfo = parse(buf, parser);
my grammar: (cutted some rules to limit length ;-))
--------------------------------------------------------
#ifndef BASIC_HTTP_GRAMMAR_H_
#define BASIC_HTTP_GRAMMAR_H_
#include <boost/spirit/core.hpp>
#include <boost/spirit/actor/assign_actor.hpp>
#include <boost/spirit/actor/insert_at_actor.hpp>
using namespace boost::spirit;
struct HttpRequestGrammar : public grammar<HttpRequestGrammar> {
template <typename ScannerT> struct definition {
definition(HttpRequestGrammar const& self) {
first = (
request = *( SP | CRLF ) >> requestLine >> CRLF
>> *(( generalHeader | requestHeader |
entityHeader ) >> CRLF) >> CRLF,
requestLine = method[insert_at_a(self.headerMap,
"method")] >> SP
>> requestUri[insert_at_a(self.headerMap,
"url")]
>> SP >>
httpVersion[insert_at_a(self.headerMap, "version")],
method = str_p("GET") | "HEAD",
...
..
token = +graph_p,
SP = str_p(" "),
CRLF = str_p("\r\n")
);
}
subrule<0> request;
subrule<1> requestLine;
subrule<2> generalHeader;
...
..
subrule<1000> SP;
subrule<1001> CRLF;
rule<ScannerT> first;
rule<ScannerT> const&
start() const {
return first;
}
};
mutable std::map<std::string, std::string> headerMap; };
#endif /*BASIC_HTTP_GRAMMAR_H_*/
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net