Skip to content
This repository has been archived by the owner on Oct 12, 2023. It is now read-only.

Heap corruption in gateway.dll during module loading #104

Closed
barnstee opened this issue Jan 20, 2017 · 3 comments
Closed

Heap corruption in gateway.dll during module loading #104

barnstee opened this issue Jan 20, 2017 · 3 comments
Assignees

Comments

@barnstee
Copy link
Member

Found a bug and luckily this one is 100% repro: During module loading, the gateway.dll suffers from a heap corruption when built in release. It doesn’t happen in debug. Modules loading are the dotnet OPC UA client module and the IoT Hub module.

You should also build PDBs for Release builds to make debugging stuff like this easier.

@avranju
Copy link
Contributor

avranju commented Jan 31, 2017

The issue here was that when you switched the build configuration to Release in Visual Studio for the gateway, it continued to link with the Debug build of the dependencies that it automatically built for you when you ran cmake. This is bad because on Windows, one gets different implementations of the C runtime (CRT) with different build configurations which means that anytime we have memory allocations and frees mixed between different CRTs, chaos ensues. A comprehensive fix for this issue will require us to change how we deal with gateway dependencies. We will essentially need to switch to depending on packages from external repositories such as nuget and Aptitude. This will take somewhat longer to accomplish and is on our backlog.

In the meantime we have checked in a change (655cd7c) that enables the following:

  • Propagate build configuration while automatically building dependencies when you run cmake, i.e., now when you run cmake you can pass the build configuration via the CMAKE_BUILD_TYPE cmake variable and it's value will be used as the configuration to use when building dependencies.
  • Support rebuilding of dependencies when running the build script (build.cmd or build.sh). This is necessary when you are switching configurations. For example, you may have been working with the Debug configuration and would now like to build Release bits. In order to accomplish this you can now run the build script like so -
    build.cmd --rebuild-deps --config Release
    
  • Enable generation of debug symbols for all release configurations on Windows

This should hopefully unblock you.

@avranju
Copy link
Contributor

avranju commented Feb 7, 2017

@barnstee Do you think it's OK to close this issue?

@damonbarry
Copy link
Member

Fix is in the 2017-03-06 release.

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

No branches or pull requests

3 participants