Master wont compile on FreeBSD
While trying the new 1.4.0-rc2 I found out that master branch no longer compiles under FreeBSD.
CC option.o
option.c:55:17: warning: implicit declaration of function 'get_current_dir_name' is invalid in C99 [-Wimplicit-function-declaration]
char *pwd = get_current_dir_name();
^
option.c:55:11: warning: incompatible integer to pointer conversion initializing 'char *' with an expression of type 'int' [-Wint-conversion]
char *pwd = get_current_dir_name();
^ ~~~~~~~~~~~~~~~~~~~~~~
CCLD sngrep
option.o: In function `init_options':
option.c:(.text+0x22): undefined reference to `get_current_dir_name'
cc: error: linker command failed with exit code 1 (use -v to see invocation)
just a quick grep get_current_dir_name /usr/include/unistd.h shows that this function is not defined in unistd.h on FreeBSD.
Just reporting back because I still would like to use it on FreeBSD systems, because I helps a lot.
Sorry, that was introduced in the last commit, thanks a lot for testing the release candidate to detect this kind of bugs!!
Could you please give it a try to the latest commit? (rc3)
Compiles but throws segfault
#0 0x000000080208f080 in getcwd () from /lib/libc.so.7
#1 0x000000000040fbc5 in init_options ()
#2 0x000000000040f0c6 in main ()
Umm quite strange, it works in my testing bsd environment.
The documentation says:
The ability to specify a NULL pointer and have getcwd() allocate memory as
necessary is an extension.
I will ignore that and allocate the memory to store the path myself :)
I can start it up on a freebsd machine of mine running 11-stable. I don't have any sip traffic on this computer so I don't know when the segfault happens.
For these systems, I usually check with the pcap file in tests directory called aaa.pcap :angel:
Thanks for the input jungle!
Strange it will segfault with just right away with any kind of parameters, even with none. Will test it tomorrow with clean fresh checkout again, maybe some error on my side.
Just to check: Is your current path longer than 1024 chars? Thats the max path value that can be stored in the savepath setting
Fresh clean checkout from git, build, test ... segfault.
I think /root shouldn't be the problem.
Btw: the version 10.3-RELEASE-p1
It seems clear that the getcwd function is the problem, but this little snippet is more or less the way the function is used in sngrep, and seems to work in my testing environment. If It crashes for you, then I will try to install a 10.3 to see if I can reproduce the error or look for another way to implement it.
[root@freebsd /tmp/freebsdtest]# freebsd-version
10.2-RELEASE
[root@freebsd /tmp/freebsdtest]# cat getcurdir.c
/*
gcc -o getcurdir getcurdir.c ; ./getcurdir
*/
#include <unistd.h>
#include <stdio.h>
#define BUFSIZE 1024
int main()
{
char buf[BUFSIZE];
printf("Current directory: %s\n", getcwd(buf, BUFSIZE));
return 0;
}
[root@freebsd /tmp/freebsdtest]# gcc -o getcurdir getcurdir.c ; ./getcurdir
Current directory: /tmp/freebsdtest
This snippet works for me, strange.
I am going to make a debug build tomorrow and will debug what is happening there.
@dunst0,
what's your config options? Are you using the native compiler (clang)?
BTW, I'd recommend upgrading to the latest patches. There's been many patches since p1.
I tried on 11-stable and @Kaian has used 10.1. I'll try a 10.3 machine I have.
@jungle-boogie right now it is a test environment, so I didn't kept it updated all the time
Native clang compiler
# clang --version
FreeBSD clang version 3.4.1 (tags/RELEASE_34/dot1-final 208032) 20140512
Target: x86_64-unknown-freebsd10.3
Thread model: posix
configure options:
# env CFLAGS="-I/usr/include -I/usr/local/include" LDFLAGS="-L/usr/lib -L/usr/local/lib" ./configure --enable-ipv6 --enable-eep --with-openssl --with-pcre
And right now I found the problem could be the C and LD flags
Without --with-pcre and the flags it didn't crash, sad because the pcre was nice
Don't be sad. Once it worked. We'll make it work again :smile: :eyes:
Thanks for all the debugging!!
Thankyou for the wonderfull tool :+1:
Btw I have under FreeBSD incomplete packages captured.
It must be a problem related with 10.3 or something in your local dir. This is my build log: https://gist.github.com/Kaian/d33b496da89f19e4ec3bada9f9859e83
For the incomplete issue, if you can send me a pcap, we can make another issue and try to solve the problem. In some known cases, while using sngrep with bpf filters (port 5060 for example) and IP fragmentation occurs not all fragments are passed to the application by the libpcap library.
Works fine for me on 10.3 p4 with the same config options.
configure: ======================================================
configure: GnuTLS Support : no
configure: OpenSSL Support : yes
configure: Unicode Support : no
configure: Perl Expressions Support : yes
configure: IPv6 Support : yes
configure: EEP Support : yes
configure: ======================================================
I'm able to open aaaa.pcap and run sngrep without a segfault.
Regarding pcre, we have this github issue that us three chatted about: https://github.com/irontec/sngrep/issues/88