Get rid of a SwapBuffers error - c++

I'm coding a little program with Qt on Mac OS and this line appears at the end of each execution, I can't get rid of it, even after browsing Google to find a solution.
QOpenGLContext::swapBuffers() called with non-exposed window, behavior is undefined
The message error is my the line of the execution log, repeated 2 or 3 times. Am-I missing something on closing QOpenGL routine?
I'll be glad to post a few line of code but I don't know which ones could be useful.

Related

Visual Studio debugger no longer showing lines of code preceding line of code where crash happens

I while ago when I had a crash in Visual Studio it would show me the lines where the code crashed as well as all the lines before that that called the function containing the line on which the code crashed.
Since a few months and a few updates in Visual Studio, it started showing only the line on which the crash happens. For example, my code is crashing and the debugger has opened the header file and is showing the line in there where the code crashed but it is not showing the lines that call the function in that header. Previously it would show the lines that call the function, starting from the main function of the program in which the header is used. And I could easily workout which part of the main program is making a bad call to the function in the header.
Is there a way to have it show me all the lines like before? I've searched everywhere online and cannot find this.
I was able to find how to display the call stack window: while debugging, in the Debug menu, select Windows > Call Stack.
This shows all the function calls down to the line where the crash happens. Solved the cause of the particular crash straight away by the way.

symbol file not loaded in VS2017 only happens 10% of the time with JAGPDF

I couldn't find a solution to this problem. I have a very simple program to generate a PDF using JAGPDF. If i am opening the program from visual studio (same input, same parameters) it runs to the end without errors 90% of the time, but sometimes it throws an exception telling me that symbols not loaded for jagpdf-1.4.dll
If I run the executable directly, 90% it creates the PDF correctly and 10% of the time created a corrupted pdf that I cannot open. How can I solve this problem?
EDIT: I put a screenshot of the error I'm getting, it is very dificult to reproduce because the program runs normally about 90% of the time, so I have to press build several times until it crashes...
EDIT 2: Since it seems the bug is from the library, (I already send them a message reporting it but doubt they'll do something about it because last release was years ago).
I sort of solved the problem by wrapping the function around a loop using try and catch where if the first time it fails then the exception is caught and the function is tried again until it passes. I put a limit of 10 times it can run the loop before terminating it.
The thinking was that, as the events seem to be statistically independent, the loop will reduce the chance of it failing from 0.1 to 0.1^n with n the number of loops.
So now the program is crashing with a probability of 0.0000001% instead of 10%.
With this fix I am happy to report no fails for this weeks data.
Thank you all for pointing me to the direction of the error.
It sounds as if you have found a bug in the PDF library you are using. You have to file a bug report with the PDF software provider. Hopefully they can provide you support.

Suggest me where possibly the error can lie in this code,segmentation error, multithreaded network simulator

I am working on a network simulator which involves generating random connection requests, making connections and releasing them after a specific service time, also generated randomly.
My code is 1000 lines long code. I am using multi-threading and this code is a part of one of two threads.
I am always getting the same error(segmentation fault) always after the same statement in the code(after the "connection request between _ and _ line:").
error-
mokamaConnection request between 10 and 4
Segmentation fault (core dumped)
A very small part of my code which contain the statement after which error is coming. I had added cout statements both above and below the statement after which error is coming.
code-
cout<<"mokama";
//generate the value of src and dest
cout<<"Connection request between "<<src<<" and "<<dest<<endl;
//initmat(topocust,0); //topocust matrix intialised with all zero
cout<<"this printed before matrix.";
I know what segmentation error means. But what i am really unable to understand is that how this error can possibly be occur after a cout statement.Is this even possible? I know i should show you the entire code but i can't since it is not feasible. Can anyone without looking at the entire code can suggest me where the problem should lie..
Also, since i know the entire code so i can say confidently that problem lie in this thread only.
Thanks in advance!
I know this will sound weird but if you are using CodeBlocks IDE, CodeBlocks may sometimes refer to wrong lines of code when segmentation errors appear (don't know why). You may try looking at the code above the indicated line.

App closes while executing after compiling with errors, but while debugging it works fine!

Well. that´s the question. Just that.
I got an app made with SDL and OpenGL. SDL opens an extra window (which is the console) additional to the graphical one. When i execute i´m getting a 3 output error, the console tells me. And it gets closed (the graphical one).
But i know this happens when a SIGSEGV signal is received (don´t know how to capture it) and it appears in my IDE (Code::blocks) while debugging. But this time nothing appears, and everything works all right. But when executing it crashes..
What the...
What kind of error can i expect?. Sometimes it gets closed, sometimes it doesn´t. How to know what kind of problem i got?.
SIGSEGV is a segmentation fault, you're trying to access memory that isn't accessible to your process.
Assuming you're on a UNIXy system, you should be able to get the program to core dump and then look at the core dump in a debugger; alternatively, use a memory debugger like Valgrind to pinpoint the memory management issue that's causing this problem.

Debugging error in STL

I have one big problem with using STL, C++ and Visual Studio. When i use some std or stl functions (in debug compilation) a have some errors some like this "Incorrect format specifier".
but my code are too large for "hand searching" for this error. Maybe one know how to get some help with finding error, some like __FILE__ & __LINE__ for assert? Because code of program too large.
Or try & catch my last hope?...
with respect Alex
Since you have the source code for the STL, what I would do is set a breakpoint at the point where the "Incorrect format specifier" string is located. Do a grep (eg find in files) for that string, set a breakpoint at each one, run your program and hope for death. :)
You talk about try/catch, so I assume it's throwing an exception. If you run your app within the debugger, doesn't it break your program at the point where the uncaught exception is thrown?
EDIT: If you could alternately compile on Linux/g++ it would leave behind a core with a backtrace in that case.
Maybe you could do status msgs on the console so that you get an idea where the error happens. You can search in this part more detailed with the same technique. Do this as often as you need.
After that you can debug you program and set breakpoints in the 'problem area' and step through it.
EDIT: If you are able to compile the program on linux, you can simply install and run valgrind memcheck. It should print out all errors with line number.
The attached screenshot makes it clear that you hit a runtime assertion, and even offers the option to go directly to the dbugger. This will take you to the faulty callstack.
This message is the default mode of _CrtDbgReport. With _CrtSetReportHook2, you can run your own code before the error is printed. You might create a minidump, for instance.