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

Author Topic: loadFromFIle crashes the application on Ubuntu 16.04  (Read 1196 times)

0 Members and 1 Guest are viewing this topic.

DoubleVV

  • Newbie
  • *
  • Posts: 1
    • View Profile
loadFromFIle crashes the application on Ubuntu 16.04
« on: September 21, 2016, 10:37:52 pm »
Hi guys.

I'm currently developing an application with SFML using the book "SFML Game developement"'. The code works pretty fine on Windows, but when I wanted to test it on Linux(Ubuntu 16.04), it crashes with a SIGABRT, and give me this : 

*** Error in `/home/doublevv/.CLion2016.2/system/cmake/generated/Shooter-420dbcb9/420dbcb9/Release/Shooter': malloc(): memory corruption: 0x00000000016e7e90 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x77725)[0x7f73f0b93725]
/lib/x86_64-linux-gnu/libc.so.6(+0x819be)[0x7f73f0b9d9be]
/lib/x86_64-linux-gnu/libc.so.6(__libc_malloc+0x54)[0x7f73f0b9f5a4]
/usr/lib/nvidia-361/tls/libnvidia-tls.so.361.42(+0x24c0)[0x7f73ef05d4c0]

The debugger tells me that this is the loadFromFile function that crashes the application. I've saw in another topic that it might come from mixing debug and release libraries. I'm using CLion 2016 2.2, using this CMake file :

# General settings
cmake_minimum_required(VERSION 3.5)
set(PROJECT_NAME New)
project(${PROJECT_NAME})
set (CMAKE_CXX_STANDARD 11)

# Enable debug symbols by default
if (CMAKE_BUILD_TYPE STREQUAL "")
    set(CMAKE_BUILD_TYPE Debug)
endif()

# Define sources and executable
set(EXECUTABLE_NAME ${PROJECT_NAME})
set(SOURCE_FILES main.cpp)
add_executable(${EXECUTABLE_NAME} ${SOURCE_FILES})

# Detect and add SFML
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/SFML-2.4.0/cmake/Modules/" ${CMAKE_MODULE_PATH})
set(SFML_ROOT "" CACHE FILEPATH "Path to SFML library.")
set(SFML_ROOT "${CMAKE_SOURCE_DIR}/SFML-2.4.0/")
set(SFML_STATIC_LIBRARIES ON)
find_package(SFML 2 REQUIRED graphics window network audio system)
if (SFML_FOUND)
    include_directories(${SFML_INCLUDE_DIR})
    target_link_libraries(${EXECUTABLE_NAME} ${SFML_LIBRARIES})
    target_link_libraries(${EXECUTABLE_NAME} ${SFML_DEPENDENCIES})
else()
    message(SEND_ERROR "SFML library not found. Please set SFML_ROOT.")
endif()
 

It crashes in release and debug mode even without mixing them, I have no idea how to solve this. I've tested some OpenGL applications, it works fine with the GC.

I have an NVIDIA 765M working with the 361.42 driver.
I've made a little exemple of how it works in the application :

namespace Fonts{
    enum ID{
        Main
    };
}

class FontHolder {

private :
    std::map<Fonts::ID, std::unique_ptr<sf::Font>> mFontMap;

public :
    void load(Fonts::ID id, const std::string& filename);

};

void FontHolder::load(Fonts::ID id, const std::string &filename) {
    std::unique_ptr<sf::Font> resource(new sf::Font());
    if(!resource->loadFromFile(filename))
        throw std::runtime_error("Resource::load - Failed to load " + filename);

    auto inserted = mFontMap.insert(std::make_pair(id, std::move(resource)));
    assert(inserted.second);
}

int main()
{
    sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");

    FontHolder mFontHolder;

    mFontHolder.load(Fonts::Main, "Media/Sansation.ttf");

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }

        window.clear();
        window.display();
    }

    return 0;
}

It crashes at the
 mFontHolder.load(Fonts::Main, "Media/Sansation.ttf");

Thanks for reading  :)

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
AW: loadFromFIle crashes the application on Ubuntu 16.04
« Reply #1 on: September 22, 2016, 07:44:21 am »
According to the call stack it seems to crash in the Nvidia driver somewhere. Could build in debug mode with SFML debug libraries and then provide a backtrace?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything