Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deadlock when attaching simultaneously with services and standard APIs [CORE900] #1297

Closed
firebird-automations opened this issue Aug 16, 2006 · 14 comments

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: Diane Downie (dianedownie)

Is related to QA40

When 2 connections race to attach to a single database, one via the isc_service_attach and one via isc_attach_database a deadlock can occur. The following are the call stacks for the 2 threads in question. The mutex involved are those created by JRD_SS_MUTEX_LOCK and SecurityDatabase::lock().
Full fbserver.dmp is available for this issue.

ChildEBP RetAddr Args to Child
02cee494 7c822124 7c83970f 00000328 00000000 ntdll!KiFastSystemCallRet
02cee498 7c83970f 00000328 00000000 00000000 ntdll!NtWaitForSingleObject+0xc
02cee4d4 7c839620 00000000 00000004 02cee640 ntdll!RtlpWaitOnCriticalSection+0x19c
02cee4f4 004068ab 00582940 00421e4e 00582940 ntdll!RtlEnterCriticalSection+0xa8
02cee4fc 00421e4e 00582940 02cee790 004220ff fbserver!THD_mutex_lock+0xb [c:\40\buildparts\firebird\superserver\src\jrd\thd.cpp @ 729]
02cee508 004220ff 02ceeb5c 02cee790 02cee980 fbserver!SecurityDatabase::lock+0xe [c:\40\buildparts\firebird\superserver\src\jrd\pwd.cpp @ 130]
02cee5d8 004222b5 02cee790 02cee6a8 02cee6b4 fbserver!SecurityDatabase::lookup_user+0x6f [c:\40\buildparts\firebird\superserver\src\jrd\pwd.cpp @ 178]
02cee664 0045f22f 02cee790 02ceeb5c 00000000 fbserver!SecurityDatabase::verifyUser+0x65 [c:\40\buildparts\firebird\superserver\src\jrd\pwd.cpp @ 387]
02cee8fc 0041d29c 00000000 02ceeb7b 02ceeb5c fbserver!SCL_init+0x1bf [c:\40\buildparts\firebird\superserver\gen\jrd\scl.cpp @ 908]
02cef904 0040d970 02cefc34 00000006 02cefaf0 fbserver!jrd8_attach_database+0x8ac [c:\40\buildparts\firebird\superserver\src\jrd\jrd.cpp @ 1043]
02cefbf4 0051ee5c 02cefc34 00ff0006 00ff207c fbserver!isc_attach_database+0x280 [c:\40\buildparts\firebird\superserver\src\jrd\why.cpp @ 768]
02cefe84 00521fea 0259f01c 00000013 00ff4660 fbserver!attach_database+0x10c [c:\40\buildparts\firebird\superserver\src\remote\server.cpp @ 797]
02ceff4c 005226a8 0259f01c 00ff42d0 00ff4550 fbserver!process_packet+0x11a [c:\40\buildparts\firebird\superserver\src\remote\server.cpp @ 3090]
02ceff84 7c349565 0259f01c 00000000 00000000 fbserver!thread+0xd8 [c:\40\buildparts\firebird\superserver\src\remote\server.cpp @ 4863]
02ceffb8 77e6608b 025a33f8 00000000 00000000 MSVCR71!_endthreadex+0xa0
02ceffec 00000000 7c3494f6 025a33f8 00000000 kernel32!BaseThreadStart+0x34

ChildEBP RetAddr Args to Child
0368de94 7c822124 7c83970f 00000338 00000000 ntdll!KiFastSystemCallRet
0368de98 7c83970f 00000338 00000000 00000000 ntdll!NtWaitForSingleObject+0xc
0368ded4 7c839620 00000000 00000004 0368f194 ntdll!RtlpWaitOnCriticalSection+0x19c
0368def4 004068ab 0057f120 004069ec 0057f120 ntdll!RtlEnterCriticalSection+0xa8
0368defc 004069ec 0057f120 00000000 0041c5a2 fbserver!THD_mutex_lock+0xb [c:\40\buildparts\firebird\superserver\src\jrd\thd.cpp @ 729]
0368df08 0041c5a2 0057f120 00582958 00000000 fbserver!THD_rec_mutex_lock+0x1c [c:\40\buildparts\firebird\superserver\src\jrd\thd.cpp @ 1371]
0368e0b4 0041cb48 0368e128 00582958 0368ef14 fbserver!init+0xc2 [c:\40\buildparts\firebird\superserver\src\jrd\jrd.cpp @ 5563]
0368f0ac 0040d970 00582958 0000004a 0368f298 fbserver!jrd8_attach_database+0x158 [c:\40\buildparts\firebird\superserver\src\jrd\jrd.cpp @ 673]
0368f39c 00422002 00582958 00000000 0368f4d0 fbserver!isc_attach_database+0x280 [c:\40\buildparts\firebird\superserver\src\jrd\why.cpp @ 768]
0368f5d4 00422106 0052ec71 0368f79c 0368fa34 fbserver!SecurityDatabase::prepare+0x112 [c:\40\buildparts\firebird\superserver\src\jrd\pwd.cpp @ 303]
0368f6a4 004222b5 0368f79c 0368f784 0368f764 fbserver!SecurityDatabase::lookup_user+0x76 [c:\40\buildparts\firebird\superserver\src\jrd\pwd.cpp @ 178]
0368f730 00404c7c 0368f79c 0368f820 00000000 fbserver!SecurityDatabase::verifyUser+0x65 [c:\40\buildparts\firebird\superserver\src\jrd\pwd.cpp @ 387]
0368fa34 00417df8 0000000b 00ff4804 0000002b fbserver!SVC_attach+0x32c [c:\40\buildparts\firebird\superserver\src\jrd\svc.cpp @ 541]
0368fb2c 004102fb 0368fc3c 0000000b 00ff4804 fbserver!jrd8_service_attach+0x98 [c:\40\buildparts\firebird\superserver\src\jrd\jrd.cpp @ 3393]
0368fbf8 0051e80b 0368fc3c 005a000b 00ff4804 fbserver!isc_service_attach+0x16b [c:\40\buildparts\firebird\superserver\src\jrd\why.cpp @ 4339]
0368fe8c 00522004 02e33bc0 02e33830 00000000 fbserver!port::service_attach+0xfb [c:\40\buildparts\firebird\superserver\src\remote\server.cpp @ 4435]
0368ff4c 005226a8 00f6005c 02e33830 02e33ab0 fbserver!process_packet+0x134 [c:\40\buildparts\firebird\superserver\src\remote\server.cpp @ 3095]
0368ff84 7c349565 00f6005c 00000000 00000000 fbserver!thread+0xd8 [c:\40\buildparts\firebird\superserver\src\remote\server.cpp @ 4863]
0368ffb8 77e6608b 026cfee8 00000000 00000000 MSVCR71!_endthreadex+0xa0
0368ffec 00000000 7c3494f6 026cfee8 00000000 kernel32!BaseThreadStart+0x34

Commits: 6662545 c877054 186825d ba264a2

@firebird-automations
Copy link
Collaborator Author

Commented by: @AlexPeshkoff

I've just commited a very simple fix. Taking into account, that locked server is bad thing, I suggest to backport it to RELEASE branch, and this is the main reason why I've made fix simple. Please review it and decide, should it go to RELEASE or not.

After it I'll commit to HEAD a better fix, removing need to lock something in jrd8_service_attach(), but requiring more changes in SecurityDatabase.

@firebird-automations
Copy link
Collaborator Author

Modified by: @AlexPeshkoff

assignee: Alexander Peshkov [ alexpeshkoff ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @AlexPeshkoff

status: Open [ 1 ] => In Progress [ 3 ]

@firebird-automations
Copy link
Collaborator Author

Commented by: Diane Downie (dianedownie)

I would be like to test the 1.5.3 backport in my environment that reproduced the problem. I can build sources, so I would just need the files affected to start testing.

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

Fix Version: 2.0 RC5 [ 10071 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

priority: Critical [ 2 ] => Major [ 3 ]

Fix Version: 2.1 [ 10041 ]

Fix Version: 2.0 RC5 [ 10071 ] =>

@firebird-automations
Copy link
Collaborator Author

Commented by: @AlexPeshkoff

Fix is also backported to B2_0_Release, but currently I'm not sure which version should be marked in Fix Versions - 2.0.1 or (missing currently) 2.0.2.

@firebird-automations
Copy link
Collaborator Author

Modified by: @AlexPeshkoff

status: In Progress [ 3 ] => Resolved [ 5 ]

resolution: Fixed [ 1 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

Fix Version: 2.0.2 [ 10130 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

Fix Version: 2.1 Alpha 1 [ 10150 ]

Fix Version: 2.1.0 [ 10041 ] =>

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

Link: This issue is related to QA40 [ QA40 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

status: Resolved [ 5 ] => Closed [ 6 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

Workflow: jira [ 11154 ] => Firebird [ 15319 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

QA Status: No test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants