Skip to content

Commit

Permalink
Use a predictable order for --lib-search-root
Browse files Browse the repository at this point in the history
Previously we were using the order in which directory entries are
returned by the filesystem, which is arbitrary, and which can change as
files or directories are added, moved, or removed.

It's more helpful for our users, and easier to document, if we sort the
list of discovered directories.

Signed-off-by: Matt Wozniski <mwozniski@bloomberg.net>
  • Loading branch information
godlygeek authored and pablogsal committed Apr 11, 2023
1 parent 9069043 commit 3a08c9e
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions src/pystack/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,19 +342,13 @@ def process_core(parser: argparse.ArgumentParser, args: argparse.Namespace) -> N
if args.lib_search_path:
lib_search_path = args.lib_search_path
if args.lib_search_root:
# We use a dictionary instead of a set to preserve the order of insertion while only
# keeping unique path entries in the resulting path
so_files = {
str(file.parent): None
for file in pathlib.Path(args.lib_search_root).glob("**/*.so")
}
so_files.update(
{
str(file.parent): None
for file in pathlib.Path(args.lib_search_root).glob("**/*.so.*")
}
)
lib_search_path = ":".join(so_files)
library_dirs = set()
for pattern in {"**/*.so", "**/*.so.*"}:
library_dirs.update(
str(file.parent)
for file in pathlib.Path(args.lib_search_root).glob(pattern)
)
lib_search_path = ":".join(sorted(library_dirs))
LOGGER.info("Using library search path: %s", lib_search_path)

corefile_analyzer = CoreFileAnalyzer(corefile, executable, lib_search_path)
Expand Down

0 comments on commit 3a08c9e

Please sign in to comment.