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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:38:51+00:00 2026-05-15T20:38:51+00:00

It seems I figured out most of my problems by simply multi-threading my application!

  • 0

It seems I figured out most of my problems by simply multi-threading my application! However, I am running into a little bit of an error: “Stack around variable ‘x’ was corrupted.” It works properly (after hitting abort on the Debug Error), but obviously I cannot have an error everytime someone runs the application. So here is the relevant code. It is the callback to one of my worker threads.

DWORD WINAPI Arc_writePipe(LPVOID threadParam)
{
    Arc_Redirect ar;
    DWORD dwWrote;
    CHAR chBuf[BUFSIZE];
    HANDLE hPipe = (HANDLE)threadParam;
    HWND g1   = FindWindow("GUI",NULL);
    HWND dlg  = GetDlgItem(g1,IDO_WORLDOUT);
    //int nLength = GetWindowTextLength(GetDlgItem(g1,IDO_WORLDINPUT));

    while(bRunThread)
    {
        if(GetDlgItemText(g1,IDO_WORLDINPUT,chBuf,BUFSIZE))
        {
            chBuf[BUFSIZE] = '\0';
            if(!WriteFile(hPipe,chBuf,BUFSIZE,&dwWrote,NULL))
            {
                //SetDlgItemText(g1,IDO_WORLDINPUT,NULL); // This is to reset text when done sending to input
                if(GetLastError() == ERROR_NO_DATA)
                    break; // Normal :)
                else
                    MessageBox(g1,"Error: Could not WriteFile();","Error",MB_ICONERROR);
            }
        }
    }
    return 1;
}

Does anyone have any ideas on why this error keeps occurring? I am not getting any GetLastError() output other than “ERROR_NO_DATA,” after the data is written so I am assuming it has something to do with my WriteFile(); function in conjunction with the BUFSIZE (defined at 0x1000). So basically, I am doing something wrong. Does anyone know perhaps a better way to get information from an edit dialog and write it to a pipe?

Thanks so much for your help!

Regards,
Dennis M.

  • 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-15T20:38:52+00:00Added an answer on May 15, 2026 at 8:38 pm

    I don’t know where the corruption is happening, so I don’t know what exactly the problem is. However, the following line is wrong:

    chBuf[BUFSIZE] = '\0';
    

    You declared chBuf with the size BUFSIZE which means that the index BUFSIZE is actually outside of the array. This will result in stack corruption. What you really need to do is chBuf[BUFSIZE - 1] = '\0';

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

Sidebar

Related Questions

This sure seems like a simple error to fix. However, I somehow can't figure
It seems like the most simplistic things are hard to figure out sometimes... Many
Has anyone figured out how the Very Sleepy profiler finds PDB files? It seems
It seems obvious that some people have been able to figure out how to
I am new to Python and I haven't figured out a simple way of
I can't seem to figure out a good way to do this, but it
I can't seem to figure out how to set the default database in Sql
I can't seem to figure out what I am doing wrong here. I publish
I am getting very frustrated because I cannot seem to figure out why Collections
Can anyone explain how compilation works? I can't seem to figure out how compilation

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.