Issue Details (XML | Word | Printable)

Key: CORE-4500
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Critical Critical
Assignee: Dmitry Yemanov
Reporter: Y. Numai
Votes: 0
Watchers: 5

If you were logged in you would be able to see more operations.
Firebird Core

Firebird crashes after unsuccessful remapping of the lock table's shared memory

Created: 25/Jul/14 10:23 AM   Updated: 23/Sep/15 11:28 AM
Component/s: Engine
Affects Version/s: 2.5.2, 2.5.2 Update 1, 2.5.3
Fix Version/s: 3.0 Beta 1, 2.5.4

OS: Windows Server 2012
Firebird: embeded server V2.5.1.26351
Crashed Application: [My C# Windows Service App (.exe) for .NET 4.0] => [.NET Data Provider (.dll)] => [Firebird Embeded Server (.dll)]

QA Status: Cannot be tested

 Description  « Hide
My C# Windows Service Application uses .NET Data Provider and FB Embeded server (fbembed.dll).
However, it sometimes crashes when it connects to a firebird database file.

===EventLog(Application) EID 1026===
Exception: System.AccessViolationException
   at FB_1236665269_Class.isc_attach_database(IntPtr[], Int16, Byte[], Int32 ByRef, Int16, Byte[])
   at FB_1236665269_Class.isc_attach_database(IntPtr[], Int16, Byte[], Int32 ByRef, Int16, Byte[])
   at FirebirdSql.Data.Client.Native.FesDatabase.Attach(FirebirdSql.Data.Common.DatabaseParameterBuffer, System.String, Int32, System.String)
   at FirebirdSql.Data.FirebirdClient.FbConnectionInternal.Connect()
   at FirebirdSql.Data.FirebirdClient.FbConnectionPool.Create()
   at FirebirdSql.Data.FirebirdClient.FbConnectionPool.CheckOut()
   at FirebirdSql.Data.FirebirdClient.FbConnection.Open()

===EventLog(Application) EID 1000===
Faulting application name: MyApp.exe, version:, time stamp: 0x52eb5d90
Faulting module name: fbembed.DLL, version:, time stamp: 0x4e89609d
Exception code: 0xc0000005
Fault offset: 0x000000000027963b
Faulting process id: 0x450
Faulting application start time: 0x01cf7f979c1b46a3
Faulting application path: C:\Program Files\MyApp\MyApp.exe
Faulting module path: C:\Program Files\MyApp\fbembed.DLL

When my app crashed, it created firebird.log as below.

ServerName Fri Jun 20 23:51:31 2014
Fatal lock manager error: ISC_map_file failed (reattach shared file), errno: 1224

I investigated my application crash dump file, and I finally found out that my app has crashed at fwrite()
in the method "LockManager::bug()."

====ll.1651-1655 at Firebird-\src\lock\lock.cpp, ====
if (fd)
fwrite(m_header, 1, m_header->lhb_used, fd);

I have a hunch that if "LockManager::acquire_shmem()" failed to "attach_shared_file" (l.1149 at lock.cpp), it calls "LockManager::bug()" (l.1150 at lock.cpp).
"LockManager::bug()" referes "m_header->lhb_used" as it shows above.

However, if "LockManager::attach_shared_file()" fails, m_header will be NULL.

====ll.337-340 at Firebird-\src\lock\lock.cpp, ====
m_header = (lhb*) ISC_map_file(status, name.c_str(), initialize, this, m_memorySize, &m_shmem);

if (!m_header)
return false;

Therefore, NULL-reference seems to occur at "fwrite(m_header, 1, m_header->lhb_used, fd)."

 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Sean Leyne added a comment - 27/Jul/14 06:24 PM
What path is the database file in?

Have you confirmed that the local user has read/write access to this folder?

Y. Numai added a comment - 29/Jul/14 03:34 AM
The answer for your first question is....
The database file which my application failed to access is "C:\MyAppData\data\2014-06-20.db."

About the second question,
my application works as local system account (NT_Authority\SYSTEM) and
the local system account has NTFS access rights to read/write to the above database file.
Therefore, I certainly have a right permission to access the database and there is no problem related to this.

I think you might misunderstand what I am talking about.
The point I want to describe is that *NULL pointer reference* after "fatal lock manager error"
but not "fatal lock manager error " itself.

My application insert data to the database for every minite.
In addition to this, the data backup application works in the same computer as my application does work.
This is the reason why "Fatal lock manager error: ISC_map_file failed (reattach shared file)" occurred
to the database file (because of the simultaneous access).
So far, Firebird works correctly.

However, after this error-catch, "LockManager::bug()" is called at l.1150 at lock.cpp (Firebird-,
then an application that uses fbembed.dll always crashes because of NULL pointer reference.
This is what I am pointing out.

Could you see the actual code and review this issue?
I would appriciate if you get a resolution for this problem.

Thank you.

Dmitry Yemanov added a comment - 29/Jul/14 05:52 AM
It should be fixed now, thanks.