Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6909145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:39:09+00:00 2026-05-27T08:39:09+00:00

I SEEM to be having an issue with GlobalLock in my application. I say

  • 0

I SEEM to be having an issue with GlobalLock in my application. I say seem because I haven’t been able to witness the issue by stepping through yet but when I let it run it breaks in one of two locations.

The app has multiple threads (say 2) simultaneously reading and writing bitmaps from PDF files. each thread handles a different file.

The first location it breaks I am reading a dib from the pdf to be OCRed. OCR is reading the characters on the bitmap and turning them into string data. The second location is when a new PDF is being created with the string data being added over the bitmap.

GlobalLock is being used on a HANDLE created by the following:

GlobalAlloc(GMEM_MOVEABLE, uBytes);

I either get an AccessViolationError (always in the first instance) or I get GlobalLock returning a NULL pointer. (The second occurance)

It seems like one file is being read and another is having a copy written at the same time. There seems to be no pattern to which files it happens on.

Now I understand that the VC++ runtime has been multithreaded since 2005 (I am using VS2010 with 2008 toolchain). But is GlobalLock part of the runtime? It seems to me more like a platform independent thing.

I want to avoid just putting a CRITICAL_SECTION around globallock and globalunlock to get them to work, or at least not know why I am doing so.

Can anyone inform me better about GlobalLock/Unlock?
-A fish out of water

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T08:39:09+00:00Added an answer on May 27, 2026 at 8:39 am

    First, the Global* heap routines are provided for compatibility with 16-bit windows. They still work, but there’s no real reason to use them anymore, except for compatibility with routines that still use global heap object handles. Note that GlobalLock/GlobalUnlock are not threading locks – they prevent the memory from moving, but multiple threads can GlobalLock the same object at the same time.

    That said, they are otherwise thread-safe; they take a heap lock internally, so there is no need to wrap your own locking around every Global* call. If you are having problems like this, it suggests you may be trying to GlobalLock a freed object, or you may be corrupting the heap (heap overflows, use-after-free, etc). You may also be missing thread synchronization on the contents of the heap object – the Global* API does not prevent multiple threads from accessing or modifying the same object at once.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This may seem like a silly question, but we are having an issue debugging
I seem to be having an issue, the application we're using uses a Ninject
I am having an issue with this message. It doesn't seem to be able
I have been having this issue for a while now and I cannot seem
Might seem like a stupid question, but I'm having an issue creating an array
I am having an issue that I can't seem to figure out. Hopefully somebody
I am having an xslt issue that I cannot seem to solve. Right now
I am having a strange issue that I can't seem to resolve. Here is
I seem to be having trouble with my code. I need to say: if
I seem to be having an issue with PHP rounding (sort of) numbers by

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.