Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Double free or corruption (!prev) error?  (Read 2124 times)

0 Members and 1 Guest are viewing this topic.

Jamie_Edwards

  • Newbie
  • *
  • Posts: 7
    • View Profile
Double free or corruption (!prev) error?
« on: April 11, 2017, 12:31:00 pm »
Hi guys

So I've started to use SFML2 after a couple of years and have hit a pretty nasty error (or so I believe as I've never come across it). I get a double free or corruption (!prev) error when terminating my window.

Now, after looking at a few different topics, they all state the cause is a call to a double freeing of pointers. Granted, initially I did indeed have a double call to my destroy() function so I removed it. However, I'm still getting the error.

The full dump is:
(click to show/hide)

I'm using std::unique_ptr's for my resources and sprites, might that be causing this?

I'm also as you can guess, using Linux. Namely Ubuntu 16.10.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10998
    • View Profile
    • development blog
    • Email
Re: Double free or corruption (!prev) error?
« Reply #1 on: April 11, 2017, 12:46:12 pm »
So you call delete somewhere in your code? If so, put a break point on it and see if it gets called multiple times.
Or even better, get rid of manual memory management. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Jamie_Edwards

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Double free or corruption (!prev) error?
« Reply #2 on: April 11, 2017, 01:26:20 pm »
I'm trying to minimise manual memory management by using smart pointers as much as possible though?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10998
    • View Profile
    • development blog
    • Email
Re: Double free or corruption (!prev) error?
« Reply #3 on: April 11, 2017, 01:40:03 pm »
Don't just minimize it, remove it entirely. You're already using smart pointers, there's no point in replacing the last occurrences of MMM as well. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/