-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Segmentation fault #3
Comments
Hmmm I can't repro this. What options are you running it with? |
I'm not passing any options, just running it as root. I'm not very familiar with debugging programs but if there is anything I can do to help track this down I can try it. I've tried running iptstate with gdb and this is what I got (although no idea of what I'm looking at): (gdb) backtrace |
I'm seeing this issue as well: Crashes just by starting it. It'll display the initial table of packets/connections once, then crash (probably during updating internal state.) Reading the error message, that's probably a problem with malloc()/free() or new/delete, and indeed running it with valgrind shows many messages like: ==13911== Invalid free() / delete / delete[] / realloc() |
Yeah - but we don't do any memory management directly - we literally just use vectors, clear them, push things on, and then re-clear them (for some history on valgrind and iptstate, see https://www.phildev.net/iptstate/memleak.shtml) - you can see in the |
First of all, I'm not a C++ guru. However, I looked at the sources and (with current git), I wonder about the conntrack_hook() function. My reading is, that in line 974, an automatic (only on stack!) variable is created: That's being worked on, until the end of conntrack_hook(): ...where |
Hmmm... that would explain it... we can certainly try that. It's odd that that would actually work in the vast majority of cases though. I suspect a more-strict version of g++ has made it's way into the world. |
Had another look at it. Using qsort() on a std::vector doesn't look too healthy to me as well. |
Arch Linux Same issue. Start it and it shows the table for a few seconds then crashes. #0 0xb7fdbc11 in __kernel_vsyscall () |
Same issue, ArchLinux, kernel 4.6.3, glibc 2.23. Starts (without any option), shows the table for half a second and segfaults. |
Yepp. Same here. :( iptstate[20826]: segfault at 0 ip 00007f05dadbd9c4 sp 00007fff17331a68 error 4 in libc-2.23.so[7f05dad45000+197000] Debian unstable/sid |
Same issue on Arch. |
Sorry - I've been traveling nonstop... I'll try to have a look at this soon. |
I pushed a branch called That branch has several broken features: reverse sorting doesn't work, sorting by IP is now much more naive... I'll fix all that before I merge if this works, I just don't want to do that before I know if those worked. |
That seems to have fixed the segfault for me. |
Thanks @rookierks - I'll try to clean this up and get it merged soon. |
|
Latest segfault branch code works fine for me. |
The refactor for #3 introduced a minor bug that broke `std::sort()` on DstIP sorting. Fixed. Signed-off-by: Phil Dibowitz <phil@ipom.com>
iptstate 2.2.6 has been released with this fix. |
I'm having trouble with the current release and current git versions.
It runs and displays the state once but then I get a segmentation fault, it seems to be when the screen is about to be refreshed the first time.
I get the following with the current git version:
*** Error in `./iptstate': munmap_chunk(): invalid pointer: 0x000000000474dec0 ***
======= Backtrace: =========
/usr/lib/libc.so.6(+0x72055)[0x7fc03e3c8055]
/usr/lib/libc.so.6(+0x779a6)[0x7fc03e3cd9a6]
./iptstate[0x406198]
./iptstate[0x403850]
/usr/lib/libc.so.6(__libc_start_main+0xf0)[0x7fc03e376610]
./iptstate[0x404a79]
======= Memory map: ========
00400000-00412000 r-xp 00000000 00:28 1450709 /tmpfs/iptstate/iptstate
00612000-00613000 rw-p 00012000 00:28 1450709 /tmpfs/iptstate/iptstate
023ca000-04770000 rw-p 00000000 00:00 0 [heap]
7fc03dd37000-7fc03dd42000 r-xp 00000000 fe:00 1887597 /usr/lib/libnss_files-2.22.so
7fc03dd42000-7fc03df41000 ---p 0000b000 fe:00 1887597 /usr/lib/libnss_files-2.22.so
7fc03df41000-7fc03df42000 r--p 0000a000 fe:00 1887597 /usr/lib/libnss_files-2.22.so
7fc03df42000-7fc03df43000 rw-p 0000b000 fe:00 1887597 /usr/lib/libnss_files-2.22.so
7fc03df43000-7fc03df49000 rw-p 00000000 00:00 0
7fc03df49000-7fc03df4d000 r-xp 00000000 fe:00 1886093 /usr/lib/libmnl.so.0.1.0
7fc03df4d000-7fc03e14d000 ---p 00004000 fe:00 1886093 /usr/lib/libmnl.so.0.1.0
7fc03e14d000-7fc03e14e000 r--p 00004000 fe:00 1886093 /usr/lib/libmnl.so.0.1.0
7fc03e14e000-7fc03e14f000 rw-p 00005000 fe:00 1886093 /usr/lib/libmnl.so.0.1.0
7fc03e14f000-7fc03e155000 r-xp 00000000 fe:00 1886027 /usr/lib/libnfnetlink.so.0.2.0
7fc03e155000-7fc03e354000 ---p 00006000 fe:00 1886027 /usr/lib/libnfnetlink.so.0.2.0
7fc03e354000-7fc03e355000 r--p 00005000 fe:00 1886027 /usr/lib/libnfnetlink.so.0.2.0
7fc03e355000-7fc03e356000 rw-p 00006000 fe:00 1886027 /usr/lib/libnfnetlink.so.0.2.0
7fc03e356000-7fc03e4f1000 r-xp 00000000 fe:00 1886852 /usr/lib/libc-2.22.so
7fc03e4f1000-7fc03e6f0000 ---p 0019b000 fe:00 1886852 /usr/lib/libc-2.22.so
7fc03e6f0000-7fc03e6f4000 r--p 0019a000 fe:00 1886852 /usr/lib/libc-2.22.so
7fc03e6f4000-7fc03e6f6000 rw-p 0019e000 fe:00 1886852 /usr/lib/libc-2.22.so
7fc03e6f6000-7fc03e6fa000 rw-p 00000000 00:00 0
7fc03e6fa000-7fc03e710000 r-xp 00000000 fe:00 1835152 /usr/lib/libgcc_s.so.1
7fc03e710000-7fc03e90f000 ---p 00016000 fe:00 1835152 /usr/lib/libgcc_s.so.1
7fc03e90f000-7fc03e910000 rw-p 00015000 fe:00 1835152 /usr/lib/libgcc_s.so.1
7fc03e910000-7fc03ea0d000 r-xp 00000000 fe:00 1887703 /usr/lib/libm-2.22.so
7fc03ea0d000-7fc03ec0c000 ---p 000fd000 fe:00 1887703 /usr/lib/libm-2.22.so
7fc03ec0c000-7fc03ec0d000 r--p 000fc000 fe:00 1887703 /usr/lib/libm-2.22.so
7fc03ec0d000-7fc03ec0e000 rw-p 000fd000 fe:00 1887703 /usr/lib/libm-2.22.so
7fc03ec0e000-7fc03ed80000 r-xp 00000000 fe:00 1835189 /usr/lib/libstdc++.so.6.0.21
7fc03ed80000-7fc03ef80000 ---p 00172000 fe:00 1835189 /usr/lib/libstdc++.so.6.0.21
7fc03ef80000-7fc03ef8a000 r--p 00172000 fe:00 1835189 /usr/lib/libstdc++.so.6.0.21
7fc03ef8a000-7fc03ef8c000 rw-p 0017c000 fe:00 1835189 /usr/lib/libstdc++.so.6.0.21
7fc03ef8c000-7fc03ef90000 rw-p 00000000 00:00 0
7fc03ef90000-7fc03efab000 r-xp 00000000 fe:00 1877341 /usr/lib/libnetfilter_conntrack.so.3.5.0
7fc03efab000-7fc03f1aa000 ---p 0001b000 fe:00 1877341 /usr/lib/libnetfilter_conntrack.so.3.5.0
7fc03f1aa000-7fc03f1ac000 r--p 0001a000 fe:00 1877341 /usr/lib/libnetfilter_conntrack.so.3.5.0
7fc03f1ac000-7fc03f1ad000 rw-p 0001c000 fe:00 1877341 /usr/lib/libnetfilter_conntrack.so.3.5.0
7fc03f1ad000-7fc03f214000 r-xp 00000000 fe:00 1835230 /usr/lib/libncursesw.so.6.0
7fc03f214000-7fc03f414000 ---p 00067000 fe:00 1835230 /usr/lib/libncursesw.so.6.0
7fc03f414000-7fc03f418000 r--p 00067000 fe:00 1835230 /usr/lib/libncursesw.so.6.0
7fc03f418000-7fc03f41a000 rw-p 0006b000 fe:00 1835230 /usr/lib/libncursesw.so.6.0
7fc03f41a000-7fc03f43c000 r-xp 00000000 fe:00 1886851 /usr/lib/ld-2.22.so
7fc03f5b4000-7fc03f5fc000 rw-p 00000000 00:00 0
7fc03f63a000-7fc03f63b000 rw-p 00000000 00:00 0
7fc03f63b000-7fc03f63c000 r--p 00021000 fe:00 1886851 /usr/lib/ld-2.22.so
7fc03f63c000-7fc03f63d000 rw-p 00022000 fe:00 1886851 /usr/lib/ld-2.22.so
7fc03f63d000-7fc03f63e000 rw-p 00000000 00:00 0
7ffd1d4a4000-7ffd1d4c5000 rw-p 00000000 00:00 0 [stack]
7ffd1d524000-7ffd1d526000 r--p 00000000 00:00 0 [vvar]
7ffd1d526000-7ffd1d528000 r-xp 00000000 00:00 0 [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]
Aborted
More info:
distribution and distribution version: Arch linux fully up-to-date
kernel version: 4.2.5
g++ version: 5.3.0
make version: 4.1
glibc version: 2.22
ncurses version: 6.0
libnetfilter_conntrack version: 1.0.5
The text was updated successfully, but these errors were encountered: