Skip to content

Conversation

egorzhdan
Copy link
Contributor

@egorzhdan egorzhdan commented Sep 3, 2025

  • Explanation: When calling a C++ function that takes a reference to a pointer to a foreign reference type, Swift would previously pass a pointer to the foreign reference type as an argument (instead of a reference to a pointer), which resulted in invalid memory accesses.
  • Scope: This changes IRGen logic that handles function parameters of foreign reference types.
  • Issues: rdar://150791778
  • Original PRs: [cxx-interop] Pass foreign reference types with correct level of indirection #83850
  • Risk: Low, this fixes a runtime crash, and the code is now covered by tests.
  • Testing: Added a compiler test.
  • Reviewers: @Xazax-hun

…rection

When calling a C++ function that takes a reference to a pointer to a foreign reference type, Swift would previously pass a pointer to the foreign reference type as an argument (instead of a reference to a pointer), which resulted in invalid memory accesses.

This was observed when using `std::vector<ImmortalRef*>::push_back`.

rdar://150791778
(cherry picked from commit 0a766e5)
@egorzhdan egorzhdan added the c++ interop Feature: Interoperability with C++ label Sep 3, 2025
@egorzhdan
Copy link
Contributor Author

@swift-ci please test

@egorzhdan
Copy link
Contributor Author

@swift-ci please test Windows

@egorzhdan egorzhdan requested a review from beccadax September 4, 2025 12:35
@egorzhdan egorzhdan marked this pull request as ready for review September 4, 2025 12:38
@egorzhdan egorzhdan requested a review from a team as a code owner September 4, 2025 12:38
@egorzhdan
Copy link
Contributor Author

@swift-ci please test Windows

@egorzhdan egorzhdan merged commit 0059c42 into swiftlang:release/6.2 Sep 5, 2025
5 checks passed
@egorzhdan egorzhdan deleted the egorzhdan/6.2-frt-indirection branch September 5, 2025 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ interop Feature: Interoperability with C++
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants