Hi, recently my game begin segfaulting with this backtrace
Program received signal SIGSEGV, Segmentation fault.
memset () at ../sysdeps/x86_64/memset.S:78
78 ../sysdeps/x86_64/memset.S: No such file or directory.
(gdb) bt
#0 memset () at ../sysdeps/x86_64/memset.S:78
#1 0x00007ffff7994711 in sf::Font::loadGlyph(unsigned int, unsigned int, bool) const () from /usr/local/lib64/libsfml-graphics.so.2
#2 0x00007ffff7994e69 in sf::Font::getGlyph(unsigned int, unsigned int, bool) const () from /usr/local/lib64/libsfml-graphics.so.2
#3 0x00007ffff79b7533 in sf::Text::updateGeometry() () from /usr/local/lib64/libsfml-graphics.so.2
#4 0x00007ffff79b7e83 in sf::Text::Text(sf::String const&, sf::Font const&, unsigned int) () from /usr/local/lib64/libsfml-graphics.so.2
#5 0x0000000000506286 in Computers::Software::Programs::UpperPanel::UpperPanel (this=0x79ac50, os=...) at /home/anrock/Documents/cprl/src/Computers/Software/Programs/UpperPanel.cpp:10
#6 0x00000000005029e4 in Computers::Software::Programs::ProgramFactory::spawn (os=..., id="UpperPanel") at /home/anrock/Documents/cprl/src/Computers/Software/Programs/ProgramFactory.cpp:25
#7 0x00000000004fdf63 in Computers::Software::OperatingSystem::start (this=0x7942a0) at /home/anrock/Documents/cprl/src/Computers/Software/OperatingSystem.cpp:98
#8 0x00000000004f7f51 in Computers::Computer::turnOn (this=0x7fffffffb2a0) at /home/anrock/Documents/cprl/src/Computers/Computer.cpp:44
#9 0x00000000004ec624 in ____C_A_T_C_H____T_E_S_T____14 () at /home/anrock/Documents/cprl/Tests/TestCp.cpp:23
#10 0x00000000004b3396 in Catch::FreeFunctionTestCase::invoke (this=0x74e770) at /home/anrock/Documents/cprl/Tests/catch.hpp:5414
#11 0x00000000004a3a25 in Catch::TestCase::invoke (this=0x74a7d0) at /home/anrock/Documents/cprl/Tests/catch.hpp:6282
#12 0x00000000004b135d in Catch::RunContext::runCurrentTest (this=0x7fffffffddf0, redirectedCout="", redirectedCerr="") at /home/anrock/Documents/cprl/Tests/catch.hpp:5027
#13 0x00000000004b033d in Catch::RunContext::runTest (this=0x7fffffffddf0, testCase=...) at /home/anrock/Documents/cprl/Tests/catch.hpp:4873
#14 0x00000000004b1e2b in Catch::Runner::runTestsForGroup (this=0x7fffffffe010, context=..., filterGroup=...) at /home/anrock/Documents/cprl/Tests/catch.hpp:5164
#15 0x00000000004b1b23 in Catch::Runner::runTests (this=0x7fffffffe010) at /home/anrock/Documents/cprl/Tests/catch.hpp:5145
#16 0x00000000004b2ad0 in Catch::Session::run (this=0x7fffffffe300) at /home/anrock/Documents/cprl/Tests/catch.hpp:5287
#17 0x00000000004b299e in Catch::Session::run (this=0x7fffffffe300, argc=1, argv=0x7fffffffe4c8) at /home/anrock/Documents/cprl/Tests/catch.hpp:5270
#18 0x00000000004a71ba in main (argc=1, argv=0x7fffffffe4c8) at /home/anrock/Documents/cprl/Tests/catch.hpp:8247
Font loaded like this:
if (!SystemFont.loadFromFile("Resources/Fonts/Terminus.ttf"))
std::cerr << "Can't load font" << std::endl;
No error reported
Then sf::Text field is initialized with this font in another class like this:
username(OS.getUsername(), OS.getFont(), 14)
getUsername() returns std::strings and getFont() returns reference to loaded font.
Now about weirdness i've found.
GDB's "p SystemFont" before SystemFont is initialized looks like this:
SystemFont = {m_library = 0x0, m_face = 0x0, m_streamRec = 0x0, m_refCount = 0x0, m_pages = std::map with 0 elements, m_pixelBuffer = std::vector of length 0, capacity 0}
and after call to loadFromFile:
SystemFont = {m_library = 0x794680, m_face = 0x799cc0, m_streamRec = 0x0, m_refCount = 0x790cd0, m_pages = std::map with 7947120 elements<error reading variable: Cannot access memory at address 0x18>,
m_pixelBuffer = std::vector of length 0, capacity 0}
I've tried to make minimal code:
#include <SFML/Graphics.hpp>
#include <iostream>
int main(int argc, char* argv[])
{
sf::Font font;
if (!font.loadFromFile("Resources/Fonts/Terminus.ttf"))
std::cerr << "Font not loaded";
return 0;
}
and look at font after initialization... and it was initialized ok!
font = {m_library = 0x604db0, m_face = 0x6030f0, m_streamRec = 0x0, m_refCount = 0x604a40, m_pages = std::map with 0 elements, m_pixelBuffer = std::vector of length 0, capacity 0}
Also about weirdness: i didn't alternate font loading and related code for a long while. It just suddenly stopped working.