QVTKWidget SetRenderWindow() with PCLVisualizer Exception - c++

I'm new in PCL. I want to build a project with PCL and VTK int Qt 5.9.6 MSVC 2017 64bit Environment.
My code is like this:
// include file
boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer;
...
// source code file
viewer.reset(new pcl:visualization::PCLVisualizer("viewer", false));
ui->qvtkWidget->SetRenderWindow(viewer->getRenderWindow());
viewer->setupInteractor(ui->qvtkWidget->GetInteractor(), ui->qvtkWidget- >GetRenderWindow());
It can be compiled but when I started debugging it goes wrong with alert:
The inferior stopped because it triggered an exception.
Stopped in thread 0 by: Exception at 0x7ffcb50b1f28, code: 0xc0000005: read access violation at 0x25, flags=0x0 (first chance).
and stopped at lineui->qvtkWidget->SetRenderWindow(viewer->getRenderWindow());
After tracking and debugging, I found the problem is that viewer->getRenderWindow()->GetInteractor() get the 0x25 value, I don't know how that could happen because a lot of online examples use code like this. And the same program runs healthy on ubuntu 18.04.
Thanks for any tips.

In the end, I found out that this is a problem caused by the version of VTK. The original version is 8.1.1, and it can be run normally by switching to 8.0.1. But I don't know why it can still be debugged normally in Linux 8.1.1.

Related

Qt Creator and MSVC - Ignoring specific exception types on debugging?

I'm currently using Qt Creator 4.4.1 with Qt 5.9.2 and the MSVC 2015 32/64 Bit compilers to create a DLL on Windows 7.
In Qt Creator under
Projects -> Build & Run -> Desktop Qt 5.9.2 MSVC2015 xxbit -> Run -> Executable
I've specified the host application, that loads my DLL, so when I hit F5 this app gets executed and loads my DLL without a flaw.
However, on loading, the main app raises an exception which I have no hands-on, making Qt Creator showing up a message box with the following content:
The inferior stopped because it triggered an exception.
Stopped in thread 0 by: Exception at 0x60251637, code 0xc0000005: write access violation at: 0x1, flags=0x0 (first chance).
I now have to close the message box and hit F5 again to proceed.
Because I have to do this for every test run, again and again, it becomes really annoying. So, is there a simplest way to tell CDB from Qt Creator to ignore only that specific type of exception?
Look at the call stack, find the relevant code and see what it does. You should find a try ... catch ... around that line. See whether you can avoid the exception in some way, typically by introducing an if ... else ....
If you cannot avoid it, and you made sure it's really safe to ignore it, start CDB with command line argument -c "sxn c0000005" or the equivalent -c "sxn av", where AV is short for "access violation". You can use sx to see all exception settings.
I encountered the same problem, the problem may be caused by the variable is not initialized, for example:
QLable *lable;
If you forget to allocate memory for this variable, it will cause this error.
lable = new QLable(this);
I think you should check your variables.

Segmentation Fault running boost example

I am trying to run the autoecho program that uses boost::asio and boost::fiber. I am using the following:
Ubuntu 16
cmake 3.9.1
boost 1_65_0
That program depends on a local copy of round_robin.hpp, yield.hpp and detail/yield.hpp. I have downloaded all of those and the program builds successfully. When I run the code, I get a segmentation fault at the line in main that does:
io_svc->run();
Does anyone know if I am doing something wrong, or if the code has an error in it?
I received an email from Oliver Kowalke #boost:
unfortunately, some fixes did not permission to merged into 1.65 (no permission because too late) - you could use branch develop (github) or you need to wait till 1.66is released.
So, until boost 1.66 is released, this code will not work unless you want to use the develop branch.

OpenCV Build ok, debug throws error, runs fine from .exe

Using Visual Studio 2010, OpenCV 2.2.2, Windows 7 64x
My code builds successfully then when it goes into debug I get the following error:
First-chance exception at 0x75f0c41f in MachineVisionHW0.exe: Microsoft C++ exception: cv::Exception at memory location 0x002dec90..
Unhandled exception at 0x75f0c41f in MachineVisionHW0.exe: Microsoft C++ exception: cv::Exception at memory location 0x002dec90..
Then I end debug, go to the file directory and run the built executable and it runs fine. Does anybody know how to fix this? It isn't keeping me from building my code, but it is incredibly inconvenient. I will include an example of the code that is doing this below.
int main(){
cv::Mat image1 = cv::imread("img1.JPG", CV_LOAD_IMAGE_GRAYSCALE);
cv::namedWindow("Sample1");
cv::imshow("Sample1", image1);
cv::waitKey(0);
return 1;
}
Do you get the unhandled exception before main?
If not, then your code is somehow doing something to raise the exception. Put a breakpoint on the first line, then hit F5, then once at the breakpoint, step through the code one line at a time to see which one causes the exception, F10 key to do this.
My gut feeling is that when running from the debugger, the cv::imread is failing since it is not finding the img1.jpg from the expected location, the current working directory is that of the solution file, not of the debug output build dir. You can do a quick test and copy the img1.jpg to the dir containing the sln file and see if that fixes the problem.

Exception thrown when exiting program (Ogre3d)

I am getting a weird exception when I exit the program. This has started since today morning and I am ready to pull my hair out. As soon as I exit the program, visual studio gives an exception and stops at line 731 in the file crt0dat.c (see attached screenshot)
I know this is very little to go on. I have tried several different things:
un the program without doing anything, that is, not initializing Ogre Core at all. Does not result in a crash
Run the program with everything commented out except creating Ogre root (which is related to Ogre itself and has nothing to do with my code), results in the same crash
Run the following program which is as basic as it gets, still results in the crash. The crash happens after return 0, when my program has finished running
#include "windows.h"
#include "OgreRoot.h"
/// --------------------------------------------
INT WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT)
{
Ogre::Root* lRoot = new Ogre::Root();
delete lRoot;
lRoot = NULL;
return 0;
}
/// --------------------------------------------
Since I have everything on the SVN, I ran the same project on my laptop and it worked without any problems, as well as exited without any problems. This led me to believe that somewhere along the line my visual studio got corrupted. I uninstalled Visual studio, then re-installed it, but the problem persists (When VS installs it goes all over my system. No way to contain it. Does anyone know a surefire way to completely destroy Visual Studio installation?). I am running out of ideas, short of re-installing windows. I hope someone here can be of help.
Callstack:
048b0910()
ntdll.dll!775d9901()
[Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]
ntdll.dll!775edc30()
ntdll.dll!775edb7c()
kernel32.dll!76c67363()
> msvcr90d.dll!__crtExitProcess(int status=0) + 0x1b bytes C
msvcr90d.dll!doexit(int code=0, int quick=0, int retcaller=0) + 0x1d1 bytes C
msvcr90d.dll!exit(int code=0) + 0x12 bytes C
OgreFWGame.exe!__tmainCRTStartup() + 0x2a2 bytes C
OgreFWGame.exe!WinMainCRTStartup() + 0xf bytes C
kernel32.dll!76c63677()
ntdll.dll!775d9d42()
ntdll.dll!775d9d15()
Crash Screencapture:
link text
That is not how you are supposed to initialize and use Ogre. Most likely the missing initialization work is what causing your crash.
To get started with ogre I highly recommend following and learning from the tutorials
Edit:
visual studio project templates for ogre can be found here: http://code.google.com/p/ogreappwizards/updates/list to get started quickly.
Thanks for everybody's help on this problem. I ended up re-installing windows (I tried uninstalling Visual Studio and re-installing it, but something went wrong while uninstalling VS [I followed Microsoft's instructions to the letter] and it would refuse to install again [the setup would crash]). I wish they would make it easy to Uninstall Visual Studio.
I wasted about 3 days before I resorted to re-installing windows. My advice would be, if you have another computer to continue to do your work on, is to do the same if something like this happens rather than waste days. If you do find a way to fix the problem, please let me know :)
I recently set ogre up in Visual Studio 2010 and it refused to work right until I copied in the right DLLs - I had been using a set compiled from a slightly older version of ogre in Visual studio 2008. It sounds like the entire ogre compilation or the DLLs may have been copied over via the SVN which could cause strange problems.
Hope it helps, anyway.

Is there a simpler Windows C++ Subversion API or an example .vcproj for minimal_client.c?

Following on the tails of my previous (answered) question...
SharpSvn makes calling the Subversion client API simple:
SvnClient client = new SvnClient();
client.Authentication.DefaultCredentials = new NetworkCredential(username, password);
client.CheckOut(new Uri("http://xxx.yyy.zzz.aaa/svn/repository"), workingCopyDir);
On the other hand, calling the client API from C/C++, as shown in minimal_client.c requires coding "closer to the metal", as it were, on Subversion.
Are there Windows libraries for C++ in Visual Studio 2003 that present a simpler interface than what minimal_client uses?
If there are not, is there a VS2003 C++ project (a .vcproj file) that demonstrates getting minimal_client to run? I'm able to compile minimal_client.c and link it using the following libraries:
libsvn_client-1.lib libsvn_delta-1.lib libsvn_diff-1.lib libsvn_fs-1.lib libsvn_fs_base-1.lib libsvn_fs_fs-1.lib libsvn_ra-1.lib libsvn_ra_local-1.lib libsvn_ra_svn-1.lib libsvn_repos-1.lib libsvn_subr-1.lib libsvn_wc-1.lib libapr-1.lib libaprutil-1.lib xml.lib libneon.lib
but when I run my application (in the debugger or start the release build without debugging), it runs for about 20 seconds without hitting the first line of main() and then throws this exception:
An unhandled exception of type
'System.TypeLoadException' occurred in
Unknown Module.
Additional information: Could not load
type apr_pool_t from assembly
minimal_client,
Version=1.0.3477.16033,
Culture=neutral, PublicKeyToken=null.
I've tried various combination of libsvn_.lib and svn_.lib to no avail.
Any thoughts on what I'm doing wrong?
EDIT: I started fresh with a "Win32 Console Project" (still in VS2003) and I am now able to debug the first few lines of my app. But now, on this line:
if (svn_cmdline_init ("minimal_client", stderr) != EXIT_SUCCESS)
I get a different exception (in the debugger or start the release build without debugging):
Unhandled exception at 0x7c91b21a in
Win32ConsoleProject_minimal_client.exe:
0xC0000005: Access violation writing
location 0x00000010.
EDIT: This thread explains that this error is a CRT mismatch between svn and stderr in my app. If I don't want to build Svn so they match (I don't want to), I can pass NULL instead of stderr (provided I'm willing to do without messages that would go to stderr) When I did this, my app ran all the way through correctly.
It seems that C++ wrappers are not overflowing the 'net. However, you may want to try SVNCPP, which can be yoinked from RapidSVN.
See http://rapidsvn.tigris.org/ for details (note: I've not tried it).
Can you upgrade to Visual C++ 2005 ? If so, you could just go using SharpSvn with C++/CLI.
Or even maybe stick to VC2003 and go SharpSvn with Managed C++ ? (not that I have any knowledge on the how od even the if)
edit: oh well, SharpSvn's homepage explicitely states that VC++ 2005 SP1 is required...