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

Author Topic: malloc: *** error for object 0x7fa16b8d6f60: pointer being freed was not allocat  (Read 11681 times)

0 Members and 1 Guest are viewing this topic.

tramstheman

  • Newbie
  • *
  • Posts: 15
    • View Profile
Ok, here we go. I figured that since my issue only occurred when the destructor was called, that perhaps the original example in #5 wasn't working because of the main scope.

So here we go, this is the simplest way to recreate the error:

#include <SFML/System.hpp>
#include <SFML/Graphics.hpp>

void test();

int main()
{
    test();

    return 0;
}

void test()
{
    sf::String s;
    sf::Text t;
}
 


test(8044,0x7fff786ce000) malloc: *** error for object 0x7fff5a3c1a00: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug


thats not all folks, another interesting thing is if i comment out the the string line, it appears to get caught in some sort of infinite loop as the program never ends:

#include <SFML/System.hpp>
#include <SFML/Graphics.hpp>

void test();

int main()
{
    test();

    return 0;
}

void test()
{
    //sf::String s;
    sf::Text t;
}
 

however, comment out the text and only have String, and everything ends up working fine:

#include <SFML/System.hpp>
#include <SFML/Graphics.hpp>

void test();

int main()
{
    test();

    return 0;
}

void test()
{
    sf::String s;
    //sf::Text t;
}
 

Process finished with exit code 0

Just for fun, because I noticed the original error trace mentioned the VertexArray, I went ahead and threw that in there, but it didn't seem to have any affect on the results.

anyway, let me know what you think :)

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Ok, I'll try to have a look at that this weekend.
SFML / OS X developer

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
I'm betting you're using libstdc++ and not libc++. The former's been deprecated on OS X for a while now. Try libc++ instead.

BTW
Quote from: tutorial
However, if your project depends on libstdc++ (directly or indirectly), you need to build SFML yourself and configure your project accordingly.

HTH
« Last Edit: October 08, 2016, 05:44:00 pm by Hiura »
SFML / OS X developer

tramstheman

  • Newbie
  • *
  • Posts: 15
    • View Profile
I am using libc++.

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_FULLY_DYNAMIC_STRING=1 -std=c++14 -stdlib=libc++")

I tried to mirror everything from Xcode

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Hum.. Okay. Could you post the CMake project file as well?
SFML / OS X developer

tramstheman

  • Newbie
  • *
  • Posts: 15
    • View Profile
#CMake Version
cmake_minimum_required(VERSION 3.5)

# Enable debug symbols by default
if(NOT CMAKE_BUILD_TYPE)
    set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build(Debug or Release)" FORCE)
endif()

project(Project)

if (WIN32)
    #do something
endif (WIN32)
if (UNIX)
    #do something
endif (UNIX)
if (MSVC)
    #do something
endif (MSVC)

# CMake Options
if(APPLE)
add_definitions(-D_GLIBCXX_FULLY_DYNAMIC_STRING)
endif(APPLE)

add_compile_options(-D_GLIBCXX_FULLY_DYNAMIC_STRING=1)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_FULLY_DYNAMIC_STRING=1 -std=c++14 -stdlib=libc++")


# Set version information in a config.h file
set(myproject_VERSION_MAJOR 1)
set(myproject_VERSION_MINOR 0)
configure_file(
        "src/Resources/config.h.in"
        "${PROJECT_BINARY_DIR}/config.h"
)
include_directories("${PROJECT_BINARY_DIR}")

# Define sources and executable
set(EXECUTABLE_NAME "Project")
# Include Project Files
include_directories("src")
include_directories("doc")
include_directories("lib")
include_directories("tests")
set(SOURCES src/main.cpp src/GameStates/BaseState.h src/Managers/EventManager.cpp src/Managers/EventManager.h src/Game/Game.h src/Game/Game.cpp src/Managers/ResourceManager.h
        src/Managers/SharedContext.h src/GameStates/StateGame.cpp src/GameStates/StateGame.h src/GameStates/StateIntro.cpp src/GameStates/StateIntro.h
        src/GameStates/StateMainMenu.cpp src/GameStates/StateMainMenu.h src/Managers/StateManager.cpp src/Managers/StateManager.h src/GameStates/StatePaused.cpp src/GameStates/StatePaused.h
        src/Utilities/Utilities.h src/Window/Window.cpp src/Window/Window.h src/Resources/Fonts/arial.ttf src/Resources/Configs/keys.cfg src/Resources/Textures/intro.png
        src/Resources/Textures/icon.png src/Resources/Spritesheets/Mushroom.png src/Managers/TextureManager.h src/Utilities/easylogging++.h src/Graphics/SpriteSheet.cpp src/Graphics/SpriteSheet.h
        src/Graphics/Directions.h src/Graphics/AnimBase.cpp src/Graphics/AnimBase.h src/Graphics/AnimDirectional.cpp src/Graphics/AnimDirectional.h src/Entities/EntityBase.cpp src/Entities/EntityBase.h
        src/Managers/EntityManager.cpp src/Managers/EntityManager.h src/Entities/Enemy.cpp src/Entities/Enemy.h src/Entities/Player.cpp src/Entities/Player.h src/Entities/Character.cpp
        src/Entities/Character.h src/Graphics/Map.cpp src/Graphics/Map.h src/Graphics/DebugOverlay.h src/Utilities/Logger.cpp src/Utilities/Logger.h src/Resources)
add_executable(${EXECUTABLE_NAME} ${SOURCES})

# Detect and add SFML
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake_modules")
#See the FindSFML.cmake file for additional details and instructions
find_package(SFML REQUIRED system window graphics network audio)
if(SFML_FOUND)
    include_directories(${SFML_INCLUDE_DIR})
    target_link_libraries(${EXECUTABLE_NAME} ${SFML_LIBRARIES})
endif()

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
I tested again with your CMakeLists.txt (I just kept main.cpp from the source file, but that's the only change I've done), but couldn't reproduce the issue... Removing -D_GLIBCXX_FULLY_DYNAMIC_STRING=1 didn't change anything for me.

Now, maybe there's something fishy going on when configuring the cmake project, either with your IDE or your global environment. Try adding set(CMAKE_VERBOSE_MAKEFILE TRUE) and post the compilation commands from the two systems you have.
SFML / OS X developer

tramstheman

  • Newbie
  • *
  • Posts: 15
    • View Profile
Interesting. I will try that tonight.

tramstheman

  • Newbie
  • *
  • Posts: 15
    • View Profile
hey im back. Sorry for the late notice, got really busy with work. Anyway, I am still having this problem unfortunately. I started a new project just to see where I can get, and when I close the window, this same issue occurs.

tramstheman

  • Newbie
  • *
  • Posts: 15
    • View Profile
I am not entirely sure what you mean by the complication commands. Are you looking for the cmake logs or the IDE messages?

I set the verbose makerfile to true, here is my console out:

Example(24764,0x7fff770bc000) malloc: *** error for object 0x7fff4ff5bb00: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug

Process finished with exit code 6

here is the cmake output:

/Applications/CLion.app/Contents/bin/cmake/bin/cmake -DCMAKE_BUILD_TYPE= -G "CodeBlocks - Unix Makefiles" /Users/name/ClionProjects/Example
-- Found SFML .. in /Library/Frameworks/SFML.framework
SFML has been found
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/name/ClionProjects/Example/cmake-build-default
 

here is the ide output:
/Applications/CLion.app/Contents/bin/cmake/bin/cmake --build /Users/name/ClionProjects/Example/cmake-build-default --target Example -- -j 4
/Applications/CLion.app/Contents/bin/cmake/bin/cmake -H/Users/name/ClionProjects/Example -B/Users/name/ClionProjects/Example/cmake-build-default --check-build-system CMakeFiles/Makefile.cmake 0
/Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/Makefile2 Example
/Applications/CLion.app/Contents/bin/cmake/bin/cmake -H/Users/name/ClionProjects/Example -B/Users/name/ClionProjects/Example/cmake-build-default --check-build-system CMakeFiles/Makefile.cmake 0
/Applications/CLion.app/Contents/bin/cmake/bin/cmake -E cmake_progress_start /Users/name/ClionProjects/Example/cmake-build-default/CMakeFiles 3
/Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/Makefile2 CMakeFiles/Example.dir/all
/Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/Example.dir/build.make CMakeFiles/Example.dir/depend
cd /Users/name/ClionProjects/Example/cmake-build-default && /Applications/CLion.app/Contents/bin/cmake/bin/cmake -E cmake_depends "Unix Makefiles" /Users/name/ClionProjects/Example /Users/name/ClionProjects/Example /Users/name/ClionProjects/Example/cmake-build-default /Users/name/ClionProjects/Example/cmake-build-default /Users/name/ClionProjects/Example/cmake-build-default/CMakeFiles/Example.dir/DependInfo.cmake --color=
/Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/Example.dir/build.make CMakeFiles/Example.dir/build
make[3]: Nothing to be done for `CMakeFiles/Example.dir/build'.
[100%] Built target Example
/Applications/CLion.app/Contents/bin/cmake/bin/cmake -E cmake_progress_start /Users/name/ClionProjects/Example/cmake-build-default/CMakeFiles 0

and let me know if you want any of the cmake-build logs.

I tested again with your CMakeLists.txt (I just kept main.cpp from the source file, but that's the only change I've done), but couldn't reproduce the issue... Removing -D_GLIBCXX_FULLY_DYNAMIC_STRING=1 didn't change anything for me.

Now, maybe there's something fishy going on when configuring the cmake project, either with your IDE or your global environment. Try adding set(CMAKE_VERBOSE_MAKEFILE TRUE) and post the compilation commands from the two systems you have.
« Last Edit: December 04, 2016, 07:47:13 am by tramstheman »

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Quote
make[3]: Nothing to be done for `CMakeFiles/Example.dir/build'.

The interesting bit is missing, try a clean before building.

Quote
and let me know if you want any of the cmake-build logs.

At this point, why not.
SFML / OS X developer

tramstheman

  • Newbie
  • *
  • Posts: 15
    • View Profile
Ok, I solved it!!!!

Ok, so I started reading through the logs before I was going to post them and discovered a few things.
First of all,

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")

is keeping the default flags, which was -std=gnu++14, so I went ahead and change it to not include the previously set flags. This solved the problem with the SSCCE, however I STILL had the problem in the actual program. As I started reading through THOSE logs, I noticed that they were reading SFML 2.3.x versions from the Framework that were somehow leftover, despite having all the recent version of the dylibs.

I deleted all the framework files and re-re-re-downloaded SFML manually and manually mv-ing them into their respective locations.

Anyway, you guys have been absolutely amazing and responsive. Sorry that this ended up being just a dumb environment issue. Hopefully this will help someone else in the future if they run into the same problem.

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
That's an unusual good news for a Monday morning!  ;D
SFML / OS X developer