Problem 1989

Summary: Crash in G4VBasicShell::ModifyPath
Product: Geant4 Reporter: nanjo
Component: interfaces/commonAssignee: Koichi Murakami <Koichi.Murakami>
Status: CLOSED FIXED    
Severity: critical CC: Koichi.Murakami
Priority: P4    
Version: 10.3   
Hardware: All   
OS: All   
Attachments: a code to reporduce the problem

Description nanjo 2017-06-29 16:33:22 CEST
Created attachment 465 [details]
a code to reporduce the problem

Dear geant4 developpers,

A crash is occurred at the line 154 in G4VBasicShell.cc,
L154  : if(newPath(newPath.size()-3,3) == "/..") {


When newPath is "/", newPath.size()-3 is negative,
and a software is crashed with the following message.

terminate called after throwing an instance of 'std::out_of_range'
  what():  basic_string::substr: __pos (which is 18446744073709551614) > this->size() (which is 1)
Aborted (core dumped)

The actual situation in my application is as follows.
When "ls" is issued in the UIterminal interface, 
the following functions are called and finally crashed. 
G4UIterminal::GetCommand
G4VBasicShell::ListDirectories
G4VBasicShell::FindDirectory
G4VBasicShell::ModifyPath

The same thing is reproduced with the attached code.

Best regards,
Hajime
Comment 1 Gabriele Cosmo 2017-09-01 10:44:33 CEST
Thanks. The problem is now fixed in the development version and the fix will be included in the next release or patch.
Comment 2 Gabriele Cosmo 2017-09-14 08:20:43 CEST
*** Problem 2006 has been marked as a duplicate of this problem. ***