Announcement

Collapse
No announcement yet.

LoadFunction hangs

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • LoadFunction hangs

    Hello, I have an uLCD-43DT PmmC Rev 1.7 When I call file_Loadfunction with a filename that does not exist, the function hangs. I would expect it to return and then file_Error would return a file not found error. I have also noticed that the mem_Heap function will hang if the heap space gets borked by releasing something twice although I'm not sure there's anything that can be done about that.

  • #2
    Thanks for that.

    until this gets fixed check that the file exists before attempting file_LoadFunction()

    As for the heap problem, have you got a simple example? Out attempts to recreate it have been unsuccessful.
    Mark

    Comment


    • #3
      It happens when loading a function using file_LoadFunction where the loaded function allocates some memory.

      Main flash code:

      Code:
      func main()
      
          var TestFunc;
      
          while(!file_Mount())continue;
      
          print("Loading func\r\n");
          TestFunc := file_LoadFunction("MyFunc.4xe");
          TestFunc();
          
          print("Func returned\r\n");
          mem_Free(TestFunc);
          print("Mem free 1\r\n");
          mem_Heap();
          print("Mem heap 1\r\n");
          mem_Free(TestFunc);
          print("Mem free 2\r\n");
          mem_Heap();
          print("Done");
      
          repeat
          forever
          
      endfunc
      Loaded function code:

      Code:
      func main()
      
          var Globals;
      
          Globals := mem_AllocZ(100);
      
      endfunc
      The main flash code never gets past the second call to 'mem_Heap()'

      Comment


      • #4
        Great, that can be simplified a bit, basically to something like 'a double free on a fragmented heap' (i.e. don't especially need a function to demonstrate).

        If you free Globals before returning from your function (like you should) everything is OK.

        We will get these fixed for the release after R19.

        Mark

        Comment

        Working...
        X