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

Long runnning connection causes mem leak in OS kernel device [CORE232] #563

Closed
firebird-automations opened this issue Apr 15, 2003 · 4 comments

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: @reevespaul

Assigned to: @samofatov

SFID: 721792#⁠
Submitted By: paul_reeves

Known Systems Impacted :

NT 4.0 Workstation SP 6a
2000 SP 3

Bug Description :

Whenever and local or remote client connects to the
database through TCP/IP (including
localhost:c:\whatever.gdb), the FB engine allocates
memory (presumably indirectly through a WinAPI function
call) from a Kernel Mode device driver.

This device driver has a tag name of AfdB, a filename
of afd.sys, and is described by Microsoft as "Ancillary
Function Driver for WinSock".

After the connection is made, even if no other activity
takes place, the FB engine continues to allocate memory
from AfdB. This memory comes from Windows Non-Paged
memory pool, which is a finite resource. After x number
days of running, this memory pool is exhausted and
Windows crashes with various insufficient memory errors
(usually starts with applications api calls returning
failure
errors.)

It appears that each connection made to the FB engine
starts this process going, so if you have multiple
connections, the exhaustion of the Non-Paged memory
pool will occur faster.

Now, when a connection disconnects from the server, the
Non-Paged memory that it used from AfdB is released.
The problem occurs when connections persist over a
period of days, or if other processes have already
depleted the available Non-Paged memory.

Viewing the Bug :

Since the actual non-paged memory is allocated from a
device driver, it's usage is not easily visible. If you
just watch the ibserver process in the task manager,
you will see no unusual memory usage. However, if you
view the Performance tabs Kernel Memory data, you will
note the Nonpaged memory slowly growing (since it is
measured
in K, it takes some time to see).

Fortunately, Microsoft has supplied a tool to help
troubleshoot Kernel Mode Memory Leaks called
poolmon.exe. This program displays different kernel
memory usages by tag (and again the tag of interest
is AfdB).

Once you have installed and run poolmon, you can
observe the Diff and Bytes for the AfdB process.
Connect through TCP/IP to the FB server a few times
(I'd suggest writing a quick program to automate
several simultaneous connections, but just using one
isql will also show the problem, but will take more
time to become obvious), and
you will notice the Diff and Bytes increase over time.
Again, once you disconnect this memory is released, but
it will keep growing until that time.

Errata :

- This bug was very difficult to find, given that it
isn't a true
leak (the memory is eventually regained upon
disconnection or server shutdown), and that it involved
the actual "leak" occurring in a kernel mode device.
Plus, since it goes away on disconnection, it took a
while to eliminate my applications as being the cause
of the
leak. I believe this bug has not been found before
since it requires a continuous connection for a long
period of time, which is not typical for a RDBMS, and
is also not a memory leak.

However, it has the nasty consequence that one
connection left over enough days can cause the entire
system to crash through memory starvation, which can
cause problems with hard drive corruption, etc.

- I had the opportunity to test InterBase 5.6 for this
same issue, and found that this bug does in fact exist
in IB 5.6 as well.

- While AfdB seems to be the driver most impacted, it
is possible that other resources are also being
consumed by the continuous connection.

References :

How to Use Poolmon : MS KB Article Q177415
Poolmon Location :

On NT4 it is on the OS Install CD, located in
Support\Debug\platform.

On 2000, it is also on the OS Install CD, located in the
support.cab file under the \Support\Tools folder.

Note that for both, a registry entry detailed in the
above KB article is required.

Regards,

Bill Morrison

@firebird-automations
Copy link
Collaborator Author

Commented by: Alice F. Bird (firebirds)

Date: 2003-09-18 13:29
Sender: skidder
Logged In: YES
user_id=495356

The problem had to be fixed in Firebird 1.5 RC6

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

Workflow: jira [ 10256 ] => Firebird [ 14488 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

QA Status: No test

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

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

QA Status: No test => Cannot be tested

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

1 participant