Bug 132145

Summary: ASSERTION FAILED: "currentPageSize || !m_db" in fast/workers/storage/use-same-database-in-page-and-workers.html
Product: WebKit Reporter: Mark Lam <mark.lam>
Component: WebCore Misc.Assignee: Mark Lam <mark.lam>
Status: ASSIGNED ---    
Severity: Normal CC: ahmad.saleem792, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   

Description Mark Lam 2014-04-24 14:21:05 PDT
Build a debug build of ToT, and run:
$ JSC_slowPathAllocsBetweenGCs=1 DumpRenderTree LayoutTests/fast/workers/storage/use-same-database-in-page-and-workers.html

You will see the following assertion failure:

Thread 30 Crashed:: WebCore: Database
0   com.apple.JavaScriptCore      	0x000000010cb00fca WTFCrash + 42 (Assertions.cpp:333)
1   com.apple.WebCore             	0x000000010fecbf5f WebCore::SQLiteDatabase::setMaximumSize(long long) + 127 (SQLiteDatabase.cpp:186)
2   com.apple.WebCore             	0x000000010feda167 WebCore::SQLTransactionBackend::openTransactionAndPreflight() + 503 (SQLTransactionBackend.cpp:584)
3   com.apple.WebCore             	0x000000010fedcc06 WebCore::SQLTransactionStateMachine<WebCore::SQLTransactionBackend>::runStateMachine() + 342 (SQLTransactionStateMachine.h:104)
4   com.apple.WebCore             	0x000000010fedbad2 WebCore::SQLTransactionBackend::performNextStep() + 34 (SQLTransactionBackend.cpp:519)
5   com.apple.WebCore             	0x000000010e73cb6d WebCore::DatabaseBackend::DatabaseTransactionTask::doPerformTask() + 45 (DatabaseTask.cpp:187)
6   com.apple.WebCore             	0x000000010e73c6ad WebCore::DatabaseTask::performTask() + 157 (DatabaseTask.cpp:97)
7   com.apple.WebCore             	0x000000010e73d4d2 WebCore::DatabaseThread::databaseThread() + 274 (DatabaseThread.cpp:198)
8   com.apple.WebCore             	0x000000010e73d34d WebCore::DatabaseThread::databaseThreadStart(void*) + 29 (DatabaseThread.cpp:105)
9   com.apple.JavaScriptCore      	0x000000010cb53210 WTF::threadEntryPoint(void*) + 144 (Threading.cpp:68)
10  com.apple.JavaScriptCore      	0x000000010cb53ef8 WTF::wtfThreadEntryPoint(void*) + 296 (ThreadingPthreads.cpp:168)
11  libsystem_pthread.dylib       	0x00007fff863fe899 _pthread_body + 138
12  libsystem_pthread.dylib       	0x00007fff863fe72a _pthread_start + 137
13  libsystem_pthread.dylib       	0x00007fff86402fc9 thread_start + 13

frame #1: 0x0000000103e30f5f WebCore`WebCore::SQLiteDatabase::setMaximumSize(this=0x000000010b510328, size=5193728) + 127 at SQLiteDatabase.cpp:186
   183 	    
   184 	    int currentPageSize = pageSize();
   185 	
-> 186 	    ASSERT(currentPageSize || !m_db);
   187 	    int64_t newMaxPageCount = currentPageSize ? size / currentPageSize : 0;
   188 	    
   189 	    MutexLocker locker(m_authorizerLock);
Comment 1 Radar WebKit Bug Importer 2014-04-24 14:22:11 PDT
<rdar://problem/16717279>
Comment 2 Ahmad Saleem 2024-04-12 03:48:14 PDT
This test was removed in below comment in 2015 - https://github.com/WebKit/WebKit/commit/1b267949c79a5f6f2ee6b1550c9673c2fb698139

Although we still have this ASSERT:

https://searchfox.org/wubkat/rev/8ce70fa03821ea1c7a19a3913730ffe6b8a522ed/Source/WebCore/platform/sql/SQLiteDatabase.cpp#363

void SQLiteDatabase::setMaximumSize(int64_t size)
{
    if (size < 0)
        size = 0;
    
    int currentPageSize = pageSize();

    ASSERT(currentPageSize || !m_db);
    int64_t newMaxPageCount = currentPageSize ? size / currentPageSize : 0;
    
    Locker locker { m_authorizerLock };
    enableAuthorizer(false);

    auto statement = prepareStatementSlow(makeString("PRAGMA max_page_count = ", newMaxPageCount));
    if (!statement || statement->step() != SQLITE_ROW)
        LOG_ERROR("Failed to set maximum size of database to %lli bytes", static_cast<long long>(size));

    enableAuthorizer(true);

}