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

The viewer crashes when tidying up the texture cache #75

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

berndporr
Copy link

Probably because openGL has already done it by the
time the viewer tries it. After all it's just a cache
and there shouldn't be any reason to clear it manually?

https://doc.qt.io/qt-5.15/qglcontext.html#deleteTexture

How to reproduce it? Compile the line follower here:
https://github.com/glasgowneuro/feedforward_closedloop_learning/tree/master/linefollower

As you can see it's not using any of the 3 pre-defined robots but creates its own robot. So only realised that the 3 default robots are always loaded. That seems to be ok. The texture IDs look legit. It's just during the tidying up it happens.

Probably because openGL has already done it by the
time the viewer tries it. After all it's just a cache
and there shouldn't be any reason to clear it manually?

https://doc.qt.io/qt-5.15/qglcontext.html#deleteTexture
cmake needs to be told which openGL version is used.

The cmake file in the python wrapper is not
explicitely targeting python version 3. Changed
the commands to the new cmake 3 ones.
@berndporr
Copy link
Author

The cmake files for the python wrappers are a bit out of date and are not detecting python3 explicitly. The commands to find python are deprecated as they do not force python3. I've changed that python3 is searched and also installed in the architecture dependent python dirs. Also squelched a cmake openCV warning.

@stephanemagnenat
Copy link
Collaborator

stephanemagnenat commented Jan 31, 2022

Thanks for the PR. The documentation of QGLContext.deleteTexture also says that this function both deletes the cache and calls glDeleteTextures from the context. How do we prevent textures from leaking if we do not call that function? The cleanup method is called from the destructor of ViewerWidget, so I do not see how the textures could have been cleaned before. There might be a bug, but I do not think your change is the proper fix.

@berndporr
Copy link
Author

berndporr commented Jan 31, 2022

Indeed. It segfaults in the destructor. By that time it seemed to have been already tidied up. I've got just a bog standard ubuntu LTS and segfaults there. It's certainly only caused by one of the pre-defined robots and not all which is even stranger.

@stephanemagnenat
Copy link
Collaborator

We could try to run it in valgrind and see if there is a double free somewhere due to something being used unexpectedly?

@berndporr
Copy link
Author

berndporr commented Feb 1, 2022

I put the "deleteTexure" back in.

void MarxbotModel::cleanup(ViewerWidget* viewer)
	{
		for (int i = 0; i < textures.size(); i++)
			viewer->deleteTexture(textures[i]);
		for (int i = 0; i < lists.size(); i++)
			glDeleteLists(lists[i], 1);
	}

...and it crashes again.
Not much luck with valgrind. Just reports that the pointer is a null pointer:
Finished.
==688981== Invalid read of size 8
==688981== at 0x490462E: QGLContext::deleteTexture(unsigned int) (in /usr/lib/x86_64-linux-gnu/libQt5OpenGL.so.5.12.8)
==688981== by 0x12B248: Enki::MarxbotModel::cleanup(Enki::ViewerWidget*) (MarxbotModel.cpp:61)
==688981== by 0x117F7D: Enki::ViewerWidget::~ViewerWidget() (Viewer.cpp:237)
==688981== by 0x1139E9: LineFollower::~LineFollower() (Linefollower.cpp:111)
==688981== by 0x112BBE: singleRun(int, char**, float, _IO_FILE*) (Linefollower.cpp:258)
==688981== by 0x112E57: main (Linefollower.cpp:297)
==688981== Address 0x0 is not stack'd, malloc'd or (recently) free'd
==688981==
==688981==
==688981== Process terminating with default action of signal 11 (SIGSEGV)
==688981== Access not within mapped region at address 0x0
==688981== at 0x490462E: QGLContext::deleteTexture(unsigned int) (in /usr/lib/x86_64-linux-gnu/libQt5OpenGL.so.5.12.8)
==688981== by 0x12B248: Enki::MarxbotModel::cleanup(Enki::ViewerWidget*) (MarxbotModel.cpp:61)
==688981== by 0x117F7D: Enki::ViewerWidget::~ViewerWidget() (Viewer.cpp:237)
==688981== by 0x1139E9: LineFollower::~LineFollower() (Linefollower.cpp:111)
==688981== by 0x112BBE: singleRun(int, char**, float, _IO_FILE*) (Linefollower.cpp:258)
==688981== by 0x112E57: main (Linefollower.cpp:297)

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

Successfully merging this pull request may close these issues.

2 participants