http://bugs.winehq.org/show_bug.cgi?id=30839
--- Comment #4 from Jacek Caban jacek@codeweavers.com 2012-06-13 10:51:07 CDT --- (In reply to comment #3)
An investigation shows that commenting out HeapFree() in SysFreeString() fixes all the problems with corrupted strings in that large and complex application I have here. So, it appears that the problem is not that BSTR cache corrupts its entries, but that strings get corrupted because they don't get cached.
Yeah, that's how the cache works. Any cache would work this way, implementations may differ only by when which string is freed.
Before closing this bug as invalid I'd like to ask: Jacek, do you have an idea how BSTR cache could be improved so that older strings get replaced by newer ones once the cache is full?
That's not exactly what happened when I was testing how BSTR cache is supposed to work.
Again, we can't get exactly the same behavior as native unless you'd reverse engineer oleaut32. What we can do is make sure that some patterns work with our implementation, but we need to know that pattern first. To give you an example:
str1 = SysAllocStringLen(..., 20); str2 = SysAllocStringLen(..., 20); SysFreeString(str1); SysFreeString(str2);
DoSomethingNotAllocatingNewBSTRsWithStrings(str1, str2);
is something guaranteed to work. Obviously it's a trivial example, but if your app really works reasonably well on Windows, it must follow another pattern that happens to work. Without understanding it, I don't see how we can fix the problem.