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 

Crash in Windows (built with MinGW)

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



Joined: 31 May 2009
Posts: 8

PostPosted: Thu Mar 17, 2011 5:08 pm    Post subject: Crash in Windows (built with MinGW) Reply with quote

Hi,

Using libminiupnp linked to Transmission has been causing crashes, the fix is simple:

Code:
--- miniupnpc-1.5/miniupnpc.c   2010-12-21 10:14:17.000000000 -0600
+++ miniupnp/miniupnpc.c        2011-03-17 10:04:08.000000000 -0600
@@ -21,16 +21,16 @@
 #include <string.h>
 #ifdef WIN32
 /* Win32 Specific includes and defines */
-#include <winsock2.h>
+#define        _WIN32_WINNT   0x0501
 #include <ws2tcpip.h>
 #include <io.h>
 #include <iphlpapi.h>
--- miniupnpc-1.5/miniwget.c    2010-12-21 10:14:17.000000000 -0600
+++ miniupnp/miniwget.c 2011-03-16 18:40:50.000000000 -0600
@@ -11,7 +11,7 @@
 #include <ctype.h>
 #include "miniupnpc.h"
 #ifdef WIN32
-#include <winsock2.h>
+#define _WIN32_WINNT   0x0501
 #include <ws2tcpip.h>
 #include <io.h>
 #define MAXHOSTNAMELEN 64


That define means Windows' vesion has to be XP or newer. This is necessary for using freeaddrinfo(), getaddrinfo(), getnameinfo().

ws2tcpip.h includes winsock2.h, so the line taken out was redundant.

The crash is very difficult to debug, its caused by stack corruption, and my guess is that the change in data structures (MIB_IPADDRTABLE, MIB_IPFORWARDROW) is causing it.
_________________
R.B.
Back to top
View user's profile Send private message
miniupnp
Site Admin


Joined: 14 Apr 2007
Posts: 1589

PostPosted: Fri Mar 18, 2011 10:25 am    Post subject: Reply with quote

You mean the code was crashing under Windows 2000 ?

To keep the compatibility with older versions of windows, you can compile the code with -DNO_GETADDRINFO
freeaddrinfo(), getaddrinfo(), getnameinfo() will not be used.
_________________
Main miniUPnP author.
https://miniupnp.tuxfamily.org/
Back to top
View user's profile Send private message Visit poster's website
rb07



Joined: 31 May 2009
Posts: 8

PostPosted: Fri Mar 18, 2011 11:08 pm    Post subject: Reply with quote

miniupnp wrote:
You mean the code was crashing under Windows 2000 ?

No, it was crashing with Windows XP sp3, Vista, and 7.
_________________
R.B.
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 -> miniupnpc 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.