Hello,
tried to reproduce the issue.

I think the problem is that in de::File::parent the method maybeAs()
is called on a NULL pointer.

With the attached patch the crash does not happen.

Kind regards,
Bernhard



# apt install doomsday doomsday-dbgsym doomsday-common-dbgsym
$ gdb -q --args doomsday
Reading symbols from doomsday...Reading symbols from 
/usr/lib/debug/.build-id/41/6978915c5c4686da064c7ff3a539ef4336958c.debug...done.
done.
(gdb) run
Starting program: /usr/games/doomsday 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
                                                                                
                                                                                
                  
Program received signal SIGSEGV, Segmentation fault.                            
                                                                                
                  
0x00007ffff476092d in __dynamic_cast () from 
/usr/lib/x86_64-linux-gnu/libstdc++.so.6                                        
                                                     
(gdb) bt                                                                        
                                                                                
                  
#0  0x00007ffff476092d in __dynamic_cast () at 
/usr/lib/x86_64-linux-gnu/libstdc++.so.6                                        
                                                   
#1  0x00007ffff7574d95 in de::filesys::Node::maybeAs<de::Folder>() 
(this=<optimized out>) at include/de/filesys/../filesys/node.h:88               
                               
#2  0x00007ffff7574d95 in de::File::parent() const (this=<optimized out>) at 
src/filesys/file.cpp:114                                                        
                     
#3  0x00007ffff757572b in de::File::description() const 
(this=this@entry=0x5555560e5850) at src/filesys/file.cpp:146
#4  0x00007ffff757a40e in de::FileSystem::interpret(de::File*) (this=<optimized 
out>, sourceData=sourceData@entry=0x5555560e5850) at 
src/filesys/filesystem.cpp:147
#5  0x00007ffff7573415 in de::DirectoryFeed::populateFile(de::Folder&, 
de::String const&) (this=this@entry=0x55555605e410, folder=..., entryName=...) 
at src/filesys/directoryfeed.cpp:120
#6  0x00007ffff7573849 in de::DirectoryFeed::populate(de::Folder&) 
(this=0x55555605e410, folder=...) at src/filesys/directoryfeed.cpp:77
#7  0x00007ffff757f011 in de::Folder::populate(de::Folder::PopulationBehavior) 
(this=0x5555560dcc80, behavior=de::Folder::PopulateFullTree) at 
src/filesys/folder.cpp:193
#8  0x00007ffff757f069 in de::Folder::populate(de::Folder::PopulationBehavior) 
(this=0x555556145070, behavior=behavior@entry=de::Folder::PopulateFullTree) at 
src/filesys/folder.cpp:203
#9  0x00007ffff757c24d in de::FileSystem::refresh() 
(this=this@entry=0x5555560b2a50) at src/filesys/filesystem.cpp:66
#10 0x00007ffff75e9be9 in de::App::Instance::initFileSystem(bool) 
(this=0x5555560b2910, allowPlugins=<optimized out>) at src/core/app.cpp:242
#11 0x00007ffff75e5faa in 
de::App::initSubsystems(QFlags<de::App::SubsystemInitFlag>) 
(this=this@entry=0x7fffffffdd80, flags=...) at src/core/app.cpp:592
#12 0x00007ffff6a43115 in 
de::BaseGuiApp::initSubsystems(QFlags<de::App::SubsystemInitFlag>) 
(this=0x7fffffffdd70, flags=...) at src/baseguiapp.cpp:106
#13 0x00005555555e48a5 in ClientApp::initialize() (this=0x7fffffffdd70) at 
src/clientapp.cpp:350
#14 0x00005555555c8605 in main(int, char**) (argc=<optimized out>, 
argv=<optimized out>) at src/main_client.cpp:75
From 1e5dcb1be8049b9169e53e44b9085f9a2c4707fe Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bernhard=20=C3=9Cbelacker?= <bernha...@mailbox.org>
Date: Tue, 23 May 2017 12:07:38 +0200
Subject: Avoid crash after parent() returning NULL pointer.

https://bugs.debian.org/847651

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff476092d in __dynamic_cast () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
(gdb) bt
#0  0x00007ffff476092d in __dynamic_cast () at /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#1  0x00007ffff7574d95 in de::filesys::Node::maybeAs<de::Folder>() (this=<optimized out>) at include/de/filesys/../filesys/node.h:88
#2  0x00007ffff7574d95 in de::File::parent() const (this=<optimized out>) at src/filesys/file.cpp:114
#3  0x00007ffff757572b in de::File::description() const (this=this@entry=0x5555560e5850) at src/filesys/file.cpp:146
#4  0x00007ffff757a40e in de::FileSystem::interpret(de::File*) (this=<optimized out>, sourceData=sourceData@entry=0x5555560e5850) at src/filesys/filesystem.cpp:147
#5  0x00007ffff7573415 in de::DirectoryFeed::populateFile(de::Folder&, de::String const&) (this=this@entry=0x55555605e410, folder=..., entryName=...) at src/filesys/directoryfeed.cpp:120
#6  0x00007ffff7573849 in de::DirectoryFeed::populate(de::Folder&) (this=0x55555605e410, folder=...) at src/filesys/directoryfeed.cpp:77
#7  0x00007ffff757f011 in de::Folder::populate(de::Folder::PopulationBehavior) (this=0x5555560dcc80, behavior=de::Folder::PopulateFullTree) at src/filesys/folder.cpp:193
#8  0x00007ffff757f069 in de::Folder::populate(de::Folder::PopulationBehavior) (this=0x555556145070, behavior=behavior@entry=de::Folder::PopulateFullTree) at src/filesys/folder.cpp:203
#9  0x00007ffff757c24d in de::FileSystem::refresh() (this=this@entry=0x5555560b2a50) at src/filesys/filesystem.cpp:66
#10 0x00007ffff75e9be9 in de::App::Instance::initFileSystem(bool) (this=0x5555560b2910, allowPlugins=<optimized out>) at src/core/app.cpp:242
#11 0x00007ffff75e5faa in de::App::initSubsystems(QFlags<de::App::SubsystemInitFlag>) (this=this@entry=0x7fffffffdd80, flags=...) at src/core/app.cpp:592
#12 0x00007ffff6a43115 in de::BaseGuiApp::initSubsystems(QFlags<de::App::SubsystemInitFlag>) (this=0x7fffffffdd70, flags=...) at src/baseguiapp.cpp:106
#13 0x00005555555e48a5 in ClientApp::initialize() (this=0x7fffffffdd70) at src/clientapp.cpp:350
#14 0x00005555555c8605 in main(int, char**) (argc=<optimized out>, argv=<optimized out>) at src/main_client.cpp:75
---
 doomsday/libcore/src/filesys/file.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/doomsday/libcore/src/filesys/file.cpp b/doomsday/libcore/src/filesys/file.cpp
index fd9b8dc..a4a21c5 100644
--- a/doomsday/libcore/src/filesys/file.cpp
+++ b/doomsday/libcore/src/filesys/file.cpp
@@ -111,6 +111,9 @@ FileSystem &File::fileSystem()
 
 Folder *File::parent() const
 {
+    if (!Node::parent())
+        return NULL;
+
     return Node::parent()->maybeAs<Folder>();
 }
 
-- 
2.11.0

Reply via email to