Skip to content
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 when I try to execute it #8

Open
dragonxtek opened this issue Jan 13, 2019 · 11 comments
Open

segmentation fault when I try to execute it #8

dragonxtek opened this issue Jan 13, 2019 · 11 comments

Comments

@dragonxtek
Copy link

I compile it in Ubuntu 18.10 with:

  • Linux kernel 4.20
  • gcc 8.2.0
  • libpcap 0.8

When I try to execute it I got a segmentation fault:
selection_131

No packets were generated (I checked with wireshark).
I tried with all options (mda, ping, traceroute) and I got the same result

@cunha
Copy link
Member

cunha commented Jan 13, 2019

Can you provide additional information to help us track the problem? A stack trace of strace would help.

@dragonxtek
Copy link
Author

Can you provide additional information to help us track the problem? A stack trace of strace would help.

Here it is

log.txt

@rlcalmeida
Copy link
Member

@dragonxtek, please try upgrading libpcap. Version 1.8.1 should suffices.

@dragonxtek
Copy link
Author

@dragonxtek, please try upgrading libpcap. Version 1.8.1 should suffices.

I installed the last version (1.9) and I have the same issue
selection_135

Here it is the new strace log
logv2.txt

@cunha
Copy link
Member

cunha commented Jan 13, 2019 via email

@cunha
Copy link
Member

cunha commented Jan 13, 2019

==20055== HEAP SUMMARY:
==20055==     in use at exit: 64 bytes in 3 blocks
==20055==   total heap usage: 4,296 allocs, 4,293 frees, 138,665 bytes allocated
==20055== 
==20055== 16 bytes in 1 blocks are indirectly lost in loss record 1 of 3
==20055==    at 0x4C2DBC5: calloc (vg_replace_malloc.c:711)
==20055==    by 0x10E5D5: addr_to_str (addr.c:128)
==20055==    by 0x10E635: addr_bytes_to_str (addr.c:138)
==20055==    by 0x10B639: mda_read_response.constprop.5 (mt_mda.c:419)
==20055==    by 0x10BCE1: is_per_packet (mt_mda.c:513)
==20055==    by 0x10BCE1: mda (mt_mda.c:743)
==20055==    by 0x10C0F6: mt_mda (mt_mda.c:773)
==20055==    by 0x1091BB: main (mt.c:289)
==20055== 
==20055== 24 bytes in 1 blocks are indirectly lost in loss record 2 of 3
==20055==    at 0x4C2BBAF: malloc (vg_replace_malloc.c:299)
==20055==    by 0x10EA55: list_insert (list.c:48)
==20055==    by 0x10C043: is_per_packet (mt_mda.c:515)
==20055==    by 0x10C043: mda (mt_mda.c:743)
==20055==    by 0x10C0F6: mt_mda (mt_mda.c:773)
==20055==    by 0x1091BB: main (mt.c:289)
==20055== 
==20055== 64 (24 direct, 40 indirect) bytes in 1 blocks are definitely lost in loss record 3 of 3
==20055==    at 0x4C2BBAF: malloc (vg_replace_malloc.c:299)
==20055==    by 0x10EA1D: list_create (list.c:33)
==20055==    by 0x10BC67: is_per_packet (mt_mda.c:506)
==20055==    by 0x10BC67: mda (mt_mda.c:743)
==20055==    by 0x10C0F6: mt_mda (mt_mda.c:773)
==20055==    by 0x1091BB: main (mt.c:289)

@rlcalmeida let's check these leaks in the meantime while @dragonxtek gets us the dump with the incorrect memory accesses.

@dragonxtek
Copy link
Author

Another thing that would help is to valgrind --leak-check=full --show-reachable=yes ./mtraceroute 8.8.8.8 -c mda.

Here it is
valgrind.txt

@dragonxtek
Copy link
Author

I meant to ask for a (GDB) stack trace on my first message but a typo made that unclear. Can you compile with debug symbols and run it inside GDB so we get a better idea of where the segfault is happening? `.

I tried with ping option:

(gdb) run
Starting program: /usr/local/bin/mtraceroute 8.8.8.8 -c ping
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
0x000055555555acb3 in dst_create (a=<optimized out>, ip_dst=0x555555562590) at dst.c:59
59	    d->ip_dst   = ip_dst;

@rlcalmeida
Copy link
Member

@dragonxtek can you compile with -g -O0 and provide gdb's backtrace output?

@cunha
Copy link
Member

cunha commented Jan 14, 2019

From @dragonxtek's valgrind dump:

==32117== Command: mtraceroute 8.8.8.8 -c mda
==32117== 
==32117== Invalid read of size 8
==32117==    at 0x10ECB3: dst_create (dst.c:61)
==32117==    by 0x109328: main (mt.c:278)
==32117==  Address 0x10 is not stack'd, malloc'd or (recently) free'd
==32117== 
==32117== 
==32117== Process terminating with default action of signal 11 (SIGSEGV)
==32117==  Access not within mapped region at address 0x10
==32117==    at 0x10ECB3: dst_create (dst.c:61)
==32117==    by 0x109328: main (mt.c:278)

@dragonxtek
Copy link
Author

@dragonxtek can you compile with -g -O0 and provide gdb's backtrace output?

(gdb) run
Starting program: /usr/local/bin/mtraceroute 8.8.8.8 -c ping
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
0x000055555555acb3 in dst_create (a=<optimized out>, ip_dst=0x555555562590) at dst.c:59
59	    d->ip_dst   = ip_dst;
(gdb) backtrace 
#0  0x000055555555acb3 in dst_create (a=<optimized out>, ip_dst=0x555555562590) at dst.c:59
#1  0x0000555555555329 in main (argc=<optimized out>, argv=<optimized out>) at mt.c:278
(gdb) backtrace full
#0  0x000055555555acb3 in dst_create (a=<optimized out>, ip_dst=0x555555562590) at dst.c:59
        d = 0x5555555625b0
        r = 0x5555555625e0
        n = 0x0
        i = 0x5555555637f0
        if_ip = 0x555555562820
#1  0x0000555555555329 in main (argc=<optimized out>, argv=<optimized out>) at mt.c:278
        args = 0x555555562260
        a = 0x5555555624a0
        d = <optimized out>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants