Hi,
for a project I need to load and unload the Channel Access context in a
shared library. Loading is no problem but unloading. It always fails
during ca_context_destroy() function.
Here is my demo code:
main.cpp (most simple case for a bigger project where it's necessary to
load and unload different shared libraries at runtime without
terminating main application)
----------------------------------------------------------
#include <windows.h>
#include <iostream>
int main()
{
HINSTANCE hinstLib;
BOOL fFreeResult;
hinstLib = LoadLibrary(TEXT("myCaLib.dll"));
if (hinstLib == NULL) {
std::cout << "myCaLib.dll not found" << std::endl;
return 1;
}
std::cout << "library loaded; hit ENTER to unload" << std::endl;
getchar();
fFreeResult = FreeLibrary(hinstLib);
std::cout << "bye" << std::endl;
return 0;
}
_______________________________________________________________________
myCaLib.cpp (most simple shared library with no functions except
creating and releasing the Channel Access context)
--------------------------------------------------------------
#include <iostream>
#include <cadef.h>
#include <windows.h>
BOOLEAN WINAPI DllMain(HINSTANCE hDllHandle, DWORD nReason, LPVOID
Reserved) {
switch (nReason)
{
case DLL_PROCESS_ATTACH: {
int32_t iResult =
ca_context_create(ca_enable_preemptive_callback);
if (iResult != ECA_NORMAL) {
std::cout << "Error: Could not create any instance of
Channel Access." << std::endl;
return 0;
}
std::cout << "New instance of Channel Access context." <<
std::endl;
std::cout << ca_context_status(ca_current_context(), 1) <<
std::endl;
break;
}
case DLL_PROCESS_DETACH: {
std::cout << "detach process ... " << std::endl;
ca_context_destroy();
break;
}
}
return 1;
}
_______________________________________________________________________
build at command line at Windows 7 64 bit
--------------------------------------------------------------
%comspec% /k "C:\Program Files (x86)\Microsoft Visual
Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"
set base=C:\base-7.0.x <== directory of nightly build or
stable EPICS BASE 7.0 (built with "EPICS_HOST_ARCH=windows-x64")
cd C:\test_case\ <== directory of our test sources
main.cpp and myCaLib.cpp
cl -nologo -FC -D__STDC__=0 -D_CRT_SECURE_NO_DEPRECATE
-D_CRT_NONSTDC_NO_DEPRECATE -Ox -GL -Oy- -W3 -MD -EHsc -DEPICS_BUILD_DLL
-DEPICS_CALL_DLL -I%base%/include/compiler/msvc
-I%base%/include/os/WIN32 -I%base%/include -c main.cpp myCaLib.cpp
link -nologo -subsystem:windows -dll -LTCG -incremental:no -opt:ref
-release -version:7.0 -MACHINE:X64 -libpath:%base%\lib\windows-x64
-out:myCaLib.dll -implib:myCaLib.lib myCaLib.obj ca.lib Com.lib
link -nologo -LTCG -incremental:no -opt:ref -release -version:7.0
-MACHINE:X64 -out:test.exe main.obj
set path=%base%\bin\windows-x64;%path%
test.exe
_______________________________________________________________________
test.exe will freeze because it hangs on ca_context_destroy()
I need any solution for this case, please.
Best regards
Carsten
________________________________
Helmholtz-Zentrum Berlin für Materialien und Energie GmbH
Mitglied der Hermann von Helmholtz-Gemeinschaft Deutscher Forschungszentren e.V.
Aufsichtsrat: Vorsitzender Dr. Volkmar Dietz, stv. Vorsitzende Dr. Jutta Koch-Unterseher
Geschäftsführung: Prof. Dr. Bernd Rech (Sprecher), Prof. Dr. Jan Lüning, Thomas Frederking
Sitz Berlin, AG Charlottenburg, 89 HRB 5583
Postadresse:
Hahn-Meitner-Platz 1
D-14109 Berlin
- Replies:
- Re: BASE 7.0.x@Windows_64 - Channel Access Context in shared library - "ca_context_destroy bug" Michael Davidsaver via Tech-talk
- Navigate by Date:
- Prev:
Re: pco Camera USB and IEEE interface Mark Rivers via Tech-talk
- Next:
Re: BASE 7.0.x@Windows_64 - Channel Access Context in shared library - "ca_context_destroy bug" Michael Davidsaver via Tech-talk
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
<2020>
2021
2022
2023
2024
- Navigate by Thread:
- Prev:
Re: Re: Re: NDPluginStats show the same statistics results and ADViewer displays no image Zhibang Shen via Tech-talk
- Next:
Re: BASE 7.0.x@Windows_64 - Channel Access Context in shared library - "ca_context_destroy bug" Michael Davidsaver via Tech-talk
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
<2020>
2021
2022
2023
2024
|