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 parserInfo = parse(buf, parser);
my grammar: (cutted some rules to limit length ;-))
--------------------------------------------------------
#ifndef BASIC_HTTP_GRAMMAR_H_
#define BASIC_HTTP_GRAMMAR_H_
#include
#include
#include
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 headerMap; };
#endif /*BASIC_HTTP_GRAMMAR_H_*/