-
Notifications
You must be signed in to change notification settings - Fork 10.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[clang] Out-of-bounds SmallVector index crash in Sema::tryCaptureVariable
after 3ed9e9e
#67260
Comments
@llvm/issue-subscribers-c-20
Compiling the following code results in a segfault/assertion failure inside `SmallVector::operator[]` since 3ed9e9e (`"[Clang] Add captures to the instantiation scope of lambda call operators"`, @cor3ntin):
template <typename T, T...> struct IntegerSequence;
template <unsigned... Indices>
using IndexSequence = IntegerSequence<unsigned, Indices...>;
template <unsigned N>
using MakeIndexSequence = __make_integer_seq<IntegerSequence, unsigned, N>;
template <typename T, typename> struct VariantConstructors {
VariantConstructors(int t)
requires(requires { T(t); });
};
template <typename> struct ParameterPack;
template <unsigned, typename...> struct InheritFromUniqueEntries;
template <unsigned I, typename... Ts, unsigned... Js, typename... Qs>
struct InheritFromUniqueEntries<I, ParameterPack<Ts...>, IndexSequence<Js...>,
Qs...> : Ts... {};
template <typename...> struct InheritFromPacks;
template <unsigned... Is, typename... Ps>
struct InheritFromPacks<IndexSequence<Is...>, Ps...>
: InheritFromUniqueEntries<Is, Ps, IndexSequence<>>... {};
template <typename... Ps>
using MergeAndDeduplicatePacks =
InheritFromPacks<MakeIndexSequence<sizeof...(Ps)>, ParameterPack<Ps>...>;
template <typename... Ts>
struct Variant
: MergeAndDeduplicatePacks<VariantConstructors<Ts, Variant<Ts>>...> {
using MergeAndDeduplicatePacks<
VariantConstructors<Ts, Variant>...>::MergeAndDeduplicatePacks;
};
Variant<int> get_number_option(int);
template <typename Callback> void for_each_calendar_field(Callback callback) {
callback(0);
}
void create_date_time_format() {
for_each_calendar_field(
[&](auto property) -> void { get_number_option(property); });
}
<details> <summary>Stack trace</summary>
</details> |
@llvm/issue-subscribers-clang-frontend
Compiling the following code results in a segfault/assertion failure inside `SmallVector::operator[]` since 3ed9e9e (`"[Clang] Add captures to the instantiation scope of lambda call operators"`, @cor3ntin):
template <typename T, T...> struct IntegerSequence;
template <unsigned... Indices>
using IndexSequence = IntegerSequence<unsigned, Indices...>;
template <unsigned N>
using MakeIndexSequence = __make_integer_seq<IntegerSequence, unsigned, N>;
template <typename T, typename> struct VariantConstructors {
VariantConstructors(int t)
requires(requires { T(t); });
};
template <typename> struct ParameterPack;
template <unsigned, typename...> struct InheritFromUniqueEntries;
template <unsigned I, typename... Ts, unsigned... Js, typename... Qs>
struct InheritFromUniqueEntries<I, ParameterPack<Ts...>, IndexSequence<Js...>,
Qs...> : Ts... {};
template <typename...> struct InheritFromPacks;
template <unsigned... Is, typename... Ps>
struct InheritFromPacks<IndexSequence<Is...>, Ps...>
: InheritFromUniqueEntries<Is, Ps, IndexSequence<>>... {};
template <typename... Ps>
using MergeAndDeduplicatePacks =
InheritFromPacks<MakeIndexSequence<sizeof...(Ps)>, ParameterPack<Ps>...>;
template <typename... Ts>
struct Variant
: MergeAndDeduplicatePacks<VariantConstructors<Ts, Variant<Ts>>...> {
using MergeAndDeduplicatePacks<
VariantConstructors<Ts, Variant>...>::MergeAndDeduplicatePacks;
};
Variant<int> get_number_option(int);
template <typename Callback> void for_each_calendar_field(Callback callback) {
callback(0);
}
void create_date_time_format() {
for_each_calendar_field(
[&](auto property) -> void { get_number_option(property); });
}
<details> <summary>Stack trace</summary>
</details> |
CC @cor3ntin |
@erichkeane I'm very confused by what's happening there.
The issue is that happens in the context of the lambda - when checking the return type of The things i do not understand is what my change broke - as best as i can tell there is a weird context change somewhere that should not happen (?) The crash is easy to fix by handling unrelated declaration contexts in Note that I've been unsuccessful in reducing this further, which is odd. |
Hmm... that does seem strange, are we missing some sort of context being created when checking? It doesn't seem that the requires clause should be capturing from the lambda at all... |
Since 2023-09-08, Clang trunk has had a bug which causes a segfault when evaluating certain `requires` expressions inside templated lambdas. There isn't an imminent fix on the horizon, so let's work around the issue by specifying the type of the offending lambda arguments explicitly. See llvm/llvm-project#67260
Since 2023-09-08, Clang trunk has had a bug which causes a segfault when evaluating certain `requires` expressions inside templated lambdas. There isn't an imminent fix on the horizon, so let's work around the issue by specifying the type of the offending lambda arguments explicitly. See llvm/llvm-project#67260
Since 2023-09-08, Clang trunk has had a bug which causes a segfault when evaluating certain `requires` expressions inside templated lambdas. There isn't an imminent fix on the horizon, so let's work around the issue by specifying the type of the offending lambda arguments explicitly. See llvm/llvm-project#67260
Since 2023-09-08, Clang trunk has had a bug which causes a segfault when evaluating certain `requires` expressions inside templated lambdas. There isn't an imminent fix on the horizon, so let's work around the issue by specifying the type of the offending lambda arguments explicitly. See llvm/llvm-project#67260
This patch picks up #78598 with the hope that we can address such crashes in `tryCaptureVariable()` for unevaluated lambdas. In addition to `tryCaptureVariable()`, this also contains several other fixes on e.g. lambda parsing/dependencies. Fixes #63845 Fixes #67260 Fixes #69307 Fixes #88081 Fixes #89496 Fixes #90669 Fixes #91633
…93206) This patch picks up llvm#78598 with the hope that we can address such crashes in `tryCaptureVariable()` for unevaluated lambdas. In addition to `tryCaptureVariable()`, this also contains several other fixes on e.g. lambda parsing/dependencies. Fixes llvm#63845 Fixes llvm#67260 Fixes llvm#69307 Fixes llvm#88081 Fixes llvm#89496 Fixes llvm#90669 Fixes llvm#91633
Compiling the following code results in a segfault/assertion failure inside
SmallVector::operator[]
since 3ed9e9e ("[Clang] Add captures to the instantiation scope of lambda call operators"
, @cor3ntin):Stack trace
https://godbolt.org/z/roM4e3faE
The text was updated successfully, but these errors were encountered: