[SERVER-11879] Using Windows mongoclient.dll, statics have duplicate storage Created: 27/Nov/13 Updated: 11/Jul/16 Resolved: 14/Jan/14 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Internal Client |
| Affects Version/s: | None |
| Fix Version/s: | 2.5.5 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Eric Milkie | Assignee: | Mark Benvenuto |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||||||||||||||
| Operating System: | ALL | ||||||||||||||||||||
| Steps To Reproduce: | Build mongoclient.lib/.dll. |
||||||||||||||||||||
| Participants: | |||||||||||||||||||||
| Description |
|
It appears that if you link against mongoclient.dll in your project and then execute code that uses a static variable that's declared in the header but has storage reserved in the C++ driver, it may crash. The compiler seems to be allocating storage space for the static variable in the local application even though it should only be using the storage in the DLL. |
| Comments |
| Comment by Eric Milkie [ 02/Dec/13 ] |
|
I confirmed in the docs. You must use dllimport (or link with a .DEF file for importing, but then you must also change your code to reference all data from the DLL by one further level of indirection). |
| Comment by Eric Milkie [ 27/Nov/13 ] |
|
This appears to be due to the linker not resolving the static symbols from the dll and the application together at link time. |