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

Double free of oCamera #3

Open
player1537 opened this issue Oct 14, 2017 · 2 comments
Open

Double free of oCamera #3

player1537 opened this issue Oct 14, 2017 · 2 comments

Comments

@player1537
Copy link

Most of the destructors do too much and this causes double frees. For instance, consider:

Camera::~Camera()
{
    ospRelease(this->oCamera);
}

Renderer::~Renderer()
{
    ospRelease(this->oRenderer);
    ospRelease(this->oCamera);
    ospRelease(this->oModel);
    ospRelease(this->oSurface);
    ospRelease(this->oMaterial);
}

When you destroy the Renderer first and then destroy the Camera, you get a double free on the oCamera. If you made a copy of the oCamera, then it'd probably be okay, but Renderer just asks for the Camera's ospray object.

Probably replacing the ospRelease(this->oCamera) with this->oCamera = NULL would be sufficient.

@ahota
Copy link
Contributor

ahota commented Oct 14, 2017

I haven't tested this before. Is there actually a double free error thrown when doing this (I'm assuming as part of the Python wrapper)?

We're not typically making copies of the objects, and the Renderer does just get a pointer to the OSPRay camera object. But the ospRelease() function is supposed to just decrease the refcounter. Since both the PBNJ Camera and Renderer both hold a pointer to the same oCamera, this should be called twice from what I understand.

@player1537
Copy link
Author

player1537 commented Oct 14, 2017 via email

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

No branches or pull requests

2 participants