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

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

Open
RussBerg opened this issue Jun 17, 2024 · 9 comments

Comments

@RussBerg
Copy link

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

std::lock_guard<std::mutex> lock(g_camInstanceMutex);

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
Copy link
Contributor

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:

  • Minimal code sample? Or did you use one of our tests like tests/seq_mode.py?
  • PVCAM version?
  • Camera model?

@RussBerg
Copy link
Author

  • Minimal code sample? Or did you use one of our tests like tests/seq_mode.py?
    I was testing with single_image_polling.py from tests
  • PVCAM version?
    2.1.6
  • Camera model?
    Retiga R6

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:

  • Python: 3.11
  • PVCam Release: 3.10.2-7PMQI
  • PVCam SDK: PVCam SDK (for PVCam 3.10.1.1) (I tried every conceivable combination of driver and SDK)

@tomhanak
Copy link
Contributor

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
Copy link
Author

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 RussBerg reopened this Jun 19, 2024
@RussBerg
Copy link
Author

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
Copy link
Contributor

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:

  • Did you try to update C++ Redistributable?
  • Do you run the Python apps on the same computer where you built PyVCAM? (I guess you did not built a wheel for PyVCAM on one PC and did not transfer .whl file to another PC to install it and test there...)
  • If you use Python's virtual environment, do you use the same venv for building PyVCAM and running the tests? Can you try to create new clean venv, build PyVCAM and run the test sample?
  • Are you sure there isn't older MSVCP140.dll anywhere in the PATH before the system finds the version used to build PyVCAM? (the order of paths in PATH matters...)

@RussBerg
Copy link
Author

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:

  • Did you try to update C++ Redistributable? yes to 14.40.33810
  • Do you run the Python apps on the same computer where you built PyVCAM? Yes
  • If you use Python's virtual environment, do you use the same venv for building PyVCAM and running the tests? Yes
  • Can you try to create new clean venv, build PyVCAM and run the test sample? Nope, not now anyway maybe down the road when the system is more available
  • Are you sure there isn't older MSVCP140.dll anywhere in the PATH before the system finds the version used to build PyVCAM? No Im not sure, I doubt it though because after running into the problem I had the system wiped and OS reinstalled, then built PyVCAM and got the same result

@krixen55
Copy link

I am still having this issue and i cannot find anything that works. I downgraded to 17.2 ms build tools, re-ran build/install of pyvcam and it still gets hung up on get_frame(). I also tried the extra arg but that also did not work.

I am using:

python: 3.10.10
pvcam: 3.10.1.1
ms build tools 17.2

@AdvancedResearchConsulting

Has there been any resolution to this issue? I'm running into this problem as well.
my system crash at this line
self.__exposure_bytes = pvc.start_live(self.__handle, self.__rois, exp_time, self.__mode, buffer_frame_count, stream_to_disk_path)
no error handling, just a complete application closure, indicating a memory access issue or thread.

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

No branches or pull requests

4 participants