Opened 3 years ago

Closed 2 years ago

#6033 closed defect (fixed)

Crash in Shader Preprocessor

Reported by: Asger Owned by: Vladislav Belov
Priority: Release Blocker Milestone: Alpha 26
Component: Core engine Keywords:
Cc: Patch:

Description

Crashed while loading a multiplayer game.

Attachments (4)

crashlog.txt (21.4 KB ) - added by Asger 3 years ago.
crashlog.dmp (153.1 KB ) - added by Asger 3 years ago.
userreport_hwdetect.txt (16.5 KB ) - added by Asger 3 years ago.
system_info.txt (19.9 KB ) - added by Asger 3 years ago.

Download all attachments as: .zip

Change History (13)

by Asger, 3 years ago

Attachment: crashlog.txt added

by Asger, 3 years ago

Attachment: crashlog.dmp added

comment:1 by Stan, 3 years ago

Callstack:

>	[Cadre en ligne] pyrogenesis.exe!Ogre::CPreprocessor::Token::operator==(const Ogre::CPreprocessor::Token &) Ligne 175	C++
 	pyrogenesis.exe!Ogre::CPreprocessor::IsDefined(const Ogre::CPreprocessor::Token & iToken) Ligne 391	C++
 	pyrogenesis.exe!Ogre::CPreprocessor::ExpandMacro(const Ogre::CPreprocessor::Token & iToken) Ligne 400	C++
 	pyrogenesis.exe!Ogre::CPreprocessor::GetToken(bool iExpand) Ligne 303	C++
 	pyrogenesis.exe!Ogre::CPreprocessor::GetExpression(Ogre::CPreprocessor::Token & oResult, int iLine, int iOpPriority) Ligne 469	C++
 	pyrogenesis.exe!Ogre::CPreprocessor::GetExpression(Ogre::CPreprocessor::Token & oResult, int iLine, int iOpPriority) Ligne 484	C++
 	pyrogenesis.exe!Ogre::CPreprocessor::GetExpression(Ogre::CPreprocessor::Token & oResult, int iLine, int iOpPriority) Ligne 579	C++
 	pyrogenesis.exe!Ogre::CPreprocessor::GetValue(const Ogre::CPreprocessor::Token & iToken, long & oValue, int iLine) Ligne 669	C++
 	pyrogenesis.exe!Ogre::CPreprocessor::GetValueDef(const Ogre::CPreprocessor::Token & iToken, long & oValue, int iLine) Ligne 1055	C++
 	[Cadre en ligne] pyrogenesis.exe!Ogre::CPreprocessor::HandleIf(Ogre::CPreprocessor::Token &) Ligne 1066	C++
 	pyrogenesis.exe!Ogre::CPreprocessor::HandleDirective(Ogre::CPreprocessor::Token & iToken, int iLine) Ligne 1210	C++
 	pyrogenesis.exe!Ogre::CPreprocessor::Parse(const Ogre::CPreprocessor::Token & iSource) Ligne 1318	C++
 	pyrogenesis.exe!Ogre::CPreprocessor::Parse(const char * iSource, unsigned int iLength, unsigned int & oLength) Ligne 1372	C++
 	pyrogenesis.exe!CPreprocessorWrapper::Preprocess(const CStr8 & input) Ligne 258	C++
 	pyrogenesis.exe!CShaderProgramGLSL::Reload() Ligne 466	C++
 	pyrogenesis.exe!CShaderManager::NewProgram(const char * name, const CShaderDefines & baseDefines, std::shared_ptr<CShaderProgram> & program) Ligne 272	C++
 	pyrogenesis.exe!CShaderManager::LoadProgram(const char * name, const CShaderDefines & defines) Ligne 69	C++
 	pyrogenesis.exe!CShaderManager::NewEffect(const char * name, const CShaderDefines & baseDefines, std::shared_ptr<CShaderTechnique> & tech) Ligne 546	C++
 	pyrogenesis.exe!CShaderManager::LoadEffect(CStrIntern name, const CShaderDefines & defines1, const CShaderDefines & defines2) Ligne 370	C++
 	pyrogenesis.exe!CDecalRData::RenderDecals(const std::vector<CDecalRData *,std::allocator<CDecalRData *>> & decals, const CShaderDefines & context, ShadowMap * shadow) Ligne 118	C++
 	pyrogenesis.exe!TerrainRenderer::RenderTerrainShader(const CShaderDefines & context, int cullGroup, ShadowMap * shadow) Ligne 306	C++
 	pyrogenesis.exe!CRenderer::RenderPatches(const CShaderDefines & context, int cullGroup) Ligne 765	C++
 	pyrogenesis.exe!CRenderer::RenderReflections(const CShaderDefines & context, const CBoundingBoxAligned & scissor) Ligne 1055	C++
 	pyrogenesis.exe!CRenderer::RenderSubmissions(const CBoundingBoxAligned & waterScissor) Ligne 1318	C++
 	pyrogenesis.exe!CRenderer::RenderScene(Scene & scene) Ligne 1714	C++
 	pyrogenesis.exe!CGameView::Render() Ligne 240	C++
 	pyrogenesis.exe!Render() Ligne 240	C++
 	pyrogenesis.exe!CGame::ReallyStartGame() Ligne 319	C++
 	pyrogenesis.exe!ProgressiveLoad() Ligne 309	C++
 	pyrogenesis.exe!Frame() Ligne 394	C++
 	pyrogenesis.exe!RunGameOrAtlas(int argc, const char * * argv) Ligne 692	C++
 	pyrogenesis.exe!SDL_main(int argc, char * * argv) Ligne 743	C++
 	[Code externe]	
 	pyrogenesis.exe!CallStartupWithinTryBlock() Ligne 365	C++
 	[Code externe]	
 	kernel32.dll![Les frames ci-dessous sont peut-être incorrects et/ou manquants, aucun symbole chargé pour kernel32.dll]	Inconnu

comment:2 by Stan, 3 years ago

Summary: unhandled exceptionCrash in Shader Preprocessor

Old one:

>	[Cadre en ligne] pyrogenesis.exe!Ogre::CPreprocessor::Token::operator==(const Ogre::CPreprocessor::Token &) Ligne 175	C++
 	pyrogenesis.exe!Ogre::CPreprocessor::IsDefined(const Ogre::CPreprocessor::Token & iToken) Ligne 391	C++
 	pyrogenesis.exe!Ogre::CPreprocessor::ExpandMacro(const Ogre::CPreprocessor::Token & iToken) Ligne 400	C++
 	pyrogenesis.exe!Ogre::CPreprocessor::GetToken(bool iExpand) Ligne 303	C++
 	pyrogenesis.exe!Ogre::CPreprocessor::GetExpression(Ogre::CPreprocessor::Token & oResult, int iLine, int iOpPriority) Ligne 469	C++
 	pyrogenesis.exe!Ogre::CPreprocessor::GetExpression(Ogre::CPreprocessor::Token & oResult, int iLine, int iOpPriority) Ligne 484	C++
 	pyrogenesis.exe!Ogre::CPreprocessor::GetExpression(Ogre::CPreprocessor::Token & oResult, int iLine, int iOpPriority) Ligne 579	C++
 	pyrogenesis.exe!Ogre::CPreprocessor::GetValue(const Ogre::CPreprocessor::Token & iToken, long & oValue, int iLine) Ligne 669	C++
 	pyrogenesis.exe!Ogre::CPreprocessor::GetValueDef(const Ogre::CPreprocessor::Token & iToken, long & oValue, int iLine) Ligne 1055	C++
 	[Cadre en ligne] pyrogenesis.exe!Ogre::CPreprocessor::HandleIf(Ogre::CPreprocessor::Token &) Ligne 1066	C++
 	pyrogenesis.exe!Ogre::CPreprocessor::HandleDirective(Ogre::CPreprocessor::Token & iToken, int iLine) Ligne 1210	C++
 	pyrogenesis.exe!Ogre::CPreprocessor::Parse(const Ogre::CPreprocessor::Token & iSource) Ligne 1318	C++
 	pyrogenesis.exe!Ogre::CPreprocessor::Parse(const char * iSource, unsigned int iLength, unsigned int & oLength) Ligne 1372	C++
 	pyrogenesis.exe!CPreprocessorWrapper::Preprocess(const CStr8 & input) Ligne 257	C++
 	pyrogenesis.exe!CShaderProgramGLSL::Reload() Ligne 466	C++
 	pyrogenesis.exe!CShaderManager::NewProgram(const char * name, const CShaderDefines & baseDefines, std::shared_ptr<CShaderProgram> & program) Ligne 272	C++
 	pyrogenesis.exe!CShaderManager::LoadProgram(const char * name, const CShaderDefines & defines) Ligne 69	C++
 	pyrogenesis.exe!CShaderManager::NewEffect(const char * name, const CShaderDefines & baseDefines, std::shared_ptr<CShaderTechnique> & tech) Ligne 546	C++
 	pyrogenesis.exe!CShaderManager::LoadEffect(CStrIntern name, const CShaderDefines & defines1, const CShaderDefines & defines2) Ligne 370	C++
 	pyrogenesis.exe!CPatchRData::RenderBases(const std::vector<CPatchRData *,std::allocator<CPatchRData *>> & patches, const CShaderDefines & context, ShadowMap * shadow, bool isDummyShader, const std::shared_ptr<CShaderProgram> & dummy) Ligne 767	C++
 	pyrogenesis.exe!TerrainRenderer::RenderTerrainShader(const CShaderDefines & context, int cullGroup, ShadowMap * shadow) Ligne 302	C++
 	pyrogenesis.exe!CRenderer::RenderPatches(const CShaderDefines & context, int cullGroup) Ligne 765	C++
 	pyrogenesis.exe!CRenderer::RenderSubmissions(const CBoundingBoxAligned & waterScissor) Ligne 1340	C++
 	pyrogenesis.exe!CRenderer::RenderScene(Scene & scene) Ligne 1707	C++
 	pyrogenesis.exe!CGameView::Render() Ligne 240	C++
 	pyrogenesis.exe!Render() Ligne 240	C++
 	pyrogenesis.exe!CGame::ReallyStartGame() Ligne 319	C++
 	pyrogenesis.exe!`anonymous namespace'::StartGame(JS::MutableHandle<JS::Value> attrs) Ligne 94	C++
 	pyrogenesis.exe!AtlasMessage::fLoadMap(AtlasMessage::mLoadMap * msg) Ligne 190	C++
 	pyrogenesis.exe!AtlasMessage::fLoadMap_wrapper(AtlasMessage::IMessage * msg) Ligne 170	C++
 	pyrogenesis.exe!MessagePasserImpl::Add(AtlasMessage::IMessage * msg) Ligne 44	C++
 	[Code externe]	
 	AtlasUI.dll![Les frames ci-dessous sont peut-être incorrects et/ou manquants, aucun symbole chargé pour AtlasUI.dll]	Inconnu

Last edited 3 years ago by Stan (previous) (diff)

by Asger, 3 years ago

Attachment: userreport_hwdetect.txt added

by Asger, 3 years ago

Attachment: system_info.txt added

comment:3 by Silier, 3 years ago

what map was it?

comment:4 by Silier, 3 years ago

Milestone: Alpha 24Alpha 25

comment:5 by Asger, 3 years ago

Obedska Bog Night

comment:6 by Stan, 3 years ago

Milestone: Alpha 25Alpha 26

Won't be fixed for A25, as there is no one to work on it. It's also pretty hard to reproduce it with a debugger attached.

comment:7 by Vladislav Belov, 2 years ago

Randomly caught for a patched SVN (r26785):

Ogre::CPreprocessor::Token::operator==(const Ogre::CPreprocessor::Token &) Line 175
Ogre::CPreprocessor::IsDefined(const Ogre::CPreprocessor::Token & iToken) Line 391
Ogre::CPreprocessor::HandleIfDef(Ogre::CPreprocessor::Token & iBody, int iLine) Line 1019
Ogre::CPreprocessor::HandleDirective(Ogre::CPreprocessor::Token & iToken, int iLine) Line 1203
Ogre::CPreprocessor::Parse(const Ogre::CPreprocessor::Token & iSource) Line 1318
Ogre::CPreprocessor::Parse(const char * iSource, unsigned int iLength, unsigned int & oLength) Line 1372
CPreprocessorWrapper::Preprocess(const CStr8 & input) Line 259
Renderer::Backend::GL::CShaderProgramGLSL::CShaderProgramGLSL(Renderer::Backend::GL::CDevice * device, const CStr8 & name, const Path & vertexFilePath, const Path & fragmentFilePath, const CShaderDefines & defines, const std::map<CStrIntern,int,std::less<CStrIntern>,std::allocator<std::pair<CStrIntern const ,int> > > & vertexAttribs, int streamflags) Line 422
std::make_unique(Renderer::Backend::GL::CDevice * &) Line 2539
Renderer::Backend::GL::CShaderProgram::ConstructGLSL(Renderer::Backend::GL::CDevice *) Line 1027
Renderer::Backend::GL::CShaderProgram::Create(Renderer::Backend::GL::CDevice * device, const CStr8 & name, const CShaderDefines & baseDefines) Line 990
Renderer::Backend::GL::CDevice::CreateShaderProgram(const CStr8 & name, const CShaderDefines & defines) Line 827
CShaderProgram::Reload() Line 40
CShaderManager::LoadProgram(const CStr8 & name, const CShaderDefines & defines) Line 82
CShaderManager::NewEffect(const CStr8 & name, const CShaderDefines & baseDefines, std::shared_ptr<CShaderTechnique> & tech) Line 395
CShaderManager::LoadEffect(CStrIntern name, const CShaderDefines & defines) Line 122
ShaderModelRenderer::Render(Renderer::Backend::GL::CDeviceCommandContext * deviceCommandContext, const std::shared_ptr<RenderModifier> & modifier, const CShaderDefines & context, int cullGroup, int flags) Line 474
CSceneRenderer::Internals::CallTranspModelRenderers(Renderer::Backend::GL::CDeviceCommandContext * deviceCommandContext, const CShaderDefines & context, int cullGroup, int flags) Line 185
CSceneRenderer::RenderTransparentModels(Renderer::Backend::GL::CDeviceCommandContext * deviceCommandContext, const CShaderDefines & context, int cullGroup, ETransparentMode transparentMode) Line 418
CSceneRenderer::RenderSubmissions(Renderer::Backend::GL::CDeviceCommandContext * deviceCommandContext, const CBoundingBoxAligned & waterScissor) Line 894
CSceneRenderer::RenderScene(Renderer::Backend::GL::CDeviceCommandContext * deviceCommandContext, Scene & scene) Line 1166
CGameView::Render() Line 238
CRenderer::RenderFrameImpl(const bool renderGUI, const bool renderLogger) Line 466
CRenderer::RenderFrame(bool needsPresent) Line 420
Frame() Line 454
RunGameOrAtlas(int argc, const char * * argv) Line 691
SDL_main(int argc, char * * argv) Line 743
main_getcmdline() Line 74	C
[External Code]
CallStartupWithinTryBlock() Line 363
[External Code]

It seems the problem is in a corrupted Token::Name inside Macro in MacroList.

comment:8 by Vladislav Belov, 2 years ago

The bug was introduced in r9123 but appeared only in r24553 because before that we didn't have defines in the shaders code.

Explaining:

First of all a CPreprocessorWrapper instance is created and input defines are added. Then we run preprocess for vertex shader code created from its file buffer. The run resolves includes for the source and run the Ogre preprocessor (Ogre::CPreprocessor). After that the processor might contain new macros pointing to a memory inside the source code or the resolved source code (particularly include guards after r24553). Then the original string and the string with resolved includes are deleted. After that we try to preprocess the fragment shader code created from its file buffer. And during that step we crash but rarely. Because highly likely the fragment shader code will be allocated in the freed memory from the vertex step.

comment:9 by Vladislav Belov, 2 years ago

Owner: set to Vladislav Belov
Resolution: fixed
Status: newclosed

In 26791:

Fixes crash in shader preprocessor introduced in rP9123 and appeared after rP24553. Fixes #6033

Note: See TracTickets for help on using tickets.