Skip to content

Fix segfault when processing types with unresolved lifetimes in generic arguments#4436

Open
v1bh475u wants to merge 3 commits intoRust-GCC:masterfrom
v1bh475u:fix/typecheck-unresolved-lifetime-segfault
Open

Fix segfault when processing types with unresolved lifetimes in generic arguments#4436
v1bh475u wants to merge 3 commits intoRust-GCC:masterfrom
v1bh475u:fix/typecheck-unresolved-lifetime-segfault

Conversation

@v1bh475u
Copy link


Fixes #3611

When resolving type paths with generic arguments, if a lifetime fails to resolve, regions_from_generic_args() returns an empty vector. Previously, this empty vector was passed to SubstMapper::Resolve, creating types with uninitialized Region data. Later, variance analysis would crash when processing these malformed types.

Fix:

  • resolve_root_path() : check if regions_from_generic_args() failed and return ErrorType immediately instead of creating malformed types
  • visit(ReferenceType&): propagate ErrorType when encountered

@v1bh475u v1bh475u force-pushed the fix/typecheck-unresolved-lifetime-segfault branch from e178f86 to b9b1d7c Compare February 13, 2026 21:52
gcc/rust/ChangeLog:

	* typecheck/rust-hir-type-check-type.cc (TypeCheckType::resolve_root_path): check for unresolved lifetimes.

Signed-off-by: vibhatsu <maulikbarot2915@gmail.com>
gcc/rust/ChangeLog:

	* typecheck/rust-hir-type-check-type.cc (TypeCheckType::visit): propagate error type in ReferenceType resolution

Signed-off-by: vibhatsu <maulikbarot2915@gmail.com>
gcc/testsuite/ChangeLog:

	* rust/compile/unresolved-lifetime-in-generic-arg.rs: New test.

Signed-off-by: vibhatsu <maulikbarot2915@gmail.com>
@v1bh475u v1bh475u force-pushed the fix/typecheck-unresolved-lifetime-segfault branch from b9b1d7c to d4b0c14 Compare February 13, 2026 22:08
@v1bh475u
Copy link
Author

The build fails due to filename. Will fix it but need help for the changelog. After we are certain about the changelog, I will do a final rebase to finish all the changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ICE: segfault with recursive enum

1 participant