Navigation

    Fuze Arena Logo
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    • Help
    • Discord

    Crash when using dynamic array structures

    Bug Reporting (FUZE 4 Nintendo Switch)
    3
    6
    500
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • N
      Nisse5 F last edited by

      I was finally able to isolate a crash I had in my larger program related to dynamic arrays.

      NOTE: I have encountered some occasions where the sample code does NOT crash, but running the program from a rebooted FUZE always seem to crash it.

      Here is the full code. The "{1}" in the code preview should just be empty lines, don't know how to remove them...

      struct StructTest
          i = 0
      endstruct
      
      struct StructArrayHolder
         int count = 0
         StructTest arr = []  // Crashes with arr = [], but not with f.e. arr[5]
      endstruct
      
      StructArrayHolder FullArray[8]
      
      function AddRecord(val)
         curridx = FullArray[0].count 
         StructTest n  // Local StructTest n will crash, global will not
         n.i = val
         FullArray[0].arr[curridx] = n
         FullArray[0].count += 1
      return void
      
      AddRecord(10)
      AddRecord(50)
      
      test = FullArray[0].arr[0]
      print(test) // Crash
      
      loop
          update()
      repeat
      
      mixaal 1 Reply Last reply Reply Quote 1
      • mixaal
        mixaal F @Nisse5 last edited by mixaal

        @Nisse5 Interesting, to be honest I don't know the F4NS language dialect properly yet :) and guessing on behavior from my knowledge from other languages. E.g. In golang you'd have to do something like

        FullArray[0] = new StructArrayHolder()
        

        before accessing the elements - this would allocate the memory at index 0 of FullArray.

        In F4NS I made this little change to your code:

        function AddRecord(val)
          currIdx = FullArray[0].count // should be 0
        
        // guessing that this will call malloc() or some custom version of allocation
          FullArray[0].arr[currIdx] = [ .i = val ] 
          FullArray[0].count += 1
        return void
        
        1 Reply Last reply Reply Quote 0
        • mixaal
          mixaal F last edited by

          I shared this program just a sec ago.

          N 1 Reply Last reply Reply Quote 1
          • N
            Nisse5 F @mixaal last edited by

            @mixaal Thanks a lot!

            1 Reply Last reply Reply Quote 0
            • N
              Nisse5 F last edited by

              @Kaiser said in Crash when using dynamic array structures:

              I also don't know how to fix that problem, but one of the FUZE team members has asked for Errors in the game, so why don't you ask there for help or to fix that error?

              It crashes FUZE. FUZE shouldn't crash. This is a bug.

              1 Reply Last reply Reply Quote 0
              • Martin
                Martin Fuze Team last edited by

                Just to say this thread isn't being ignored! Thanks for reporting.

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post