kevingurney opened a new issue, #35224:
URL: https://github.com/apache/arrow/issues/35224

   ### Describe the enhancement requested
   
   As discussed in [this comment 
thread](https://github.com/apache/arrow/pull/34563#discussion_r1167214786), 
when building the Arrow C++ libraries in `Debug` mode on Windows using Visual 
Studio, the resulting `arrow.dll` file will be linked against a 
[`MultiThreadedDebugDLL` (i.e. `/MDd`) 
version](https://cmake.org/cmake/help/latest/prop_tgt/MSVC_RUNTIME_LIBRARY.html)
 of the [MSVC Runtime 
libraries](https://learn.microsoft.com/en-us/cpp/c-runtime-library/crt-library-features)
 (e.g. `VCRUNTIME140D.dll` - note the **D** for **D**ebug in the DLL name).
   
   This can lead to unexpected behavior (e.g. crashes, memory corruptions, 
etc.) when linking `arrow.dll` against other code that is built against a 
different MSVC Runtime (e.g. a non-`Debug` version). We ran into this issue 
when [developing the MATLAB 
interface](https://github.com/apache/arrow/pull/34563#discussion_r1160962568) 
and linking a `Debug` build of `arrow.dll` against a [MATLAB MEX 
function](https://www.mathworks.com/help/matlab/call-mex-functions.html) (which 
is linked against a non-`Debug` MSVC Runtime by default). It was quite 
challenging to determine the root cause of the issue from the symptoms (memory 
corruption).
   
   The fact that [every DLL and EXE can be linked against a different MSVC 
Runtime](https://learn.microsoft.com/en-us/cpp/c-runtime-library/crt-library-features?view=msvc-170#what-problems-exist-if-an-application-uses-more-than-one-crt-version)
 may not be obvious to some C++ developers who primarily develop on platforms 
other than Windows. Therefore, it might be helpful to add a note to the ["Debug 
Builds" section of the "Building on Windows" documentation for the Arrow C++ 
libraries](https://arrow.apache.org/docs/developers/cpp/windows.html#debug-builds)
 to warn developers about potential MSVC Runtime compatibility issues when 
building in `Debug` mode. Hopefully, this will help prevent other community 
members from having to spend lots of effort debugging similar issues in the 
future.
   
   ### Component(s)
   
   C++, Documentation


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to