AdditionAgentRAM - an unused piece of memory? - page 3 - General Discussion and Assistance - CHDK Forum

AdditionAgentRAM - an unused piece of memory?

  • 32 Replies
  • 19859 Views
*

Offline reyalp

  • ******
  • 14126
Re: AdditionAgentRAM - an unused piece of memory?
« Reply #20 on: 10 / November / 2013, 14:50:10 »
Advertisements
Updated patch adds OPT_ARAM_TESTING for checking if the AgentRAM block is actually unused by the Canon firmware (works like OPT_EXMEM_TESTING).
From further investigation on elph130, it appears that the problem is not the aram getting corrupted. OPT_ARAM_TESTING doesn't show any problems.

From the romlog, it looks like the firmware free is somehow being passed an aram pointer. The call is from free(logo); in gui.c init_splash().

I don't really see how this can happen, or how it would happen on elph130 but not d10. I'll try to look into it some more today. Probably missing something obvious  :-[

A lightly annotated romlog is attached.
Don't forget what the H stands for.

*

Offline srsa_4c

  • ******
  • 4451
Re: AdditionAgentRAM - an unused piece of memory?
« Reply #21 on: 10 / November / 2013, 15:55:11 »
The call is from free(logo); in gui.c init_splash().
The logo file is available (stat), but can't be (f)opened, and free() ends up causing an exception? People testing the a2500 port report quite a few weird things, maybe some of those are related?
For example, what about the struct used by the firmware's stat()? It can trash the stack if it has changed in this DryOS revision.
« Last Edit: 10 / November / 2013, 16:02:44 by srsa_4c »

*

Offline reyalp

  • ******
  • 14126
Re: AdditionAgentRAM - an unused piece of memory?
« Reply #22 on: 10 / November / 2013, 16:09:10 »
The call is from free(logo); in gui.c init_splash().
The logo file is available (stat), but can't be (f)opened, and free() ends up causing an exception? People testing the a2500 port report quite a few weird things, maybe some of those are related?
The logo displays, I think the crash happens when it is done.
Quote
For example, what about the struct used by the firmware's stat()? It can trash the stack if it has changed in this DryOS revision.
Good point.

edit:
It appears that aram_heap becomes null ???

edit:
I've confirmed this. It also seems to be sensitive to layout of the wrappers.c code, some debug code I added to aram_malloc made it stop happening. This could be a bug in the elph130 port, or it may be a generic bug that only happens to hit the right address on this port in my build.

It happens somewhere between tick 980 and tick 1070 (varies slightly between runs). This is very close to the time zebra.flt was loaded.

edit: zebra appears to be coincidence, still happens with zebra disabled
« Last Edit: 10 / November / 2013, 19:52:41 by reyalp »
Don't forget what the H stands for.

*

Offline reyalp

  • ******
  • 14126
Re: AdditionAgentRAM - an unused piece of memory?
« Reply #23 on: 10 / November / 2013, 21:34:31 »
OK, I found the elph130 issue. Not related to to agentram, possibly due to new dryos version. I'll make another post for that.

edit: http://chdk.setepontos.com/index.php?topic=10910.0
« Last Edit: 10 / November / 2013, 22:17:23 by reyalp »
Don't forget what the H stands for.

*

Offline reyalp

  • ******
  • 14126
Re: AdditionAgentRAM - an unused piece of memory?
« Reply #24 on: 10 / November / 2013, 23:01:13 »
Attached patch for luascript.c adds an "aram" to lua get_meminfo. This behaves like exmem, return false if aram not in use.

I'm still not sure what the default should be.
Don't forget what the H stands for.

Re: AdditionAgentRAM - an unused piece of memory?
« Reply #25 on: 11 / November / 2013, 00:26:52 »
Attached patch for luascript.c adds an "aram" to lua get_meminfo. This behaves like exmem, return false if aram not in use.
Hmm .. made the patch and then modified my memtest.lua script to :
Code: [Select]
--[[ Mem Space Test
--]]
function comma_value(amount)
  local formatted = amount
  while true do 
    formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
    if (k==0) then
      break
    end
  end
  return formatted
end
mem = get_meminfo("system")
print("mem  : ".. comma_value(mem.free_size).."  "..comma_value(mem.free_block_max_size)  )
xmem = get_meminfo("exmem")
if( xmem ~= false ) then print("exmem: ".. comma_value(xmem.free_size).."  ".. comma_value(xmem.free_block_max_size) ) end
aram = get_meminfo("aram")
if( aram ~= false ) then print("aram: ".. comma_value(aram.free_size).."  ".. comma_value(aram.free_block_max_size) ) end
 

and the results look like :


mem   : 281,312     275,795
aram: 72 40


Not quite what I expected,  but its late now so who knows ?
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline philmoz

  • *****
  • 3450
    • Photos
Re: AdditionAgentRAM - an unused piece of memory?
« Reply #26 on: 15 / November / 2013, 17:42:51 »
New patch:
- moved memory management code to a new file in core so it compiles as thumb
- re-factored common code into separate functions

Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)

*

Offline philmoz

  • *****
  • 3450
    • Photos
Re: AdditionAgentRAM - an unused piece of memory?
« Reply #27 on: 16 / November / 2013, 20:37:15 »
Added to trunk in revision 3230.

Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)

*

Offline msl

  • *****
  • 1280
  • A720 IS, SX220 HS 1.01a
    • CHDK-DE links
Re: AdditionAgentRAM - an unused piece of memory?
« Reply #28 on: 17 / November / 2013, 05:29:00 »
AdditionAgentRAM also enabled on the SX220 (revision 3231).

msl
CHDK-DE:  CHDK-DE links

*

Offline reyalp

  • ******
  • 14126
Re: AdditionAgentRAM - an unused piece of memory?
« Reply #29 on: 24 / November / 2013, 21:00:43 »
In trunk changeset 3248 I've added a "combined" option to lua get_meminfo, and made it the default when no heap name is given.

"combined" sets free_block_max_size to the largest single free block in any of the pools, and sets most of the other sizes to totals over all of the enabled heaps. start_adress and end_address are not included, since they don't make sense.

I also changed the chdk_malloc field to be true for all heaps, since the current code will allocate from any heap.

Note that currently the suba code doesn't return allocated_count, and the allocated_size and allocated_peak aren't equivalent to the canon values. I intend to fix some of this later. In dryos, allocated_size appears to be the total amount allocated, including overhead. The suba values seem to increment with each allocation, but don't ever decrease.
Don't forget what the H stands for.

 

Related Topics


SimplePortal © 2008-2014, SimplePortal