Search Unity

[Not a real problem] Weird problem inside IJob

Discussion in 'Entity Component System' started by georgeq, Mar 6, 2019.

  1. georgeq

    georgeq

    Joined:
    Mar 5, 2014
    Posts:
    662
    I'm having a hard time debugging a piece of code inside a job. The problem is that even when the job's logic is correct, sometimes a block of instructions is being executed when it shouldn't or not executed when it should. As you can see in the image below, the break point can only be hit when the if is true, however it was hit when all the values involved cause the expression to be false, and in fact in the watch window the expression reports false. So?... why this block of code was executed? My first thought was that it could be due some imprecision on the floating point values, but I discarded that idea after analyzing the source of those values: First: The 1001002 come from a hard coded constant. Second: the process that generates the values for min (which is then copied to furthest), generated the zeros from a hard coded constant too. Third, the values contained and max and best, come form exactly the same source object and data. Knowing this facts I cannot attribute this misbehavior to some floating point imprecision, and the only other possibility I can think of is some threading issue.

    debug.jpg
     
    Last edited: Mar 6, 2019
  2. GilCat

    GilCat

    Joined:
    Sep 21, 2013
    Posts:
    676
    Is it a Parallel job?
     
  3. georgeq

    georgeq

    Joined:
    Mar 5, 2014
    Posts:
    662
    Is not a IJobParallelFor is that's what you ask, is just a plain IJob.
     
  4. georgeq

    georgeq

    Joined:
    Mar 5, 2014
    Posts:
    662
    Confirmed... this is NOT a floating point issue:

    debug2.png

    Same problem with integers!
     
  5. dzamani

    dzamani

    Joined:
    Feb 25, 2014
    Posts:
    122
    You have a breakpoint after furthest, best and speed have been updated so your expression is also updated. Could you put it on the line 598 instead and send your screenshots again ?
     
  6. georgeq

    georgeq

    Joined:
    Mar 5, 2014
    Posts:
    662
    Ah.... you are so right... so I guess I haven't sleep well enough.
     
    dzamani likes this.