buglwIP - A Lightweight TCP/IP stack - Bugs: bug #35587, Uninitialized pointer

 
 

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

bug #35587: Uninitialized pointer

Submitted by:  Jiri Dobry <jdobry>
Submitted on:  Wed 22 Feb 2012 08:06:13 AM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: Crash ErrorStatus: Invalid
Privacy: PublicAssigned to: None
Open/Closed: ClosedPlanned Release: None
lwIP version: 1.4.0

Wed 22 Feb 2012 10:56:42 AM UTC, comment #3:

Regarding Misra: as stated by mason on lwip-devel, this is true for automatic variables (i.e. local variables) but not for global variables.

Regarding "sw reinit": this is currently not supported by lwIP.

As such, the term "invalid" doesn't mean you don't have a problem. Instead, it means it is not a "bug" meaning we never stated that lwIP would solve the problem you are facing (which seems to be "sw reinit" or a non-standard startup code not clearing global uninitialized variables).

Simon Goldschmidt <goldsimon>
Project Administrator
Wed 22 Feb 2012 10:18:12 AM UTC, comment #2:

Thanks for reaction, but I can't agree that it is invalid.

Why:
- this stack is designed mainly for embeded systems and this world have some different rules. For example MISRA 2004 Rule Number 9.1: "All automatic variables shall have been assigned a value before being used.". This rule have GOOD reason:

- when we use default initializations for variables, we can have problem after sw reinit. In this case it is clear. "next_timeout" pointer is somewhere into lwipheap. First call of lwip_init() is correct, but second try for restart IP stack will fail. Pointer is not initialized and need not point to same segment as is allocated for timmers.

Jiri Dobry <jdobry>
Wed 22 Feb 2012 08:27:15 AM UTC, comment #1:

In C, global uninitialized variables (no matter if 'static' or globally visible), are implcitly initialized to '0' (or 'NULL' for pointer types). This must be done by the startup code before 'main()' is called (e.g., for gcc, the section '.bss' is cleared by looping over the whole section and filling it with zeros).

This is part of the C standard. If it's not working for you, there's a bug in your startup code. This is a common error found in hand-written startup code. Some compilers allow skipping the initialization to save space, but that's not standard conformant.

Closing as invalid.

Simon Goldschmidt <goldsimon>
Project Administrator
Wed 22 Feb 2012 08:06:13 AM UTC, original submission:

File src/core/timers.c contain uninitialized pointer next_timeout. LWIP crash on startup when memory is not initialized to zeroes.

Fix is simple like this:
..........
/** Initialize this module */
void sys_timeouts_init(void)
{
+ next_timeout = NULL;
#if IP_REASSEMBLY
..........

Jiri Dobry <jdobry>

 

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed 22 Feb 2012 08:27:15 AM UTCgoldsimonStatusNone=>Invalid
      Open/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1