Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-81105

Converting self-recursive arrays to string overflows the call stack

    XMLWordPrintable

Details

    • 6dfbbc2a5435d2e9542e9cf2eb039147db0ff29b (qt/qtdeclarative/5.14)

    Description

      JavaScript, in its infinite wisdom, allows us to have arrays that contains themselves. For obvious reasons, trying to convert such an array to a string is not a good idea, but QV4 right now does not handle this case very nicely - in fact, the call stack overflows and the engine crashes.

      let v1 = [];
      v1.push(v1);
      console.log(v1); // Crashes
      

      There is some room for debate as to what the "correct" handling of this case should be (or indeed if this should be specified at all); for example, here is js60:

      js> let v1 = [];
      js> v1.push(v1);
      1
      js> console.log(v1);
      
      js>
      

      Incidentally, Python has a similar construct; it appears to generally use ... to notate the self-referencing members of an array.

      Attachments

        Activity

          People

            fabiankosmale Fabian Kosmale
            hlt Tobias Holl
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: