Bug 69277

Summary: A little more WebSQLDatabase thread safety
Product: WebKit Reporter: Michael Nordman <michaeln>
Component: WebCore Misc.Assignee: Michael Nordman <michaeln>
Status: RESOLVED FIXED    
Severity: Normal CC: ap, levin, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
safer
none
safer
ap: commit-queue-
safer none

Description Michael Nordman 2011-10-03 12:06:47 PDT
We're getting reports of INVALID_STATE exceptions being throw from the openDatabase method. It looks like there some unsafe initialization code paths that may be the culprit.
Comment 1 Michael Nordman 2011-10-03 12:12:08 PDT
Created attachment 109505 [details]
safer
Comment 2 WebKit Review Bot 2011-10-03 12:13:46 PDT
Attachment 109505 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebCore/ChangeLog', u'Source/WebCor..." exit_code: 1

Source/WebCore/ChangeLog:5:  Need whitespace between colon and description  [changelog/filechangedescriptionwhitespace] [5]
Source/WebCore/ChangeLog:6:  Need whitespace between colon and description  [changelog/filechangedescriptionwhitespace] [5]
Total errors found: 2 in 5 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Michael Nordman 2011-10-03 12:27:41 PDT
Created attachment 109508 [details]
safer

made some whitespace changes in the changelog file
Comment 4 Alexey Proskuryakov 2011-10-03 14:11:56 PDT
Comment on attachment 109508 [details]
safer

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

I don't understand thread-safe string copying well enough, so leaving this for someone else (Dave Levin?) to review.

> Source/WebCore/storage/AbstractDatabase.cpp:51
> +static const char versionKey[] = "WebKitDatabaseVersionKey";

Is this actually guaranteed to not use initialization, or do you need to use a pointer?

> Source/WebCore/storage/AbstractDatabase.cpp:298
> +            const String tableName(infoTableName);

We don't use local const variables in WebKit.

> Source/WebCore/storage/AbstractDatabase.cpp:396
> +    const String query(String("SELECT value FROM ") + infoTableName +  " WHERE key = '" + versionKey + "';");

We don't use local const variables in WebKit.

> Source/WebCore/storage/AbstractDatabase.cpp:416
> +    const String query(String("INSERT INTO ") + infoTableName +  " (key, value) VALUES ('" + versionKey + "', ?);");

We don't use local const variables in WebKit.
Comment 5 Michael Nordman 2011-10-03 14:23:49 PDT
Created attachment 109530 [details]
safer
Comment 6 Michael Nordman 2011-10-03 14:26:11 PDT
> Is this actually guaranteed to not use initialization, or do you need to use a pointer?

Yes, no.

> We don't use local const variables in WebKit.

Done x 3
Comment 7 David Levin 2011-10-03 14:57:17 PDT
Comment on attachment 109530 [details]
safer

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

Looks great!

> Source/WebCore/storage/AbstractDatabase.cpp:2
> + * Copyright (C) 2011 Google Inc. All rights reserved.

In WebKit, we leave the year in tact, so this would become 2010, 2011.

But you don't need to change this back -- just fyi for future changes.
Comment 8 Michael Nordman 2011-10-03 14:58:47 PDT
thank you good reviewer sir!
Comment 9 WebKit Review Bot 2011-10-03 16:06:43 PDT
Comment on attachment 109530 [details]
safer

Clearing flags on attachment: 109530

Committed r96554: <http://trac.webkit.org/changeset/96554>
Comment 10 WebKit Review Bot 2011-10-03 16:06:47 PDT
All reviewed patches have been landed.  Closing bug.