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

Submitter:  Jiri Dobry <jdobry>
Submitted:  Wed 22 Feb 2012 08:06:13 AM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  Crash Error Status:  Invalid
Privacy:  Public Assigned to:  None
Open/Closed:  Closed Planned 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>
Group 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>
Group 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>

 

(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 jdobry (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 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2012-02-22 goldsimon StatusNone Invalid
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-caa5.
    Corresponding source code