Magic Lantern Forum

Developing Magic Lantern => General Development => Topic started by: dfort on February 14, 2017, 08:15:35 PM

Title: 5D3.134 Stubs API test errors
Post by: dfort on February 14, 2017, 08:15:35 PM
Hope I'm not overstaying my welcome here but this seems like this is so close. I've been running the Stubs API test and consistently getting 200 errors, but they are all the same error.

[FAIL] ABS((m0-m1) - 50*1024) => 0xc800

It seems to be happening in this selftest function:

static void stub_test_malloc_n_allocmem()
{
    // mallocs
    // bypass the memory backend and use low-level calls only for these tests
    // run this test 200 times to check for memory leaks


It maybe pointing to a problem with the memory allocation stubs but I triple checked them against the 123 and the 113 disassemblies and they seem fine, they also pass the check-stubs.py test.

Any idea where the problem might be at?
Title: Re: 5D3.134 Stubs API test errors
Post by: a1ex on February 14, 2017, 08:29:55 PM
That section of the test allocates 50K, then frees it, then repeats 200 times. During this process, it checks the amount of available memory, as reported by Canon code.

The error message indicates that m0 = m1 (before and after _malloc). Therefore, either _malloc is not working properly (unlikely, since it passes the previous tests, so it probably returned a valid value) or the amount of free memory is not reported correctly (GetFreeMemForMalloc -> MALLOC_FREE_MEMORY in consts.h).
Title: Re: 5D3.134 Stubs API test errors
Post by: dfort on February 14, 2017, 09:08:46 PM
Well at least I've been searching in the right area though not really knowing what I'm searching for.

// see "Malloc Information"
#define MALLOC_STRUCT 0x3c268
#define MALLOC_FREE_MEMORY (MEM(MALLOC_STRUCT + 8) - MEM(MALLOC_STRUCT + 0x1C)) // "Total Size" - "Allocated Size"


Changing MALLOC_STRUCT from the 123 to the 113 values solved an issue with "Failed to allocate BVRAM mirror" errors so I guess that was a lucky guess though it didn't do anything for the fail errors in the Stubs API test. I've been looking at the "Malloc Information" in all three firmware versions and it seems that 134 is more like 113 than 123 in that area. However, MALLOC_FREE_MEMORY is the same in both 113 and 123 in consts.h and not knowing how to find the values for MALLOC_STRUCT I am once again lost in the woods.

So the constants have moved? Reminds me of that old joke, "The only thing constant is change."

I'm running some of the other tests in the selftest module and the camera seems to be doing quite nicely with 1.3.4.
Title: Re: 5D3.134 Stubs API test errors
Post by: dfort on February 14, 2017, 10:44:18 PM
Problem solved. @chris_overseas pointed me to his 5D3-133 branch so I tried his MALLOC_STRUCT address and the Stubs API test passed without any fails. Now I know this isn't the "right" way to do it but it is working. I need to make another pass, especially on consts.h before posting the pull request.
Title: Re: 5D3.134 Stubs API test errors
Post by: RenatoPhoto on February 15, 2017, 03:06:03 AM
Bravo!!!

(https://media.giphy.com/media/M0cWmMOAdn9Ek/giphy.gif)
Title: Re: 5D3.134 Stubs API test errors
Post by: DeafEyeJedi on February 15, 2017, 03:28:11 AM
(http://media.giphy.com/media/3otPotypHZ3Wev76Rq/giphy.gif)