Redlib malloc()/free()

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Redlib malloc()/free()

1,124 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by causticphoton on Sat Aug 14 22:18:54 MST 2010
Trying to port the NicheLite TCP/IP stack from NXP on LPCXpresso.

Think I have things figured out for the most part, but when I use malloc(), and free(), the heap pointer keeps increasing, until it blows away my stack. free() is not freeing memory, or malloc() is not seeing the memory free'd.

Is free() broken in redlib?



NOTE: you can see below that the printf routines included with NicheLite use malloc as an intermediate buffer. The npalloc() calls keep increasing the pointer that I get back from npalloc() even though npfree() is being called.




mbed LPC1768 Startup... (Aug 14 2010   22:31:09)
usr_stack = 10005FF0, __get_MSP() = 10007FA8, tk_getsp() = 10007FA8
npalloc(): ptr = 10001C0C, size = 40
sp = 10007F98, st_base = 10005FA8, heap at = 10001C40
tk->tk_guard = [10005FA8] 53544143
npalloc(): ptr = 10001C50, size = 40
npalloc(): ptr = 10001C84, size = 256
TASK clock tick: tk->tk_fp = 10001D4C, tk->tk_stack = 10001C84, tk->tk_size = 256
sp = 10001D48, *sp = 00000000
npalloc(): ptr = 10001D90, size = 40
npalloc(): ptr = 10001DC4, size = 1024
TASK debug Task1: tk->tk_fp = 1000218C, tk->tk_stack = 10001DC4, tk->tk_size = 1024
sp = 10002188, *sp = 00000000
npalloc(): ptr = 100021D0, size = 40
npalloc(): ptr = 10002204, size = 1024
TASK debug Task2: tk->tk_fp = 100025CC, tk->tk_stack = 10002204, tk->tk_size = 1024
sp = 100025C8, *sp = 00000000
npalloc(): ptr = 10002610, size = 40
npalloc(): ptr = 10002644, size = 1024
TASK debug Task3: tk->tk_fp = 10002A0C, tk->tk_stack = 10002644, tk->tk_size = 1024
sp = 10002A08, *sp = 00000000
npalloc(): ptr = 10002A50, size = 40
npalloc(): ptr = 10002A84, size = 1024
TASK debug Task4: tk->tk_fp = 10002E4C, tk->tk_stack = 10002A84, tk->tk_size = 1024
sp = 10002E48, *sp = 00000000
npalloc(): ptr = 10002E90, size = 40
npalloc(): ptr = 10002EC4, size = 1024
TASK web server: tk->tk_fp = 1000328C, tk->tk_stack = 10002EC4, tk->tk_size = 1024
sp = 10003288, *sp = 00000000
npalloc(): ptr = 100032D0, size = 40
npalloc(): ptr = 10003304, size = 1024
TASK console: tk->tk_fp = 100036CC, tk->tk_stack = 10003304, tk->tk_size = 1024
sp = 100036C8, *sp = 00000000
npalloc(): ptr = 10003710, size = 128
npalloc(): ptr = 1000379C, size = 132

INET> ?
SNMP Station: general commands:
   help     - help with menus
   state    - show current station setup
   delay    - set milliseconds to wait between pings
   host     - set default active IP host
   length   - set default ping packet length
   quit     - quit station program
   ping     - send a ping
   setip    - set interface IP address
   version  - display version information
   !command - pass command to OS shell
npalloc(): ptr = 1000382C, size = 156
Also try 'help [npfree(): ptr = 1000382C
npalloc(): ptr = 100038D4, size = 156
generalnpfree(): ptr = 100038D4
npalloc(): ptr = 1000397C, size = 156
|npfree(): ptr = 1000397C
npalloc(): ptr = 10003A24, size = 156
diagnosticnpfree(): ptr = 10003A24
npalloc(): ptr = 10003ACC, size = 156
|npfree(): ptr = 10003ACC
npalloc(): ptr = 10003B74, size = 156
zzznpfree(): ptr = 10003B74
npalloc(): ptr = 10003C1C, size = 156
]'
npfree(): ptr = 10003C1C
npalloc(): ptr = 10003CC4, size = 156

npfree(): ptr = 10003CC4
INET> ?
SNMP Station: general commands:
   help     - help with menus
   state    - show current station setup
   delay    - set milliseconds to wait between pings
   host     - set default active IP host
   length   - set default ping packet length
   quit     - quit station program
   ping     - send a ping
   setip    - set interface IP address
   version  - display version information
   !command - pass command to OS shell
npalloc(): ptr = 10003D6C, size = 156
Also try 'help [npfree(): ptr = 10003D6C
npalloc(): ptr = 10003E14, size = 156
generalnpfree(): ptr = 10003E14
npalloc(): ptr = 10003EBC, size = 156
|npfree(): ptr = 10003EBC
npalloc(): ptr = 10003F64, size = 156
diagnosticnpfree(): ptr = 10003F64
npalloc(): ptr = 1000400C, size = 156
|npfree(): ptr = 1000400C
npalloc(): ptr = 100040B4, size = 156
zzznpfree(): ptr = 100040B4
npalloc(): ptr = 1000415C, size = 156
]'
npfree(): ptr = 1000415C
npalloc(): ptr = 10004204, size = 156

npfree(): ptr = 10004204
INET> ?
SNMP Station: general commands:
   help     - help with menus
   state    - show current station setup
   delay    - set milliseconds to wait between pings
   host     - set default active IP host
   length   - set default ping packet length
   quit     - quit station program
   ping     - send a ping
   setip    - set interface IP address
   version  - display version information
   !command - pass command to OS shell
npalloc(): ptr = 100042AC, size = 156
Also try 'help [npfree(): ptr = 100042AC
npalloc(): ptr = 10004354, size = 156
generalnpfree(): ptr = 10004354
npalloc(): ptr = 100043FC, size = 156
|npfree(): ptr = 100043FC
npalloc(): ptr = 100044A4, size = 156
diagnosticnpfree(): ptr = 100044A4
npalloc(): ptr = 1000454C, size = 156
|npfree(): ptr = 1000454C
npalloc(): ptr = 100045F4, size = 156
zzznpfree(): ptr = 100045F4
npalloc(): ptr = 1000469C, size = 156
]'
npfree(): ptr = 1000469C
npalloc(): ptr = 10004744, size = 156

npfree(): ptr = 10004744
INET> ?
SNMP Station: general commands:
   help     - help with menus
   state    - show current station setup
   delay    - set milliseconds to wait between pings
   host     - set default active IP host
   length   - set default ping packet length
   quit     - quit station program
   ping     - send a ping
   setip    - set interface IP address
   version  - display version information
   !command - pass command to OS shell
npalloc(): ptr = 100047EC, size = 156
Also try 'help [npfree(): ptr = 100047EC
npalloc(): ptr = 10004894, size = 156
generalnpfree(): ptr = 10004894
npalloc(): ptr = 1000493C, size = 156
|npfree(): ptr = 1000493C
npalloc(): ptr = 100049E4, size = 156
diagnosticnpfree(): ptr = 100049E4
npalloc(): ptr = 10004A8C, size = 156
|npfree(): ptr = 10004A8C
npalloc(): ptr = 10004B34, size = 156
zzznpfree(): ptr = 10004B34
npalloc(): ptr = 10004BDC, size = 156
]'
npfree(): ptr = 10004BDC
npalloc(): ptr = 10004C84, size = 156

npfree(): ptr = 10004C84
INET> ?
SNMP Station: general commands:
   help     - help with menus
   state    - show current station setup
   delay    - set milliseconds to wait between pings
   host     - set default active IP host
   length   - set default ping packet length
   quit     - quit station program
   ping     - send a ping
   setip    - set interface IP address
   version  - display version information
   !command - pass command to OS shell
npalloc(): ptr = 10004D2C, size = 156
Also try 'help [npfree(): ptr = 10004D2C
npalloc(): ptr = 10004DD4, size = 156
generalnpfree(): ptr = 10004DD4
npalloc(): ptr = 10004E7C, size = 156
|npfree(): ptr = 10004E7C
npalloc(): ptr = 10004F24, size = 156
diagnosticnpfree(): ptr = 10004F24
npalloc(): ptr = 10004FCC, size = 156
|npfree(): ptr = 10004FCC
npalloc(): ptr = 10005074, size = 156
zzznpfree(): ptr = 10005074
npalloc(): ptr = 1000511C, size = 156
]'
npfree(): ptr = 1000511C
npalloc(): ptr = 100051C4, size = 156

npfree(): ptr = 100051C4
INET> 

Original Attachment has been moved to: 1100602_LPCLinkDiagnostics.txt.zip

0 项奖励
回复
2 回复数

938 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by MotoCon on Sun Dec 19 11:19:42 MST 2010
CausticPhoton,

Did you get this working?  I am trying to do the same thing.  What processor are you targeting?
0 项奖励
回复

938 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CodeRedSupport on Sun Aug 15 01:45:01 MST 2010
There were some issues with the reuse of free'ed memory in Redlib which have been fixed in LPCXpresso v3.4.6:

http://knowledgebase.nxp.com/showthread.php?t=598

Regards,
CodeRedSupport
0 项奖励
回复