SFTtech / openage

Free (as in freedom) open source clone of the Age of Empires II engine 🚀
http://openage.dev
Other
12.63k stars 1.11k forks source link

Game crash: Failed to compile vertex shader #280

Closed detrumi closed 9 years ago

detrumi commented 9 years ago

When trying to run the game, I get the following error:

ERR cpp/shader/shader.cpp:54 (openage::shader::Shader::Shader(GLenum, const char *), thread 0): Failed to compile vertex shader

What's strange is that the infolog variable at this line is empty.

I'm running a normal nvidia GPU, so that shouldn't be a problem. The following valgrind error might be related, but I'm not sure. I pasted part of the valgrind output here.

==6682== Conditional jump or move depends on uninitialised value(s)
==6682==    at 0x4C31389: memset (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==6682==    by 0x61D7F2: std::_MakeUniq<char []>::__array std::make_unique<char []>(unsigned long) (in /home/wilco/p/openage/.bin/clang-debug-O1/cpp/openage)
==6682==    by 0x61D67C: openage::shader::Shader::Shader(unsigned int, char const*) (shader.cpp:51)
==6682==    by 0x5C13C1: openage::GameMain::GameMain(openage::Engine*) (game_main.cpp:172)
==6682==    by 0x5C0B5A: openage::run_game(openage::Arguments*) (game_main.cpp:97)
==6682==    by 0x5BF2DA: main (main.cpp:61)
==6682==  Uninitialised value was created by a stack allocation
==6682==    at 0x61D5F0: openage::shader::Shader::Shader(unsigned int, char const*) (shader.cpp:30)
TheJJ commented 9 years ago

The first uninitialized-warning in your valgrind-log seems to originate from this line not filling the status variable. The next problem is that the loglen is not initialized here. Can you manually init these two variables to 0? Maybe libepoxy is failing hard because otherwise your glGetShaderiv should either crash or set the variable, not just do nothing apparently.

detrumi commented 9 years ago

Initializing status and loglen to 0 didn't change the crash, but changed the valgrind error:

==8136== Invalid read of size 1
==8136==    at 0x4C2E0E2: strlen (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==8136==    by 0x7F0E7C8: std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21)
==8136==    by 0x5C00F9: openage::log::MessageBuilder& openage::log::MessageBuilder::operator<< <char*>(char* const&) (message.h:112)
==8136==    by 0x61D841: openage::log::MessageBuilder& openage::log::MessageBuilder::operator<< <char []>(std::unique_ptr<char [], std::default_delete<char []> > const&) (message.h:134)
==8136==    by 0x61D71F: openage::shader::Shader::Shader(unsigned int, char const*) (shader.cpp:55)
==8136==    by 0x5C13C1: openage::GameMain::GameMain(openage::Engine*) (game_main.cpp:172)
==8136==    by 0x5C0B5A: openage::run_game(openage::Arguments*) (game_main.cpp:97)
==8136==    by 0x5BF2DA: main (main.cpp:61)
==8136==  Address 0x10de8fc0 is 0 bytes after a block of size 0 alloc'd
==8136==    at 0x4C2B800: operator new[](unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==8136==    by 0x61D7F2: std::_MakeUniq<char []>::__array std::make_unique<char []>(unsigned long) (in /home/wilco/p/openage/.bin/clang-debug-O1/cpp/openage)
==8136==    by 0x61D68C: openage::shader::Shader::Shader(unsigned int, char const*) (shader.cpp:51)
==8136==    by 0x5C13C1: openage::GameMain::GameMain(openage::Engine*) (game_main.cpp:172)
==8136==    by 0x5C0B5A: openage::run_game(openage::Arguments*) (game_main.cpp:97)
==8136==    by 0x5BF2DA: main (main.cpp:61)
TheJJ commented 9 years ago

Now the log message seems to have length 0 (-> doesn't even contain a \0-byte) and the logger still wants to append the message i think. This is why it's an invalid read. Damnit why isn't the correct value returned by the gl functions?

detrumi commented 9 years ago

I've updated my NVIDIA driver to version 346 (from 331), but this had no effect on the error.

The status variable indeed isn't being assigned to. status gets the value 32767 when I try to print it.

The documentation mentions that the params argument of glGetShaderiv (in this case status) isn't changed when an error is generated. I'm not sure how to get such an error, though.

Jon0 commented 9 years ago

This is an issue I had using a nvidia driver, the workaround involved compiling the latest version of libepoxy from source and removing the older apt-get version.

see more: https://github.com/anholt/libepoxy/issues/23

detrumi commented 9 years ago

Thanks, that solves it!

For future reference, these steps fixed it: