Photometrics / PyVCAM

Python3.X wrapper for Photometrics and QImaging PVCAM based cameras
MIT License
36 stars 17 forks source link

build with latest version of MS Build Tools 2022 (17.10.1) causes call to get_frame() to seg fault #47

Open RussBerg opened 4 weeks ago

RussBerg commented 4 weeks ago

This took me a while to figure out but it appears to fail when trying to lock the mutex in start_seq

https://github.com/Photometrics/PyVCAM/blob/9398c286b0cc2c18e77c90b6f48c154b098fb652/src/pyvcam/pvcmodule.cpp#L768

The build of the module all completes and installs without error, it just failed to work.

Downgrading to MS Build Tools 2022 17.2.1 fixes this.

This was tested on a windows 11 machine 64bit, you can download the Build Tools for Spring 2022 LTSC | 17.2 from here https://learn.microsoft.com/en-us/visualstudio/releases/2022/release-history#updating-your-installation-to-a-specific-release

image

tomhanak commented 4 weeks ago

I have tried to reproduce the issue with full Visual Studio installation versions 17.9.6 and 17.10.2. Everything seems to work well with Python 3.7 and 3.12.

Could you please provide:

RussBerg commented 4 weeks ago

I even tried wiping the computer and starting from scratch and got the same result, the only thing that worked was the different version of build tools.

Other info:

tomhanak commented 3 weeks ago

Unfortunately, I'm still unable to reproduce the issue even with exactly the same environment and camera you have.

But quick Google query has found that something similar is happening to others: https://stackoverflow.com/a/78599923/6523522

Could you please try the recommended Microsoft solution? I.e. update VCRedist x86 and x64 (Microsoft Visual C++ 2015-2022 Redistributable) to the latest version. Mine is currently 14.40.33810.

RussBerg commented 3 weeks ago

tried adding the flag D_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR to extra_compile_args in setup.py and that worked 👍 , doesn't quite make sense to me though that you didn't need the flag if using the same build env (14.40.33810)

RussBerg commented 3 weeks ago

If you add me I can create a PR for the flag addition or you can, the change was

 elif is_windows:
     extra_compile_args = ['-D_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR']
     include_dirs.append('{}/inc/'.format(pvcam_sdk_path))
tomhanak commented 3 weeks ago

I'm glad that defining the macro works for you. But as stated by Microsoft in the VS 2022 17.10 STL release notes, that's a workaround only, not the solution:

... You must follow this rule: When you mix binaries built by different supported versions of the toolset, the Redistributable version must be at least as new as the latest toolset used by any app component.

You can define _DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR as an escape hatch.

--- microsoft/STL changelog

Thus we won't apply the proposed patch. It might be reconsidered later when more users report the problem and nothing else helps...

Back to your problem:

RussBerg commented 3 weeks ago

Thanks for your interest Tom but I can't devote any more time to this problem as the computer in question is being used by others on my team to develop software that uses the camera, so now that I have a work around I/we have to move on.

To answer your questions though: