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 283883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T05:24:40+00:00 2026-05-12T05:24:40+00:00

Not sure what’s going on here. I have an Windows console app written in

  • 0

Not sure what’s going on here.
I have an Windows console app written in C. When I run it from within VS2008, it runs fine. If I run it from the cmd.exe prompt, it crashes, usually in malloc(). I am guessing it is a race condition due to a mismatched CRT library.

The app is simple.
It calls into the WinHttp layer to send a GET request to a website, then slurps up the reply. That part seems to work fine, but after WinHttpReadData, the program calls printf() to print out the data received, and that is where the malloc crash often occurs.

But only outside the debugger.
????

I am compiling from the command line.

c:\vc9\bin\cl.exe /Zi /DEBUG -Ic:\vc9\Include 
             -IC:\WindowsSDK\v6.1\Include  HttpGet.c 
             -link /debug /out:HttpGet.exe /SUBSYSTEM:CONSOLE  /LIBPATH:c:\vc9\Lib
              /LIBPATH:C:\WindowsSDK\v6.1\Lib  WinHttp.lib

I see the results above if I compile with /MT, or nothing. If I compile with /MD, then it hangs when run in the debugger, on a call to free(), and it crashes in cmd.exe (same as with /MT).

run in             result: /MT            result: /MD
---------          ------------           -----------
VS2008 debugger    runs fine              hang in free() (at the end)
cmd.exe            crash in malloc        crash in malloc
"VC cmd prompt"    crash or hang(spin)    ?? 

Some questions –

  1. Is the different behavior because of the PATH available within VS2008?

  2. Could the cause be that I don’t have the VC90 runtime installed on my machine?

  3. I thought that by linking statically (/MT) I wouldn’t have the requirement of needing the VC90 runtime to be installed?

  4. I still don’t understand /NODEFAULTLIB. Is that relevant?

I am used to makefiles and compilers, and I know C. I don’t know C++ which is why I write in C. But I don’t understand all the vagaries of the CRT on Windows. Can someone clear up this mystery?

  • 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-12T05:24:41+00:00Added an answer on May 12, 2026 at 5:24 am

    Typically when I’ve seen something work in the debugger but nowhere else, it’s due to uninitialized memory. The debugger is “nice enough” to clear memory for you, as if that is doing you a favor.

    The second possibility is a buffer overrun, and the debugger is causing the memory location of your mallocs to move around enough to avoid it. I would suspect this one given your failure is showing up during a malloc; you might be corrupting the malloc chain.

    Another possibility that stands out is some sort of race condition, and the debugger is changing the timing enough to let you get away with it.

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

Sidebar

Related Questions

Not sure what's going on here. I have a DateTime object, and when I
Not sure what exactly is going on here, but seems like in .NET 1.1
Not sure what's going on here, but in my Rails 3 application, I type
not sure what i'm missing, but here ti go's: i have a floating left
Not sure what I'm missing here but this code runs without any error message,
Not sure if I've worded my title correctly but here goes. I have a
Not sure if this is possible, but here goes. I have a MongoDB (using
Not sure what is going on. When I perform the following code... it runs
Not sure how to frame this one, so here goes... I have a need
Not sure why but I am not getting anything back from the json call.

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.