<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[WSACleanup vor FreeLibrary =&amp;gt; Crash]]></title><description><![CDATA[<p>Hallo,<br />
ich habe eine multithreaded Server/Client Anwendung mit Winsock bei der der Netzwerkcode in einer DLL ausgelagert ist. Ich exportiere neben einigen anderen eine Init() und Destroy() Funktion und rufe in den beiden jeweils WSAStartup und WSACleanup auf.<br />
Im Serverprogrammteil (wo ein listen socket gebinded wird usw) stürzt das Programm ein oder zwei Sekunden nach dem Aufruf von FreeLibrary ab (vorher wurde Destroy, also WSACleanup aufgerufen und dafür gesorgt daß garantiert alle threads beendet und alle sockets geclosed wurden).</p>
<p>Das interessante ist: Wenn ich ein Sleep(5000) <strong>vor</strong> WSACleanup mache stürzt es ab (weil direkt darauf der FreeLibrary folgt), wenn ich es <strong>nach</strong> WSACleanup mache, gibt es keinen Absturz.</p>
<p>Was passiert da in WSACleanup??</p>
<p>Danke,<br />
Dr. Gunni</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/212830/wsacleanup-vor-freelibrary-gt-crash</link><generator>RSS for Node</generator><lastBuildDate>Sat, 18 Apr 2026 20:35:36 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/212830.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 11 May 2008 02:54:29 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to WSACleanup vor FreeLibrary =&amp;gt; Crash on Sun, 11 May 2008 02:54:29 GMT]]></title><description><![CDATA[<p>Hallo,<br />
ich habe eine multithreaded Server/Client Anwendung mit Winsock bei der der Netzwerkcode in einer DLL ausgelagert ist. Ich exportiere neben einigen anderen eine Init() und Destroy() Funktion und rufe in den beiden jeweils WSAStartup und WSACleanup auf.<br />
Im Serverprogrammteil (wo ein listen socket gebinded wird usw) stürzt das Programm ein oder zwei Sekunden nach dem Aufruf von FreeLibrary ab (vorher wurde Destroy, also WSACleanup aufgerufen und dafür gesorgt daß garantiert alle threads beendet und alle sockets geclosed wurden).</p>
<p>Das interessante ist: Wenn ich ein Sleep(5000) <strong>vor</strong> WSACleanup mache stürzt es ab (weil direkt darauf der FreeLibrary folgt), wenn ich es <strong>nach</strong> WSACleanup mache, gibt es keinen Absturz.</p>
<p>Was passiert da in WSACleanup??</p>
<p>Danke,<br />
Dr. Gunni</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1506853</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1506853</guid><dc:creator><![CDATA[DrGunni]]></dc:creator><pubDate>Sun, 11 May 2008 02:54:29 GMT</pubDate></item><item><title><![CDATA[Reply to WSACleanup vor FreeLibrary =&amp;gt; Crash on Sun, 11 May 2008 08:43:06 GMT]]></title><description><![CDATA[<blockquote>
<p>An application or dynamic-link library (DLL) is required to perform a successful WSAStartup call before it can use Windows Sockets services. When it has completed the use of Windows Sockets, the application or DLL must call WSACleanup to deregister itself from a Windows Sockets implementation and allow the implementation to free any resources allocated on behalf of the application or DLL. Any pending blocking or asynchronous calls issued by any thread in this process are canceled without posting any notification messages or without signaling any event objects. Any pending overlapped send and receive operations (WSASend/WSASendTo/WSARecv/WSARecvFrom with an overlapped socket) issued by any thread in this process are also canceled without setting the event object or invoking the completion routine, if specified. In this case, the pending overlapped operations fail with the error status WSA_OPERATION_ABORTED.</p>
<p>Sockets that were open when WSACleanup was called are reset and automatically de-allocated as if closesocket was called. Sockets that have been closed with closesocket but that still have pending data to be sent can be affected. The pending data can be lost if the ws2.dll is unloaded from memory as the application exits. To ensure that all pending data is sent, an application should use shutdown to close the connection, and then wait until the close completes before calling closesocket and WSACleanup. All resources and internal state, such as queued unposted-posted messages, must be de-allocated so as to be available to the next user.</p>
<p>Sockets opened at the time of a WSACleanup call are closed and de-allocated as they would be if closesocket was called. Lingering sockets, sockets that were closed with closesocket but that still have pending data to be sent, can be affected. Their pending data will be lost if the ws2.dll is unloaded from memory as the application exits. To ensure that data is not lost, an application should shut down the socket before calling closesocket and then WSACleanup. All of the ws2.dll resources and internal state will be reset and/or de-allocated on the final call to WSACleanup.</p>
<p>There must be a call to WSACleanup for every successful call to WSAStartup made by a task. Only the final WSACleanup call for that task does the actual cleanup; the preceding calls simply decrement an internal reference count in the ws2.dll.</p>
</blockquote>
<p><a href="http://msdn.microsoft.com/en-us/library/aa916085.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/aa916085.aspx</a><br />
Ich glaube das beantwortet deine Frage <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f576.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--sunglasses"
      title=":sunglasses:"
      alt="🕶"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1506887</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1506887</guid><dc:creator><![CDATA[markusrw]]></dc:creator><pubDate>Sun, 11 May 2008 08:43:06 GMT</pubDate></item><item><title><![CDATA[Reply to WSACleanup vor FreeLibrary =&amp;gt; Crash on Sun, 11 May 2008 17:59:38 GMT]]></title><description><![CDATA[<p>Hi, der MSDN Text ist mir natürlich bekannt und da steht leider nichts was den Crash erklären könnte.<br />
Vielleicht sollt ich noch erwähnen daß sich im Debug Modus zur Crashstelle auch nicht wirklich hinspringen lässt und nichtmal ordentliches disassembly angezeigt wird (nur ???). Beim Callstack steht die ntdll und das wars. Dürfte also irgendetwas &quot;tieferes&quot; sein.</p>
<p><a href="http://666kb.com/i/aykarom32nu2hxm0m.gif" rel="nofollow">http://666kb.com/i/aykarom32nu2hxm0m.gif</a></p>
<p>Gibt es da irgendwelche Anhaltspunkte für einen Crash dieser Art?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1507117</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1507117</guid><dc:creator><![CDATA[DrGunni]]></dc:creator><pubDate>Sun, 11 May 2008 17:59:38 GMT</pubDate></item></channel></rss>