1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-16 07:22:43 +01:00

Revert "Merge pull request #13938 from NixOS/import-thunk"

This has multiple dangling pointer issues that lead to segfaults in e.g.:

nix eval --expr '(builtins.getFlake "github:nixos/nixpkgs/25.05")' --impure

This reverts commit ad175727e4, reversing
changes made to d314750174.
This commit is contained in:
Sergei Zimmerman 2025-09-18 01:52:46 +03:00
parent b4fcb64276
commit fd034814dc
No known key found for this signature in database
9 changed files with 91 additions and 138 deletions

View file

@ -8,8 +8,6 @@
#include <set>
#include <vector>
#include <boost/container_hash/hash.hpp>
namespace nix {
/**
@ -260,17 +258,11 @@ public:
*/
std::string makeRelative(const CanonPath & path) const;
friend std::size_t hash_value(const CanonPath &);
friend struct std::hash<CanonPath>;
};
std::ostream & operator<<(std::ostream & stream, const CanonPath & path);
inline std::size_t hash_value(const CanonPath & path)
{
boost::hash<std::string_view> hasher;
return hasher(path.path);
}
} // namespace nix
template<>
@ -278,8 +270,8 @@ struct std::hash<nix::CanonPath>
{
using is_avalanching = std::true_type;
std::size_t operator()(const nix::CanonPath & path) const noexcept
std::size_t operator()(const nix::CanonPath & s) const noexcept
{
return nix::hash_value(path);
return std::hash<std::string>{}(s.path);
}
};

View file

@ -119,23 +119,15 @@ struct SourcePath
std::ostream & operator<<(std::ostream & str, const SourcePath & path);
inline std::size_t hash_value(const SourcePath & path)
{
std::size_t hash = 0;
boost::hash_combine(hash, path.accessor->number);
boost::hash_combine(hash, path.path);
return hash;
}
} // namespace nix
template<>
struct std::hash<nix::SourcePath>
{
using is_avalanching = std::true_type;
std::size_t operator()(const nix::SourcePath & s) const noexcept
{
return nix::hash_value(s);
std::size_t hash = 0;
hash_combine(hash, s.accessor->number, s.path);
return hash;
}
};

View file

@ -220,17 +220,6 @@ typename T::mapped_type * get(T & map, const K & key)
template<class T, typename K>
typename T::mapped_type * get(T && map, const K & key) = delete;
/**
* Look up a value in a `boost::concurrent_flat_map`.
*/
template<class T>
std::optional<typename T::mapped_type> getConcurrent(const T & map, const typename T::key_type & key)
{
std::optional<typename T::mapped_type> res;
map.cvisit(key, [&](auto & x) { res = x.second; });
return res;
}
/**
* Get a value for the specified key from an associate container, or a default value if the key isn't present.
*/

View file

@ -95,7 +95,9 @@ std::optional<struct stat> PosixSourceAccessor::cachedLstat(const CanonPath & pa
// former is not hashable on libc++.
Path absPath = makeAbsPath(path).string();
if (auto res = getConcurrent(cache, absPath))
std::optional<Cache::mapped_type> res;
cache.cvisit(absPath, [&](auto & x) { res.emplace(x.second); });
if (res)
return *res;
auto st = nix::maybeLstat(absPath.c_str());