buglwIP - A Lightweight TCP/IP stack - Bugs: bug #37158, MEM_USE_POOLS==1: LWIP_ASSERT...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #37158: MEM_USE_POOLS==1: LWIP_ASSERT (rmem == LWIP_MEM_ALIGN(rmem)) fails

Submitter:  Artem Pisarenko <jblackarty>
Submitted:  Tue 21 Aug 2012 01:53:56 PM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  Duplicate
Privacy:  Public Assigned to:  goldsimon
Open/Closed:  Closed Planned Release:  None
lwIP version:  1.4.0

Wed 22 Aug 2012 07:04:47 PM UTC, comment #3: 

This is a duplicate to bug #33545, already fixed shortly after 1.4.0 was released -> already fixed for 1.4.1.

Simon Goldschmidt <goldsimon>
Group administrator
Wed 22 Aug 2012 04:45:54 AM UTC, comment #2: 

Yes, it's line 134 in my sources too. Seems like debugger interpret sources or places breakpoints in some tricky way.

I'm writing my own port from scratch for STM32F2x7 MCU with ARM Cortex-M3 processor. This processor supports unaligned accesses in simple terms (although ARMv7-M Architecture Reference Manual restricts unaligned access in some cases and I'm not sure how gcc compiler workaround these ones).

Anyway it works ok as I said before (I've just configured to debug output asserts). There are no need to remove asserts. 2nd assert doesn't fail, it's ok. But I still didn't tested my port heavily. I've just run standard tcpecho example from contribs until now.

Also I forget to say that I use non-original lwip sources. I modified them a little to temporary solve bug #37148:

diff --git a/lwip/core/memp.c b/lwip/core/memp.c
index 4da879a..d47cb11 100644
--- a/lwip/core/memp.c
+++ b/lwip/core/memp.c
@@ -104,10 +104,8 @@ struct memp {
 #else /* MEMP_OVERFLOW_CHECK */

 /* No sanity checks
- * We don't need to preserve the struct memp while not allocated, so we
- * can save a little space and set MEMP_SIZE to 0.
  */
-#define MEMP_SIZE           0
+#define MEMP_SIZE          LWIP_MEM_ALIGN_SIZE(sizeof(struct memp))
 #define MEMP_ALIGN_SIZE(x) (LWIP_MEM_ALIGN_SIZE(x))

 #endif /* MEMP_OVERFLOW_CHECK */

May be my solution wasn't correct and triggered this issue. But I cannot check without this fix because my lwip port cannot even start without it.

Artem Pisarenko <jblackarty>
Tue 21 Aug 2012 02:39:39 PM UTC, comment #1: 

[Updating the summary to reflect MEM_USE_POOLS==1]

First: the LWIP_ASSERT line you quoted is line 134 in my 1.4.0 sources, not line 137 as the stack trace says.


As alignment is highliy port-dependent, could you tell us what hardware/lwIP-port you are using and what's the native alignment requirement of that hardware?

It seems like your bug report is true, though: for MEM_USE_POOLS==1, mem_malloc() gets an aligned 'element' pointer from memp_malloc() and then increases 'element'. The resulting pointer might not be aligned any more, as the struct memp_malloc_helper only contains one memp_t, which will be an u8_t.

Could you remove the assert from mem.c:134 and see if it works? Especially the 2nd next assert which checks that 'hmem' is alingned should not fire. If so, I'd just remove line 134...

Simon Goldschmidt <goldsimon>
Group administrator
Tue 21 Aug 2012 01:53:56 PM UTC, original submission:  

lwip assertion fails at line:

LWIP_ASSERT("rmem == MEM_ALIGN(rmem)", (rmem == LWIP_MEM_ALIGN(rmem)));

in function mem_free() at mem.c.

It happens each time on tcp activity. But everything works ok (looks like that).

rmem = 0x6400a669
Call stack:

9 mem_free() mem.c:137
8 pbuf_free() pbuf.c:654
7 tcp_send_empty_ack() tcp_out.c:879
6 tcp_output() tcp_out.c:921
5 tcp_input() tcp_in.c:390
4 ip_input() ip.c:505
3 ethernet_input() etharp.c:1282
2 tcpip_thread() tcpip.c:103
1 <symbol is not available>

Initial data:
msg->msg.inp.p = 0x20009cb4
Ethernet driver allocates pbufs for incoming frames in this way:

pbuf_alloc(PBUF_RAW, frame_length + ETH_PAD_SIZE, PBUF_POOL);


lwipopts.h:

...
#define NO_SYS                          0
#define MEM_ALIGNMENT                   4
#define MEM_USE_POOLS                   1
#define MEMP_USE_CUSTOM_POOLS           1
#define MEM_SIZE                        1600
#define MEMP_SANITY_CHECK               1
#define MEMP_SEPARATE_POOLS             1
#define ETH_PAD_SIZE                    2
#define TCP_SND_BUF                (2 * TCP_MSS)
...

lwippools.h:

LWIP_MALLOC_MEMPOOL_START
LWIP_MALLOC_MEMPOOL(80, 64)
LWIP_MALLOC_MEMPOOL(30, 128)
LWIP_MALLOC_MEMPOOL(10, 512)
LWIP_MALLOC_MEMPOOL(5, 2048)
LWIP_MALLOC_MEMPOOL_END
LWIP_MEMPOOL(SYS_SEM, 43, 4, "SYS_SEM")
LWIP_MEMPOOL(SYS_MBOX, 11, 4, "SYS_MBOX")


Artem Pisarenko <jblackarty>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by goldsimon (Posted a comment)
  • -email is unavailable- added by jblackarty (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2012-08-22 goldsimon StatusNeed Info Duplicate
        Open/ClosedOpen Closed
    2012-08-21 goldsimon StatusNone Need Info
        Assigned toNone goldsimon
        SummaryLWIP_ASSERT (rmem == LWIP_MEM_ALIGN(rmem)) fails MEM_USE_POOLS==1: LWIP_ASSERT (rmem == LWIP_MEM_ALIGN(rmem)) fails

    Back to the top

    Powered by Savane 3.13-bb6a.
    Corresponding source code