Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Bug Passing a negative array length to the schedule method of a job doesn't throw an error

Discussion in 'Entity Component System' started by JakHussain, Aug 13, 2020.

  1. JakHussain

    JakHussain

    Joined:
    Oct 20, 2016
    Posts:
    318
    I'm quite embarrassed that I've done this to myself but equally surprised that I can tell a job to run with a negative array length which effectively makes it not run at all.

    I want to submit a bug report but I first want to hear if this is by design or if there's any justification to this? I can't imagine I'm the first idiot to accidentally pass a negative number as the array length argument in the years that the job system has been production ready.

    I can't imagine a reason why 0 or less should be allowed as valid input.
     
  2. Nyanpas

    Nyanpas

    Joined:
    Dec 29, 2016
    Posts:
    406
    I am sorry but...
    math.abs(length)
    :oops:
     
  3. JakHussain

    JakHussain

    Joined:
    Oct 20, 2016
    Posts:
    318
    yeah. i get that. my point is that 0 or less should be an invalid argument.
     
    Nyanpas likes this.
  4. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    3,983
    0 is a perfectly valid array size and should not throw an error. If I use ToComponentDataArray on an empty EntityQuery and then schedule a parallel job based on that, I don't want errors. I just want the job to early out. This is an oversimplified example use case, but I can assure you there are real-world use cases where this is important.

    Negative numbers is a different matter.
     
    JakHussain, Nyanpas and tertle like this.