Skip to content
Snippets Groups Projects

Resolve "Segmentation fault in sfind"

Closed Ramon Nou requested to merge 138-segmentation-fault-in-sfind into master
1 unresolved thread
Compare and Show latest version
2 files
+ 25
9
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 16
9
@@ -66,6 +66,7 @@ typedef struct {
// optimizing parameters NOT USED
int queue_length;
int max_entries_per_iter;
int steal_from_next; // if true, then steal from the next process
int parallel_single_dir_access; // if 1, use hashing to parallelize single
// directory access, if 2 sequential increment
@@ -114,6 +115,7 @@ pfind_options_t *pfind_parse_args(int argc, char **argv, int force_print_help){
pfind_options_t *res = (pfind_options_t *)malloc(sizeof(pfind_options_t));
memset(res, 0, sizeof(pfind_options_t));
auto print_help = force_print_help;
res->workdir = "./";
@@ -151,7 +153,9 @@ pfind_options_t *pfind_parse_args(int argc, char **argv, int force_print_help){
res->name_pattern = (char *)malloc(strlen(argv[i + 1]) * 4 + 100);
// transform a traditional name pattern to a regex:
char *str = argv[i + 1];
char *out = res->name_pattern;
char * out = res->name_pattern;
auto pos = 0;
for (size_t i = 0; i < strlen(str); i++) {
if (str[i] == '*') {
@@ -228,10 +232,6 @@ pfind_options_t *pfind_parse_args(int argc, char **argv, int force_print_help){
case 'q':
res->queue_length = atoi(optarg);
break;
if (res->queue_length < 10) {
pfind_abort("Queue must be at least 10 elements!\n");
}
break;
case 's':
res->stonewall_timer = atol(optarg);
break;
@@ -280,8 +280,7 @@ void dirProcess(const string path, unsigned long long &checked,
struct dirent_extended *getdir = (struct dirent_extended *)malloc(
(sizeof(struct dirent_extended) + 255) * 1024 * 100);
memset(getdir, 0, (sizeof(struct dirent_extended) + 255) * 1024 * 100);
// cout << "PROCESSING " << world_rank << "/"<< world_size << " = " << path <<
// endl;
for (auto server = 0; server < opt->num_servers; server++) {
unsigned long long total_size = 0;
@@ -289,7 +288,7 @@ void dirProcess(const string path, unsigned long long &checked,
path.c_str(), getdir,
(sizeof(struct dirent_extended) + 255) * 1024 * 100, server);
struct dirent_extended *temp = getdir;
if (opt->verbosity) cout << "[" << n << "] " << path.c_str() << endl;
while (total_size < n) {
if (strlen(temp->d_name) == 0)
break;
@@ -311,11 +310,14 @@ void dirProcess(const string path, unsigned long long &checked,
if ((uint64_t)temp->ctime < runtime.ctime_min)
timeOK = false;
}
if (timeOK and (temp->size == opt->size or opt->size == std::numeric_limits<uint64_t>::max()))
if (!(opt->name_pattern &&
regexec(&opt->name_regex, temp->d_name, 0, nullptr, 0)))
found++;
checked++;
if (opt->verbosity) cout << temp->d_name << endl;
temp = reinterpret_cast<dirent_extended *>(reinterpret_cast<char *>(temp) + temp->d_reclen);
}
}
@@ -346,12 +348,13 @@ int process(pfind_options_t *opt) {
workdir = workdir.substr(strlen(opt->mountdir), workdir.size());
if (workdir.size() == 0)
workdir = "/";
dirs.push(workdir);
do {
string processpath = dirs.front();
dirs.pop();
if (opt->verbosity) cout << processpath << endl;
dirProcess(processpath, checked, found, dirs, 0, 1, opt);
// cout << "NO more paths " << dirs.size() << endl;
} while (!dirs.empty());
@@ -362,6 +365,10 @@ int process(pfind_options_t *opt) {
}
int main(int argc, char **argv) {
if (gkfs_getsingleserverdir == nullptr) {
cerr << "LD_PRELOAD not correctly defined or incorrect gekkofs version." << endl;
exit(1);
}
for (auto i = 0; i < argc; i++) {
if (strcmp(argv[i], "--help") == 0) {
Loading