Bug 36473 - Missing lock in call to doneCreatingDatabase
Summary: Missing lock in call to doneCreatingDatabase
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Eric U.
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-03-22 18:20 PDT by Eric U.
Modified: 2010-03-25 23:06 PDT (History)
2 users (show)

See Also:


Attachments
Patch (1.76 KB, patch)
2010-03-22 18:51 PDT, Eric U.
no flags Details | Formatted Diff | Diff
Patch (3.07 KB, patch)
2010-03-25 10:47 PDT, Eric U.
no flags Details | Formatted Diff | Diff
Patch (3.46 KB, patch)
2010-03-25 15:13 PDT, Eric U.
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Eric U. 2010-03-22 18:20:39 PDT
The last call to doneCreatingDatabase in DatabaseTracker::canEstablishDatabase is called without locking m_databaseGuard.  This will assert in debug builds and use a supposedly-protected data structure without locking in release builds.  This is a bug in my last checkin [56293].

This wasn't caught by layout tests because we don't have one that tries to create a database with a large quota.
Comment 1 Eric U. 2010-03-22 18:51:53 PDT
Created attachment 51382 [details]
Patch
Comment 2 Dumitru Daniliuc 2010-03-22 19:01:40 PDT
LGTM, fwiw.
Comment 3 Eric Seidel (no email) 2010-03-25 00:28:14 PDT
Comment on attachment 51382 [details]
Patch

The test seems missing from this patch.
Comment 4 Eric U. 2010-03-25 10:47:31 PDT
Created attachment 51656 [details]
Patch
Comment 5 Eric U. 2010-03-25 10:48:03 PDT
Thanks Eric; forgot the svn add.
Comment 6 David Levin 2010-03-25 14:51:45 PDT
Comment on attachment 51656 [details]
Patch

> Index: WebCore/ChangeLog
> +        * storage/DatabaseTracker.cpp:  Added missing lock call.

Ideally your comment would be at the function level (which is where you did this change).

> +        (WebCore::DatabaseTracker::canEstablishDatabase):
> +

> Index: WebCore/storage/DatabaseTracker.cpp
> +    MutexLocker lockDatabase(m_databaseGuard);
>      doneCreatingDatabase(origin, name);

It seems nicer to do this:

  MutexLocker lockDatabase(m_databaseGuard);
  if (requirement <= quotaForOriginNoLock(origin))
      return true;
  
  doneCreatingDatabase(origin, name);

Opinion?
Comment 7 Eric U. 2010-03-25 15:13:15 PDT
(In reply to comment #6)
> (From update of attachment 51656 [details])
> > Index: WebCore/ChangeLog
> > +        * storage/DatabaseTracker.cpp:  Added missing lock call.
> 
> Ideally your comment would be at the function level (which is where you did
> this change).
> 
> > +        (WebCore::DatabaseTracker::canEstablishDatabase):
> > +

Fixed.

> > Index: WebCore/storage/DatabaseTracker.cpp
> > +    MutexLocker lockDatabase(m_databaseGuard);
> >      doneCreatingDatabase(origin, name);
> 
> It seems nicer to do this:
> 
>   MutexLocker lockDatabase(m_databaseGuard);
>   if (requirement <= quotaForOriginNoLock(origin))
>       return true;
> 
>   doneCreatingDatabase(origin, name);
> 
> Opinion?

Sure, and I'll do you one better; I can let the previous lock call out of its braces.
Comment 8 Eric U. 2010-03-25 15:13:57 PDT
Created attachment 51682 [details]
Patch
Comment 9 WebKit Commit Bot 2010-03-25 20:22:20 PDT
Comment on attachment 51682 [details]
Patch

Rejecting patch 51682 from commit-queue.

Unexpected failure when landing patch!  Please file a bug against webkit-patch.
Failed to run "['WebKitTools/Scripts/webkit-patch', '--status-host=webkit-commit-queue.appspot.com', 'land-attachment', '--force-clean', '--non-interactive', '--parent-command=commit-queue', '--build-style=both', '--quiet', '51682', '--no-update']" exit_code: 1
Last 500 characters of output:
ne 60, in _run
    step(tool, options).run(state)
  File "/Users/eseidel/Projects/CommitQueue/WebKitTools/Scripts/webkitpy/tool/steps/commit.py", line 34, in run
    commit_message = self._tool.checkout().commit_message_for_this_commit()
  File "/Users/eseidel/Projects/CommitQueue/WebKitTools/Scripts/webkitpy/common/checkout/api.py", line 65, in commit_message_for_this_commit
    return CommitMessage("".join(changelog_messages).splitlines())
NameError: global name 'CommitMessage' is not defined
Comment 10 Eric Seidel (no email) 2010-03-25 21:18:36 PDT
Comment on attachment 51682 [details]
Patch

I've restarted the commit-bot.  Sorry for the noise.
Comment 11 WebKit Commit Bot 2010-03-25 23:06:24 PDT
Comment on attachment 51682 [details]
Patch

Clearing flags on attachment: 51682

Committed r56604: <http://trac.webkit.org/changeset/56604>
Comment 12 WebKit Commit Bot 2010-03-25 23:06:28 PDT
All reviewed patches have been landed.  Closing bug.