miniupnp.tuxfamily.org Forum Index miniupnp.tuxfamily.org
The forum about miniupnp and libnatpmp
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

miniupnpd segfault if natpmp is enabled

 
Post new topic   Reply to topic    miniupnp.tuxfamily.org Forum Index -> miniupnpd Bugs
View previous topic :: View next topic  
Author Message
vom513



Joined: 13 Sep 2018
Posts: 10
Location: Ohio, USA

PostPosted: Sun Sep 16, 2018 10:12 pm    Post subject: miniupnpd segfault if natpmp is enabled Reply with quote

OS: Ubuntu 14.04 server

miniupnpd version: I've tried both 2.1 and 2.1.20180706

(IPv6 address below sanitized...)

Code:
root@ice:~/miniupnpd-2.1.20180706# miniupnpd -f /etc/miniupnpd/miniupnpd.conf -d
miniupnpd[7085]: system uptime is 4170 seconds
miniupnpd[7085]: version 2.1 starting NAT-PMP/PCP UPnP-IGD ext if eth0.666 BOOTID=1537135672
miniupnpd[7085]: HTTP listening on port 58046
miniupnpd[7085]: HTTP IPv6 address given to control points : [2001:db8:1234::1]
miniupnpd[7085]: Listening for NAT-PMP/PCP traffic on port 5351
Segmentation fault (core dumped)


Another strange datapoint - I had first compiled this and got it running and had nat-pmp enabled in config and it started and ran just fine. My ISP had an outage last night so I've rebooted my firewall several times troubleshooting that issue. It was ever since a fresh boot that it segfaults. I'm racking my brain trying to think of what could be different from running it a few days ago and today after a fresh boot...

I can provide my config.h (I can tell you have I have IPv6 and IGDv2 enabled...) as well as my miniupnpd.conf. Just let me know where to upload them to or how to share.

Also if there's gdb output you need let me know. Disclaimer - I don't really know how to drive gdb. I tried it already and I got 'no debugging symbols' found. I'm guessing I need to tweak the build process at some point so these are preserved ? Let me know what to do here and I'll gladly do so.

Thanks.
Back to top
View user's profile Send private message
miniupnp
Site Admin


Joined: 14 Apr 2007
Posts: 1589

PostPosted: Mon Sep 24, 2018 1:44 pm    Post subject: Reply with quote

Edit the make file to enable the "-g" in CFLAGS
then rebuild.
run using gdb
Code:
gdb --args miniupnpd -f /etc/miniupnpd/miniupnpd.conf -d

when it crashes, use bt to show the "backtrace"
_________________
Main miniUPnP author.
https://miniupnp.tuxfamily.org/
Back to top
View user's profile Send private message Visit poster's website
vom513



Joined: 13 Sep 2018
Posts: 10
Location: Ohio, USA

PostPosted: Mon Sep 24, 2018 9:31 pm    Post subject: Reply with quote

Okay, hopefully this is what you are looking for:

Code:

gdb --args miniupnpd -f /etc/miniupnpd/miniupnpd.conf -d
...
(gdb) run
Starting program: /usr/sbin/miniupnpd -f /etc/miniupnpd/miniupnpd.conf -d
miniupnpd[6502]: system uptime is 613499 seconds
miniupnpd[6502]: version 2.1 starting NAT-PMP/PCP UPnP-IGD ext if eth0.666 BOOTID=1537824384
miniupnpd[6502]: HTTP listening on port 43572
miniupnpd[6502]: HTTP IPv6 address given to control points : [2001:db8:1234::1]
miniupnpd[6502]: Listening for NAT-PMP/PCP traffic on port 5351

Program received signal SIGSEGV, Segmentation fault.
0x000000000040f4a7 in ?? ()
(gdb) bt
#0  0x000000000040f4a7 in ?? ()
#1  0x000000000040fa79 in ?? ()
#2  0x0000000000403a76 in ?? ()
#3  0x00007ffff741ef45 in __libc_start_main (main=0x402560, argc=4, argv=0x7fffffffe688, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>,
    stack_end=0x7fffffffe678) at libc-start.c:287
#4  0x000000000040488f in ?? ()
Back to top
View user's profile Send private message
miniupnp
Site Admin


Joined: 14 Apr 2007
Posts: 1589

PostPosted: Mon Sep 24, 2018 9:46 pm    Post subject: Reply with quote

you have not rebuilt with the -g flag...
_________________
Main miniUPnP author.
https://miniupnp.tuxfamily.org/
Back to top
View user's profile Send private message Visit poster's website
vom513



Joined: 13 Sep 2018
Posts: 10
Location: Ohio, USA

PostPosted: Mon Sep 24, 2018 10:01 pm    Post subject: Reply with quote

Sorry, stumbling around a bit with this.

In Makefile.linux, I added:

Code:
CFLAGS += -g


Seems like I also needed to comment out strip in the install: section

Code:
#$(STRIP) miniupnpd


This looks better to my (untrained) eye:

Code:

(gdb) run
Starting program: /usr/sbin/miniupnpd -f /etc/miniupnpd/miniupnpd.conf -d
miniupnpd[7646]: system uptime is 615342 seconds
miniupnpd[7646]: version 2.1 starting NAT-PMP/PCP UPnP-IGD ext if eth0.666 BOOTID=1537826227
miniupnpd[7646]: HTTP listening on port 50830
miniupnpd[7646]: HTTP IPv6 address given to control points : [2001:db8:1234::1]
miniupnpd[7646]: Listening for NAT-PMP/PCP traffic on port 5351

Program received signal SIGSEGV, Segmentation fault.
copyIPv6IfDifferent (src=0xfaffffef00000010, dest=0x7fffffffddb8) at pcpserver.c:181
181         memcpy(dest, src, sizeof(struct in6_addr));
(gdb) bt
#0  copyIPv6IfDifferent (src=0xfaffffef00000010, dest=0x7fffffffddb8) at pcpserver.c:181
#1  createPCPResponse (response=response@entry=0x7fffffffdd8c "\002\201", pcp_msg_info=pcp_msg_info@entry=0x7fffffffddc0) at pcpserver.c:1491
#2  0x000000000040fa79 in PCPSendUnsolicitedAnnounce (sockets=sockets@entry=0x622170, n_sockets=n_sockets@entry=2, socket6=socket6@entry=14) at pcpserver.c:1659
#3  0x0000000000403a76 in main (argc=<optimized out>, argv=<optimized out>) at miniupnpd.c:2198
Back to top
View user's profile Send private message
miniupnp
Site Admin


Joined: 14 Apr 2007
Posts: 1589

PostPosted: Tue Sep 25, 2018 8:49 am    Post subject: Reply with quote

Sorry about the strip, I was not thinking that you ran the installed verstion...
_________________
Main miniUPnP author.
https://miniupnp.tuxfamily.org/
Back to top
View user's profile Send private message Visit poster's website
miniupnp
Site Admin


Joined: 14 Apr 2007
Posts: 1589

PostPosted: Tue Sep 25, 2018 9:38 am    Post subject: Reply with quote

Could you try this ?
Code:
diff --git a/miniupnpd/pcpserver.c b/miniupnpd/pcpserver.c
index 9acfb44..e6c427a 100644
--- a/miniupnpd/pcpserver.c
+++ b/miniupnpd/pcpserver.c
@@ -1652,6 +1652,7 @@ void PCPSendUnsolicitedAnnounce(int * sockets, int n_sockets)
 #endif /* ENABLE_IPV6 */
        /* this is an Unsolicited ANNOUNCE response */
 
+       memset(&info, 0, sizeof(info));
        info.version = this_server_info.server_version;
        info.opcode = PCP_OPCODE_ANNOUNCE;
        info.result_code = PCP_SUCCESS;

_________________
Main miniUPnP author.
https://miniupnp.tuxfamily.org/
Back to top
View user's profile Send private message Visit poster's website
miniupnp
Site Admin


Joined: 14 Apr 2007
Posts: 1589

PostPosted: Tue Sep 25, 2018 10:01 am    Post subject: Reply with quote

That is strange. Are you using the latest sources from https://github.com/miniupnp/miniupnp/ ?

this commit should have fixed the issue :
https://github.com/miniupnp/miniupnp/commit/95d707a71f20eb32a23cf7345702dc2b06c55af1
_________________
Main miniUPnP author.
https://miniupnp.tuxfamily.org/
Back to top
View user's profile Send private message Visit poster's website
vom513



Joined: 13 Sep 2018
Posts: 10
Location: Ohio, USA

PostPosted: Tue Sep 25, 2018 12:48 pm    Post subject: Reply with quote

miniupnp wrote:
That is strange. Are you using the latest sources from https://github.com/miniupnp/miniupnp/ ?

this commit should have fixed the issue :
https://github.com/miniupnp/miniupnp/commit/95d707a71f20eb32a23cf7345702dc2b06c55af1


I was using miniupnpd-2.1.20180706. I just cloned from git and it looks like it's working now:

Code:

root@ice:/etc/init.d# grep miniupnp /var/log/syslog
Sep 25 08:42:51 ice miniupnpd[7836]: shutting down MiniUPnPd
Sep 25 08:42:58 ice miniupnpd[11697]: HTTP listening on port 33002
Sep 25 08:42:58 ice miniupnpd[11697]: HTTP IPv6 address given to control points : [2001:db8:1234::1]
Sep 25 08:42:58 ice miniupnpd[11697]: Listening for NAT-PMP/PCP traffic on port 5351
root@ice:/etc/init.d# netstat -planoW | grep :5351
udp        0      0 192.168.64.1:5351       0.0.0.0:*                           11697/miniupnpd  off (0.00/0/0)
udp        0      0 192.168.65.1:5351       0.0.0.0:*                           11697/miniupnpd  off (0.00/0/0)
udp6       0      0 :::5351                 :::*                                11697/miniupnpd  off (0.00/0/0)


Thanks for looking into this.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    miniupnp.tuxfamily.org Forum Index -> miniupnpd Bugs All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP
© 2007 Thomas Bernard, author of MiniUPNP.