Closed sichbo closed 5 years ago
Hi, Simon.
I can repro the crash (I updated Microsoft.Windows.CppWinRT to the latest version in order to get a build). Then, I updated the C# project to 17763, and that got me further in the debugger. But still, there seemed to be an issue with the code someplace. I see you're using one of the helper functions for collections. In this case, though, I tweaked your code to use the equivalent one of the base classes for collections. And I was able to bypass the issue of m_Impl being invalid. FYI, here's the class:
struct ThingCollection :
implements<ThingCollection, IVector<A::Thing>, IVectorView<A::Thing>, IIterable<A::Thing>>,
winrt::vector_base<ThingCollection, A::Thing>
{
ThingCollection()
{
m_values.push_back(winrt::make<A::implementation::Thing>());
}
auto& get_container() const noexcept
{
return m_values;
}
auto& get_container() noexcept
{
return m_values;
}
private:
std::vector<A::Thing> m_values{ winrt::make<A::implementation::Thing>(), winrt::make<A::implementation::Thing>() };
};
The C# project is Output-ing the expected Size(). Since that sidesteps the immediate issue, you might want to just go that way.
Meanwhile, I'll let the product team know about this GitHub Issue in case they want to advise us and/or file a bug on the debugger. And, just FYI, customers always have these options: For issues, or suspected product bugs, there's Microsoft Support; a support engineer will look at the repro and see whether the issue is a product bug or something else. For Visual Studio issues, there's the Visual Studio User Voice feedback website, or the Developer Community. The Windows developer feedback site is the right place to file a product bug.
For problems/errors/omissions with the actual documentation, this is the right forum to raise those. Please let me know if there's anything that I can do to improve the documentation here. And thanks again for the feedback and your diligence in reporting these issues. :) ~Steve
So, there is a known mixed-mode debugging bug in Visual Studio; the visualizer within the C++/WinRT VSIX contains a workaround. That combined with what I found, means that some combination of upgrading your VSIX and/or the target SDK of your projects should alleviate that issue. But if the base classes for collections work for you (you don't have to shim all those methods), then that might be better. ~Steve
Thanks for that, Steve!
You're earning your coffee today :)
Many thanks for the vector_base sample and passing along the debugger issue and finding out about the known mixed-mode bug. Traditionally when I've encountered behaviour like this in VS it was my own stupid fault and needed Intel xe memory inspector to find the source (typically hand coded asm/intrinsic mistakes.)
My understanding of the wpdev uservoice site was that it was only for feature suggestions. If it's a good way to get bugs looked at like you say, I'll try filing a broker infrastructure bug that I've been sitting on. When I tried getting somebody to look at it through the msdn support forum, they just said I had to open an incident through the main support channel you linked. The problem with that is it's a $300 "gamble" as to whether or not it's actually a bug and you need to buy an incident prior to submission and I'm pretty sure there are no refunds either way. For an indie developer who hasn't earned a penny in three years that's a bit rough.
Anyhoo, it sounds like this issue is well in-hand already so we can close it out. Thanks again, Steve.
You're right, Simon, the Developer Community is probably better for bug reports than the UserVoice is. I just wanted to enumerate all the channels, as they're all ways to get data to Microsoft (some better channels than others for that), where "data" is "hey, someone else is having this issue, too." As a customer, I might feel like my single lone voice won't prevail, so why bother; on the other hand, until Microsoft gets a good sample of the population of folks an issue is affecting, we're not sure how to prioritize it. So it's great to get all the data we can. I can't speak with certainty to the refund question, but I'll make enquiries since it seems like something I should know for sure. :)
Thanks again for the outstanding support, Steve. There was a "bugs" category on uservoice, so I went ahead and uploaded a MVCE on that other issue. Cheers!
Cool! You're welcome! :)
Just one last bit of info, Simon, FYI. You needn't be concerned on this score: "it's a $300 "gamble" as to whether or not it's actually a bug and you need to buy an incident prior to submission and I'm pretty sure there are no refunds either way."
For future reference: if you pay to open up a new professional support incident and the issue leads to a confirmed bug by the dev team, then you can request a refund and it will get processed. Just be sure to verify with the case owner that, when the case is closed, it's linked to the correct BUG number.
Great to know — thanks for the tip!
Note: Visual Studio 16.0.0 preview 3 will contain a fix for the mixed mode debugging issue mentioned by @stevewhims (the workaround was only partly effective)
I may doing something wrong here, but a basic custom collection returned by a WinRT component seems to crash the IDE debugger.
I've posted an MVCE here: https://github.com/sichbo/WinRTCollectionCrash
The gist of it is: Basic MIDL definition
In your
ThingCollection
implementation, simply shim all of the interface methods into a backing:Breakpoint on something like
ThingCollection.Size()
and have an external app consume the component. Hovering overm_Impl
or attempting to seethis
in the watch window will hose the app and crash the debugging experience.My assumption of the WinRT wizardry is that everything should be kept alive until the client app destroys its projected instance? What we're seeing instead are symptoms of stack imbalance/memory corruption. Digging into the disassembly we can see "this" is wiped out with a debugger hint address 0xCCCCCCCC. Trying to disassemble further up the ABI chain inside of the
Size()
method will crash the debugger.Interestingly, you can get slightly further along by changing that IVector backing instance to
const&
like so:… with that, you at least get what looks like a sane "this" pointer.. but alas, expanding it then crashes not only the debugger, but the full Visual Studio IDE.
What gives?
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.