|
From: | Min Xu |
Subject: | [lwip-devel] [bug #34429] In RAW/NO_SYS mode, with LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT set to 1, memory gets corrupted |
Date: | Fri, 30 Sep 2011 01:04:17 +0000 |
User-agent: | Mozilla/5.0 (Windows NT 5.1; rv:7.0) Gecko/20100101 Firefox/7.0 |
Follow-up Comment #3, bug #34429 (project lwip): My change that seem to work: 1: Adding break; after setting local_mem_free_count to 1 if mem_free_count is non-zero. No need to LOAD-STORE if a single STORE instruction suffices 2: Remove the extraneous LWIP_MEM_ALLOC_UNPROTECT() and LWIP_MEM_ALLOC_PROTECT() when mem == lfree .. We don't want another mem_malloc or mem_free to mess up the lfree Section 1: for (ptr = (mem_size_t)((u8_t *)lfree - ram); ptr < MEM_SIZE_ALIGNED - size; ptr = ((struct mem *)(void *)&ram[ptr])->next) { mem = (struct mem *)(void *)&ram[ptr]; #if LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT mem_free_count = 0; LWIP_MEM_ALLOC_UNPROTECT(); /* allow mem_free to run */ LWIP_MEM_ALLOC_PROTECT(); if (mem_free_count != 0) { local_mem_free_count = 1; break; } mem_free_count = 0; #endif /* LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT */ Section 2: if (mem == lfree) { /* Find next free block after mem and update lowest free pointer */ while (lfree->used && lfree != ram_end) { // LWIP_MEM_ALLOC_UNPROTECT(); /* prevent high interrupt latency... */ // LWIP_MEM_ALLOC_PROTECT(); lfree = (struct mem *)(void *)&ram[lfree->next]; } LWIP_ASSERT("mem_malloc: !lfree->used", ((lfree == ram_end) || (!lfree->used))); } _______________________________________________________ Reply to this item at: <http://savannah.nongnu.org/bugs/?34429> _______________________________________________ Message sent via/by Savannah http://savannah.nongnu.org/
[Prev in Thread] | Current Thread | [Next in Thread] |