Opened 6 years ago
Closed 5 years ago
#67 closed defect (duplicate)
DiOS: VFS Capture does not work
Reported by: | Vladimír Štill | Owned by: | mornfall |
---|---|---|---|
Priority: | major | Milestone: | 5.0 |
Component: | other | Keywords: | |
Cc: |
Description
Let's have a program, du.cpp:
#include <dirent.h> #include <unistd.h> #include <iostream> #include <string> #include <string_view> using namespace std::literals; void list( std::string entry, std::string name, std::string indent ) { std::cout << indent << name << "\n"; DIR *d = opendir( entry.c_str() ); if ( d ) { struct dirent *dir; indent += " "; while ( (dir = readdir( d )) != nullptr ) { if ( dir->d_name == "."sv || dir->d_name == ".."sv ) continue; list( entry + "/" + dir->d_name, dir->d_name, indent ); } closedir( d ); } } int main() { std::string from; from.resize( 256 ); getcwd( from.data(), from.size() ); list( from, from, "" ); }
Now, we want to run this program with a VFS capture:
$ divine exec -o nofail:malloc --virtual --capture test/dios/ -std=c++17 du.cpp compiling du.cpp FAULT: null pointer dereference: [global* 0 0 ddn] DOUBLE FAULT: trying to return without a caller E: Double fault, program terminated. Segmentation fault
Without capture, this works better:
$ divine exec -o nofail:malloc --virtual -std=c++17 du.cpp compiling du.cpp [0] / encountered an infeasible path (execution cancelled)
Although the last line seems like a bug too.
Note: See
TracTickets for help on using
tickets.
The problem with --capture is that there is no root directory (i.e. the same problem as described in #31). The example program has a funny bug though, where the std::string has an embedded 0 character in it, leading to infinite recursion with
opendir
always opening the current working directory. In any case, I'm adding the (fixed) program to the testsuite.