Skip to content

Commit

Permalink
LVRT crash was because RTSetCleanupProc was null. (#114)
Browse files Browse the repository at this point in the history
* LVRT crash was because RTSetCleanupProc was null. Now it works

* All this extra logic is dumb (and was broken). Just assume liblvrt.so is already loaded
  • Loading branch information
chadallee committed Aug 19, 2022
1 parent da1bb67 commit 68c66fe
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions src/lv_interop.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <iostream>
#include <cstring>
#include <memory>
#include <grpcpp/grpcpp.h>

#ifndef _WIN32
#include <dlfcn.h>
Expand Down Expand Up @@ -69,21 +70,17 @@ namespace grpc_labview
return;
}

auto lvModule = dlopen(nullptr, RTLD_LAZY);
if (lvModule != nullptr)
{
NumericArrayResizeImp = (NumericArrayResize_T)dlsym(lvModule, "NumericArrayResize");
PostLVUserEvent = (PostLVUserEvent_T)dlsym(lvModule, "PostLVUserEvent");
Occur = (Occur_T)dlsym(lvModule, "Occur");
}
if (NumericArrayResize == nullptr)
NumericArrayResizeImp = (NumericArrayResize_T)dlsym(RTLD_DEFAULT, "NumericArrayResize");
PostLVUserEvent = (PostLVUserEvent_T)dlsym(RTLD_DEFAULT, "PostLVUserEvent");
Occur = (Occur_T)dlsym(RTLD_DEFAULT, "Occur");
RTSetCleanupProc = (RTSetCleanupProc_T)dlsym(RTLD_DEFAULT, "RTSetCleanupProc");

if (NumericArrayResizeImp == nullptr ||
PostLVUserEvent == nullptr ||
Occur == nullptr ||
RTSetCleanupProc == nullptr)
{
std::cout << "Loading LabVIEW Runtime engine!" << std::endl;
lvModule = dlopen("liblvrt.so", RTLD_NOW);
NumericArrayResizeImp = (NumericArrayResize_T)dlsym(lvModule, "NumericArrayResize");
PostLVUserEvent = (PostLVUserEvent_T)dlsym(lvModule, "PostLVUserEvent");
Occur = (Occur_T)dlsym(lvModule, "Occur");
RTSetCleanupProc = (RTSetCleanupProc_T)dlsym(lvModule, "RTSetCleanupProc");
exit(grpc::StatusCode::INTERNAL);
}
}

Expand Down

0 comments on commit 68c66fe

Please sign in to comment.