Segmentation fault, Bro and a Debian

Hi,

I try to use bro under Debian un-stable (today upgrade) and after some
light modification, I was able to compile bro. But after that, I 've a
segmentation fault...

First, modifications :

1- I've some gcc 3.2.3 problem which looks like :

g++ -o bif_parse.o -c bif_parse.cc
builtin-func.y:63: 'vector' is used as a type, but is not defined as a type.
builtin-func.y: In function `int yyparse()':
builtin-func.y:151: `args' undeclared (first use this function)
builtin-func.y:151: (Each undeclared identifier is reported only once for each
   function it appears in.)
make: *** [bif_parse.o] Error 1

I solve them by added "using namespace std;" just after the include headers.

Same things with Type.h and Anon.h

2- The "yy_current_buffer" (line 474) not declare... I change "if (
   yy_current_buffer )" it by "if ( YY_CURRENT_BUFFER )" and the
   compilation continue.

3- I replace '#include <hash_map>' by '#include <hash_map.h>' because,
   hash_map wasn't founded. This work fine but added a warning like that:

/usr/include/c++/3.2/backward/backward_warning.h:32:2: warning:
#warning This file includes at least one deprecated or antiquated
header. Please consider using one of the 32 headers found in section
17.4.1.2 of the C++ standard. Examples include substituting the <X>
header for the <X.h> header for C++ includes, or <sstream> instead of
the deprecated header <strstream.h>. To disable this warning use
-Wno-deprecated.

4- The function isspace wasn't founded too in Debug.cc, so I added
   "#include <ctype.h>"

5- The DebugCmds.cc file generate a problem too :

g++ -I. -Ilibedit -O -Ilinux-include -c DebugCmds.cc
DebugCmds.cc: In function `int find_all_matching_cmds(const std::string&, const
   char**)':
DebugCmds.cc:164: invalid conversion from `const char*' to `unsigned int'
DebugCmds.cc:164: initializing argument 1 of `int std::basic_string<_CharT,
   _Traits, _Alloc>::compare(_Alloc::size_type, _Alloc::size_type, const
   _CharT*) const [with _CharT = char, _Traits = std::char_traits<char>, _Alloc
   = std::allocator<char>]'
DebugCmds.cc:164: invalid conversion from `unsigned int' to `const char*'
DebugCmds.cc:164: initializing argument 3 of `int std::basic_string<_CharT,
   _Traits, _Alloc>::compare(_Alloc::size_type, _Alloc::size_type, const
   _CharT*) const [with _CharT = char, _Traits = std::char_traits<char>, _Alloc
   = std::allocator<char>]'
make: *** [DebugCmds.o] Error 1

I just change "if ( prefix.compare(curr_name, 0, arglen ) )" by "if (
prefix.compare(arglen, 0, curr_name ) )"

6- A classical link problem with bro compilation under Linux, solve by
   replacing: "-lresolv" by "/usr/lib/resolv.a" in the Makefile.

After that, the compilation go to the end but, when I compile bro with
the -g flag and run gdb, I could see that:

(gdb) r -i eth0
Starting program: /usr/local/src/bro-pub-0.8a20/bro -i eth0

Program received signal SIGSEGV, Segmentation fault.
0x401b3364 in strcmp () from /lib/libc.so.6
(gdb) bt
#0 0x401b3364 in strcmp () from /lib/libc.so.6
#1 0x0804db83 in streq(char const*, char const*) (s1=0x0, s2=0x0)
    at util.cc:54
#2 0x0809e5c9 in BroObj::SetLocationInfo(Location const*, Location const*) (
    this=0x812ffb8, start=0xbfffe24c, end=0xbfffe24c) at Obj.cc:99
#3 0x0805c6ff in Attr (this=0x812ffb8, t=ATTR_OPTIONAL, e=0x0) at Attr.cc:42
#4 0x0805070e in yyparse() () at parse.y:868
#5 0x0804cb93 in main (argc=135439840, argv=0xbffffdd4) at main.cc:328

(gdb) p start_location -> first_line
$1 = 137
(gdb) p start_location -> last_line
$2 = 137

I know that I've done too much modification from original
sources... But via some fprintf, I discover that, in the previous call
to this function, the Locations was in the bro.init file.

Does anybody have an idea ?

Thanks for all. Regards,