EmulationStation icon indicating copy to clipboard operation
EmulationStation copied to clipboard

Emulation Station bails out if it can't read a rom subfolder

Open joolswills opened this issue 7 years ago • 1 comments

This leaves the framebuffer in an unusable state on the RPI. Ideally when an exception happens we should cleanup SDL2 and exit cleanly. This issue has been reported quite a few times by people on the forum. It can be recreated by making a roms subfolder with a directly with chmod 000 for example

terminate called after throwing an instance of 'boost::filesystem::filesystem_error'
  what():  boost::filesystem::directory_iterator::construct: Permission denied: /roms/snes/test"
Aborted (core dumped)

here's a quick hack that fixes this issue - but probably a way to implement this better.

--- a/es-app/src/SystemData.cpp
+++ b/es-app/src/SystemData.cpp
@@ -133,17 +133,24 @@ void SystemData::populateFolder(FileData* folder)
                        isGame = true;
                }
 
-               //add directories that also do not match an extension as folders
-               if(!isGame && fs::is_directory(filePath))
+               try
                {
-                       FileData* newFolder = new FileData(FOLDER, filePath.generic_string(), mEnvData, this);
-                       populateFolder(newFolder);
-
-                       //ignore folders that do not contain games
-                       if(newFolder->getChildrenByFilename().size() == 0)
-                               delete newFolder;
-                       else
-                               folder->addChild(newFolder);
+                       //add directories that also do not match an extension as folders
+                       if(!isGame && fs::is_directory(filePath))
+                       {
+                               FileData* newFolder = new FileData(FOLDER, filePath.generic_string(), mEnvData, this);
+                               populateFolder(newFolder);
+
+                               //ignore folders that do not contain games
+                               if(newFolder->getChildrenByFilename().size() == 0)
+                                       delete newFolder;
+                               else
+                                       folder->addChild(newFolder);
+                       }
+               }
+               catch (boost::filesystem::filesystem_error &e)
+               {
+                       // log something
                }
        }
 }

joolswills avatar Nov 17 '17 18:11 joolswills

Experiencing something similar to this.

I have ~/RetroPie symlinked to an external software raid. If it is not mounted and I don't realize it before starting ES, I get this error after a short splash screen and then my keyboard does not respond, forcing me to cut power or else do $ emulationstation && sleep 10 && sudo reboot in advance.

terminate called after throwing an instance of 'std::out_of_range'
    what():  vector::_M_range_check: __n (which is 0) >= this->size() (which is 0)
Aborted
_

jlamoure avatar May 20 '19 13:05 jlamoure