Bug 93128

Summary: [WIN] Use BString in favour of BSTR to improve memory management
Product: WebKit Reporter: Patrick R. Gansterer <paroga>
Component: WebKit APIAssignee: Patrick R. Gansterer <paroga>
Status: RESOLVED FIXED    
Severity: Normal CC: andersca, aroben, bfulgham, hausmann, rniwa, roger_fong, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: PC   
OS: Windows XP   
Bug Depends on: 96958    
Bug Blocks:    
Attachments:
Description Flags
Patch
none
Patch
webkit.review.bot: commit-queue-
Patch none

Description Patrick R. Gansterer 2012-08-03 08:56:39 PDT
[WIN] Use BString in favour of BSTR to improve memory management
Comment 1 Patrick R. Gansterer 2012-08-03 09:02:28 PDT
Created attachment 156394 [details]
Patch
Comment 2 Eric Seidel (no email) 2012-08-07 15:27:15 PDT
Comment on attachment 156394 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=156394&action=review

> Source/WebCore/platform/win/BString.cpp:130
> -    if (m_bstr)
> -        SysFreeString(m_bstr);
> +    clear();

Is SysFreeString null-safe?  The previous code didn't seem to think so.
Comment 3 Patrick R. Gansterer 2012-08-07 23:10:45 PDT
Comment on attachment 156394 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=156394&action=review

>> Source/WebCore/platform/win/BString.cpp:130
>> +    clear();
> 
> Is SysFreeString null-safe?  The previous code didn't seem to think so.

Yes it is. The previous code did only on a few places.
Comment 4 WebKit Review Bot 2012-09-17 14:43:29 PDT
Comment on attachment 156394 [details]
Patch

Clearing flags on attachment: 156394

Committed r128809: <http://trac.webkit.org/changeset/128809>
Comment 5 WebKit Review Bot 2012-09-17 14:43:32 PDT
All reviewed patches have been landed.  Closing bug.
Comment 6 WebKit Review Bot 2012-09-17 14:58:35 PDT
Re-opened since this is blocked by 96958
Comment 7 Patrick R. Gansterer 2012-09-18 14:22:10 PDT
Created attachment 164621 [details]
Patch
Comment 8 WebKit Review Bot 2012-09-19 03:34:59 PDT
Comment on attachment 164621 [details]
Patch

Rejecting attachment 164621 [details] from commit-queue.

Failed to run "['/mnt/git/webkit-commit-queue/Tools/Scripts/webkit-patch', '--status-host=queues.webkit.org', '-..." exit_code: 1

ERROR: /mnt/git/webkit-commit-queue/Source/WebCore/ChangeLog neither lists a valid reviewer nor contains the string "Unreviewed" or "Rubber stamp" (case insensitive).

Full output: http://queues.webkit.org/results/13898489
Comment 9 Patrick R. Gansterer 2012-09-19 03:55:08 PDT
Created attachment 164707 [details]
Patch
Comment 10 WebKit Review Bot 2012-09-19 04:15:10 PDT
Comment on attachment 164707 [details]
Patch

Clearing flags on attachment: 164707

Committed r128988: <http://trac.webkit.org/changeset/128988>
Comment 11 WebKit Review Bot 2012-09-19 04:15:14 PDT
All reviewed patches have been landed.  Closing bug.
Comment 12 Roger Fong 2012-09-25 16:20:18 PDT
Hello, this patch is causing an assertion failure on Windows. All I'm doing is launching WinLauncher.

I get an assertion failure ASSERTION FAILED !m_bstr.

Here's the stack trace.


 	WebKit.dll!WebCore::BString::operator&()  Line 61 + 0x3a bytes	C++
>	WebKit.dll!WebView::notifyPreferencesChanged(IWebNotification * notification=0x005fefb8)  Line 4591 + 0x16 bytes	C++
 	WebKit.dll!WebView::onNotify(IWebNotification * notification=0x005fefb8)  Line 4549 + 0xf bytes	C++
 	WebKit.dll!WebNotificationCenter::postNotificationInternal(IWebNotification * notification=0x005fefb8, wchar_t * notificationName=0x004fb9bc, IUnknown * anObject=0x005be918)  Line 131 + 0x14 bytes	C++
 	WebKit.dll!WebNotificationCenter::postNotificationName(wchar_t * notificationName=0x004fb9bc, IUnknown * anObject=0x005be918, IPropertyBag * userInfo=0x00000000)  Line 188	C++
 	WebKit.dll!WebPreferences::postPreferencesChangesNotification()  Line 144 + 0x1c bytes	C++
 	WebKit.dll!WebView::initWithFrame(tagRECT frame={...}, wchar_t * frameName=0x00000000, wchar_t * groupName=0x00000000)  Line 2726	C++
 	WinLauncher.dll!dllLauncherEntryPoint(HINSTANCE__ * __formal=0x00120000, HINSTANCE__ * __formal=0x00120000, HINSTANCE__ * __formal=0x00120000, int nCmdShow=1)  Line 368 + 0x35 bytes	C++
 	WinLauncher.exe!wWinMain(HINSTANCE__ * hInstance=0x00120000, HINSTANCE__ * hPrevInstance=0x00000000, wchar_t * lpstrCmdLine=0x004a4afe, int nCmdShow=1)  Line 208 + 0x18 bytes	C++
 	WinLauncher.exe!__tmainCRTStartup()  Line 589 + 0x1c bytes	C
 	kernel32.dll!@BaseThreadInitThunk@12()  + 0x12 bytes	
 	ntdll.dll!___RtlUserThreadStart@8()  + 0x27 bytes	
 	ntdll.dll!__RtlUserThreadStart@8()  + 0x1b bytes	

Do you mind taking a look, it's preventing my from debugging things...
Thanks!
Comment 13 Roger Fong 2012-09-25 16:31:23 PDT
(In reply to comment #12)
> Hello, this patch is causing an assertion failure on Windows. All I'm doing is launching WinLauncher.
> 
> I get an assertion failure ASSERTION FAILED !m_bstr.
> 
> Here's the stack trace.
> 
> 
>      WebKit.dll!WebCore::BString::operator&()  Line 61 + 0x3a bytes    C++
> >	WebKit.dll!WebView::notifyPreferencesChanged(IWebNotification * notification=0x005fefb8)  Line 4591 + 0x16 bytes	C++
>      WebKit.dll!WebView::onNotify(IWebNotification * notification=0x005fefb8)  Line 4549 + 0xf bytes    C++
>      WebKit.dll!WebNotificationCenter::postNotificationInternal(IWebNotification * notification=0x005fefb8, wchar_t * notificationName=0x004fb9bc, IUnknown * anObject=0x005be918)  Line 131 + 0x14 bytes    C++
>      WebKit.dll!WebNotificationCenter::postNotificationName(wchar_t * notificationName=0x004fb9bc, IUnknown * anObject=0x005be918, IPropertyBag * userInfo=0x00000000)  Line 188    C++
>      WebKit.dll!WebPreferences::postPreferencesChangesNotification()  Line 144 + 0x1c bytes    C++
>      WebKit.dll!WebView::initWithFrame(tagRECT frame={...}, wchar_t * frameName=0x00000000, wchar_t * groupName=0x00000000)  Line 2726    C++
>      WinLauncher.dll!dllLauncherEntryPoint(HINSTANCE__ * __formal=0x00120000, HINSTANCE__ * __formal=0x00120000, HINSTANCE__ * __formal=0x00120000, int nCmdShow=1)  Line 368 + 0x35 bytes    C++
>      WinLauncher.exe!wWinMain(HINSTANCE__ * hInstance=0x00120000, HINSTANCE__ * hPrevInstance=0x00000000, wchar_t * lpstrCmdLine=0x004a4afe, int nCmdShow=1)  Line 208 + 0x18 bytes    C++
>      WinLauncher.exe!__tmainCRTStartup()  Line 589 + 0x1c bytes    C
>      kernel32.dll!@BaseThreadInitThunk@12()  + 0x12 bytes    
>      ntdll.dll!___RtlUserThreadStart@8()  + 0x27 bytes    
>      ntdll.dll!__RtlUserThreadStart@8()  + 0x1b bytes    
> 
> Do you mind taking a look, it's preventing my from debugging things...
> Thanks!

In notifyPreferencesChanged, it looks like the bstr gets set on     
settings->setCursiveFontFamily(toAtomicString(str));.

Later a reference to said bstr gets passed into     
hr = preferences->defaultTextEncodingName(&str);

For some reason the &operator for bstrings is overriden to assert(!b_str). I'm not sure why though...
Comment 14 Patrick R. Gansterer 2012-09-26 00:05:00 PDT
Committed r129598: <http://trac.webkit.org/changeset/129598>