[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: strdup vs _strdup on Windows builds
[Thread Prev] | [Thread Next]
- Subject: RE: strdup vs _strdup on Windows builds
- From: "Murphy, Gearoid P" <gearoid.murphy@xxxxxx>
- Reply-to: libssh@xxxxxxxxxx
- Date: Wed, 15 Jun 2011 13:33:41 +0000
- To: "libssh@xxxxxxxxxx" <libssh@xxxxxxxxxx>
Ok, the issue was caused by linking to both the debug and release runtime libraries. I had built OpenSSL in release mode but libssh was built in debug. Incredibly, the linker took the "strdup" function from the release runtime but took "free" function from "debug" runtime (or vice versa). These runtimes use different heaps, hence the error. Another triumph of technical excellence from Microsoft. Thanks for your feedback Paulo. - Gearoid ________________________________________ From: Murphy, Gearoid P Sent: 15 June 2011 13:19 To: libssh@xxxxxxxxxx Subject: RE: strdup vs _strdup on Windows builds That certainly seems related to what I'm seeing but I'm not using static linking anywhere, at least, not that I know of. I will rebuild ssl and libssh again to see if there are any configuration details which could be changed. Thanks - Gearoid ________________________________ From: Paulo Panhoto [paulo.panhoto@xxxxxxxxx] Sent: 15 June 2011 12:55 To: libssh@xxxxxxxxxx Subject: Re: strdup vs _strdup on Windows builds Hi, I found a link that might be related to this problem: http://connect.microsoft.com/VisualStudio/feedback/details/333868/programs-using-a-static-library-and-calling-strdup-crash Regards, Paulo On Wed, Jun 15, 2011 at 6:35 AM, Murphy, Gearoid P <gearoid.murphy@xxxxxx<mailto:gearoid.murphy@xxxxxx>> wrote: Hi I've run into a heap corruption assertion whilst running the example programs shipped with the libhssh source. I'm building on an x64 Windows 7 VM using Visual Studio 2008 with libssh 0.5.0. Debugging always traced the error to the process of freeing memory allocated via strdup. MSDN documentation states that strdup was deprecated from Visual Studio 2005 onwards. http://msdn.microsoft.com/en-us/library/ms235454(v=vs.80).aspx<http://msdn.microsoft.com/en-us/library/ms235454%28v=vs.80%29.aspx><http://msdn.microsoft.com/en-us/library/ms235454%28v=vs.80%29.aspx> Unfortunately, this sort of volatility is a constant issue on Windows systems. Nothing like having a monopoly to compensate for brain-dead technical decisions ;-). I was able to address the issue by refactoring the code to use _strdup instead of strdup but I'd rather not have to do this each time I compile a new build of libssh. I'd be happy to assist wherever possible but I'd like to get some feedback first. Thanks - Gearoid
strdup vs _strdup on Windows builds | "Murphy, Gearoid P" <gearoid.murphy@xxxxxx> |
Re: strdup vs _strdup on Windows builds | Paulo Panhoto <paulo.panhoto@xxxxxxxxx> |
RE: strdup vs _strdup on Windows builds | "Murphy, Gearoid P" <gearoid.murphy@xxxxxx> |