Problem 1989 - Crash in G4VBasicShell::ModifyPath
Summary: Crash in G4VBasicShell::ModifyPath
Status: CLOSED FIXED
Alias: None
Product: Geant4
Classification: Unclassified
Component: interfaces/common (show other problems)
Version: 10.3
Hardware: All All
: P4 critical
Assignee: Koichi Murakami
URL:
: 2006 (view as problem list)
Depends on:
Blocks:
 
Reported: 2017-06-29 16:33 CEST by nanjo
Modified: 2017-09-14 10:37 CEST (History)
1 user (show)

See Also:


Attachments
a code to reporduce the problem (124 bytes, text/x-c++src)
2017-06-29 16:33 CEST, nanjo
Details

Note You need to log in before you can comment on or make changes to this 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. ***