Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

BUG: "Memory could not be read" Error Occurs with ODBC Under High Stress


View products that this article applies to.

This article was previously published under Q281735

↑ Back to the top


Symptoms

Applications that call the LoadLibrary and FreeLibrary functions for a dynamic-link library (DLL) that uses Odbc32.dll may receive the following error message when multiple instances of the application are running under a heavily stressed environment:
"YourApp.EXE - Application Error: The instruction at '0x1f8148d9' referenced memory '0x1f8148d9'. The memory could not be 'read'."

↑ Back to the top


Cause

Odbc32.dll generates a secondary thread to monitor the ODBC registry keys. When Odbc32.dll is unloading, it waits 100 milliseconds for the secondary thread to terminate. After 100 milliseconds, it unloads itself, even if the thread has not terminated.

In most scenarios, 100 milliseconds is enough time for the thread to terminate. However, if the CPU is under high stress, the secondary thread may still be running after Odbc32.dll is unloaded, which causes the error.

↑ Back to the top


Resolution

Remove the explicit FreeLibrary call for the DLL that is using Odbc32.dll.

↑ Back to the top


Status

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

↑ Back to the top


More information

Steps to Reproduce Behavior

  1. Create a Win32 DLL named "TestDll" that exports a function named "Function1" that connects to and disconnects from a database using ODBC.
  2. Create a Win32 console application named "Application1" that calls LoadLibrary, Function1, and FreeLibrary of TestDll.
  3. Create another Win32 console application named "Application2" that spawns 50 instances of Application1 in an infinite loop.
  4. After ten or fifteen minutes, the following error message is generated:
    "Application1.EXE - Application Error: The instruction at '0x1f8148d9' referenced memory '0x1f8148d9'. The memory could not be 'read'."

↑ Back to the top


Keywords: KB281735, kbbug

↑ Back to the top

Article Info
Article ID : 281735
Revision : 3
Created on : 5/12/2003
Published on : 5/12/2003
Exists online : False
Views : 395