Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MATLAB] Report error when building the MATLAB Interface to Arrow in Debug mode on Windows #35239

Open
sreeharihegden opened this issue Apr 19, 2023 · 5 comments · May be fixed by #39595
Open

Comments

@sreeharihegden
Copy link
Contributor

Describe the enhancement requested

As discussed in this comment thread, 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 of the MSVC Runtime libraries (e.g. VCRUNTIME140D.dll - note the D for Debug 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 and linking a Debug build of arrow.dll against a MATLAB MEX function (which is linked against a non-Debug MSVC Runtime by default).

Hence, as @kou suggested here, when building the MATLAB Interface to Arrow in Debug mode on Windows, it might be good to report an error such as "You can't build this with Debug because MATLAB is built with Release. You must use Release".

Component(s)

MATLAB

@kevingurney
Copy link
Member

Adding good-first-issue and good-second-issue labels.

This would be a nice usability improvement and a good chance to learn about the CMake build system for the MATLAB Interface as a new contributor.

@ShaiviAgarwal2
Copy link

@sreeharihegden @kevingurney Is this issue resolved? If not, I want to contribute to it!!

@kevingurney
Copy link
Member

@ShaiviAgarwal2 - thanks for checking. No - this issue has not yet been resolved. Please feel free to contribute!

@ShaiviAgarwal2
Copy link

@kevingurney
According to my understanding, the issue arises because the resulting arrow.dll file is linked against a MultiThreadedDebugDLL (i.e., /MDd) version of the MSVC Runtime libraries.

We can follow these steps to solve the issue-:

Firstly, we will identify the build mode (Debug or Release) that MATLAB is using this can be done by checking the MSVC Runtime library that MATLAB is linked against. If it's a non-debug version, MATLAB is built with Release.

If the build mode is Debug, we should display an error message to the user. The error message should clearly state that building in Debug mode is not allowed because MATLAB is built with Release. It should also tell the user to use Release mode instead.

After displaying the error message, we should then stop the build process which will prevent the user from accidentally building the project in Debug mode.

Finally, the user should switch to Release mode for building the project which can be done from the build configuration settings in Visual Studio.

@kevingurney
Copy link
Member

@ShaiviAgarwal2 - yes, your understanding seems correct to me.

ShaiviAgarwal2 added a commit to ShaiviAgarwal2/arrow that referenced this issue Jan 14, 2024
ShaiviAgarwal2 added a commit to ShaiviAgarwal2/arrow that referenced this issue Jan 14, 2024
ShaiviAgarwal2 added a commit to ShaiviAgarwal2/arrow that referenced this issue Jan 19, 2024
ShaiviAgarwal2 added a commit to ShaiviAgarwal2/arrow that referenced this issue Jan 23, 2024
ShaiviAgarwal2 added a commit to ShaiviAgarwal2/arrow that referenced this issue Feb 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment