3

Got a weird bug today...

A new feature I just implemented works but outputs nothing.
So I start printing its inputs early in the code, fine no problem here. Then I print out the supposed results a little bit later, fine too. But now the full program work perfectly.
I find out that if I remove one of those two prints then suddenly my function start outputing empty arrays! WTF?

I think I find a quantum bug, you can observe the bug or the internal values but not both!

Comments
  • 0
    Timing messed up?
  • 0
    I remember some time ago working with delphi (definetly not an expert) and the IDE was amazingly broken. Jus try to compile and it give you an error on X line...

    - "hmmm but this was fine a minute ago..."

    Hit compile again, other error on other line...

    - "I swear I didn't touch this"

    Hit compile a few times, same random errors...

    - "WtF man!?

    Hit again... and everithing was ok.

    Like I said, not an expert on delphi, but that happened a lot, weird...
  • 2
    To conclude this, in the end it seems to be a tricky shared vars and local scopes problem.

    I have 2 thread, one writing an array the second reading it.

    What seems to be happening is that without the prints, each thread have it's own var (just pointing to the same array at first) and when the writer thread change it it doesn't affect the other.

    But with the prints python compiler correctly interpret both as the same variable.
  • 1
    @Kasonnara
    So it was a race condition.
  • 0
    @joas Not really there is no timing issue. Always the same result. Python makes atomic assignments.

    The problem was that when the writing thread create a new array and affect a pointer to it in the variable, it only changes its own variable. The other thread keeps the pointer of the initial array and thus isn't affected.

    But strangely with the prints it correctly affect the new array in the other thread variable.
Add Comment