by _mental_ » Wed May 17, 2017 6:23 am
The crash is caused by drawing of particle during offscreen rendering for save game's thumbnail at
gl_sprite.cpp:331:
Code: Select all
sector_t *cursec = actor ? actor->Sector : particle ? particle->subsector->sector : nullptr;
There was
nullptr in
particle->subsector.
Spoiler: Callstack
Code: Select all
GLSprite::Draw(int pass) Line 331
GLDrawList::DoDraw(int pass, int i, bool trans) Line 752
GLDrawList::DoDrawSorted(SortNode * head) Line 799
GLDrawList::DrawSorted() Line 841
GLSceneDrawer::RenderTranslucent() Line 450
GLSceneDrawer::DrawScene(int drawmode) Line 519
GLPlaneMirrorPortal::DrawContents() Line 807
GLPortal::RenderPortal(bool usestencil, bool doquery) Line 154
GLPortal::EndFrame() Line 512
GLSceneDrawer::DrawScene(int drawmode) Line 517
GLSceneDrawer::ProcessScene(bool toscreen) Line 723
GLSceneDrawer::RenderViewpoint(AActor * camera, GL_IRECT * bounds, float fov, float ratio, float fovratio, bool mainview, bool toscreen) Line 839
GLSceneDrawer::WriteSavePic(player_t * player, FileWriter * file, int width, int height) Line 950
FGLInterface::WriteSavePic(player_t * player, FileWriter * file, int width, int height) Line 1061
PutSavePic(FileWriter * file, int width, int height) Line 2248
G_DoSaveGame(bool okForQuicksave, FString filename, const char * description) Line 2307
G_Ticker() Line 1103
TryRunTics() Line 1952
D_DoomLoop() Line 1041
The particle in question was not processed yet in
P_ThinkParticles() function, i.e. it had initial lifetime value and
subsector was
nullptr.
The crash itself is fairly random so I cannot say for sure but it seems like
P_SpawnParticle() was called after
P_ThinkParticles().
IMHO the best solution will be to add the following line to
P_SpawnParticle() function:
Code: Select all
particle->subsector = R_PointInSubsector(particle->Pos);
Alternatively, we can add checks for
nullptr in
subsector member everywhere. But it's hardly the right way to solve initialization problems.
The crash is caused by drawing of particle during offscreen rendering for save game's thumbnail at [url=https://github.com/coelckers/gzdoom/blob/master/src/gl/scene/gl_sprite.cpp#L331]gl_sprite.cpp:331[/url]:
[code]sector_t *cursec = actor ? actor->Sector : particle ? particle->subsector->sector : nullptr;[/code]
There was [b]nullptr[/b] in [b]particle->subsector[/b].
[spoiler=Callstack][code]GLSprite::Draw(int pass) Line 331
GLDrawList::DoDraw(int pass, int i, bool trans) Line 752
GLDrawList::DoDrawSorted(SortNode * head) Line 799
GLDrawList::DrawSorted() Line 841
GLSceneDrawer::RenderTranslucent() Line 450
GLSceneDrawer::DrawScene(int drawmode) Line 519
GLPlaneMirrorPortal::DrawContents() Line 807
GLPortal::RenderPortal(bool usestencil, bool doquery) Line 154
GLPortal::EndFrame() Line 512
GLSceneDrawer::DrawScene(int drawmode) Line 517
GLSceneDrawer::ProcessScene(bool toscreen) Line 723
GLSceneDrawer::RenderViewpoint(AActor * camera, GL_IRECT * bounds, float fov, float ratio, float fovratio, bool mainview, bool toscreen) Line 839
GLSceneDrawer::WriteSavePic(player_t * player, FileWriter * file, int width, int height) Line 950
FGLInterface::WriteSavePic(player_t * player, FileWriter * file, int width, int height) Line 1061
PutSavePic(FileWriter * file, int width, int height) Line 2248
G_DoSaveGame(bool okForQuicksave, FString filename, const char * description) Line 2307
G_Ticker() Line 1103
TryRunTics() Line 1952
D_DoomLoop() Line 1041[/code][/spoiler]
The particle in question was not processed yet in [b]P_ThinkParticles()[/b] function, i.e. it had initial lifetime value and [b]subsector[/b] was [b]nullptr[/b].
The crash itself is fairly random so I cannot say for sure but it seems like [b]P_SpawnParticle()[/b] was called after [b]P_ThinkParticles()[/b].
IMHO the best solution will be to add the following line to [b]P_SpawnParticle()[/b] function:[code]particle->subsector = R_PointInSubsector(particle->Pos);[/code]
Alternatively, we can add checks for [b]nullptr[/b] in [b]subsector[/b] member everywhere. But it's hardly the right way to solve initialization problems.