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

  • Home
  • SEARCH
  • 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 245415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T21:05:13+00:00 2026-05-11T21:05:13+00:00

I have a bug in a multi-processes program. The program receives input and instantly

  • 0

I have a bug in a multi-processes program. The program receives input and instantly produces output, no network involved, and it doesn’t have any time references.
What makes the cause of this bug hard to track down is that it only happens sometimes.

If I constantly run it, it produces both correct and incorrect output, with no discernible order or pattern.

What can cause such non-deterministic behavior? Are there tools out there that can help? There is a possibility that there are uninitialized variables in play. How do I find those?

EDIT: Problem solved, thanks for anyone who suggested
Race Condition.
I didn’t thought of it mainly because I was sure that my design prevents this. The problem was that I’ve used ‘wait’ instead of ‘waitpid’, thus sometimes, when some process was lucky enough to finish before the one I was expecting, the correct order of things went wild.

  • 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-11T21:05:13+00:00Added an answer on May 11, 2026 at 9:05 pm

    The scheduler!

    Basically, when you have multiple processes, they can run in any bizarre order they want. If those processes are sharing a resource that they are both reading and writing from (whether it be a file or memory or an IO device of some sort), ops are going to get interleaved in all sorts of weird orders. As a simple example, suppose you have two threads (they’re threads so they share memory) and they’re both trying to increment a global variable, x.

    y = x + 1;
    x = y
    

    Now run those processes, but interleave the code in this way

    Assume x = 1

    P1:

    y = x + 1
    

    So now in P1, for variable y which is local and on the stack, y = 2. Then the scheduler comes in and starts P2

    P2:

    y = x + 1
    x = y
    

    x was still 1 coming into this, so 1 has been added to it and now x = 2

    Then P1 finishes

    P1:

    x = y
    

    and x is still 2! We incremented x twice but only got that once. And because we don’t know how this is going to happen, it’s referred to as non-deterministic behavior.

    The good news is, you’ve stumbled upon one of the hardest problems in Systems programming as well as the primary battle cry of many of the functional language folks.

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

Sidebar

Ask A Question

Stats

  • Questions 179k
  • Answers 179k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Try adding another id of the links div to the… May 12, 2026 at 3:49 pm
  • Editorial Team
    Editorial Team added an answer Basically you need two parts: 1) Your Nameserver needs to… May 12, 2026 at 3:49 pm
  • Editorial Team
    Editorial Team added an answer that trailing comma would be a parse error - in… May 12, 2026 at 3:49 pm

Related Questions

I work off of a multi-user Windows Server, and the rdpclip bug bites us
Intermittently in our app, we encounter LockTimeoutExceptions being throw from SQL CE. We've recently
I am currently hunting a nasty bug in a multi-threaded environment using FutureTasks and
I am getting email addresses out of the Address Book from a Cocoa Touch

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.