buglwIP - A Lightweight TCP/IP stack - Bugs: bug #64685, snmp traps build failure (dangling...

 
 

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

bug #64685: snmp traps build failure (dangling pointer)

Submitter:  Erik Ekman <yarrick>
Submitted:  Sun 17 Sep 2023 09:42:22 AM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open Planned Release:  None
lwIP version:  2.1.3

Sun 28 Apr 2024 01:20:49 AM UTC, comment #3: 

As a work around, I couldn't find out how to pass the details on the command line, but found I could get the build working by ignoring that specific warning.

In `contrib/ports/CMakeCommon.cmake`

Add:
    -Wno-error=dangling-pointer

After that, the warning is still there, but at least it compiles.


Additional note:

Also, in the BUILDING instructions, for "Working example" the instructions are slightly out of order -- I found you need to copy the `lwipcfg.h` file before running the commands.

Sly Gryphon <sgryphon>
Fri 26 Apr 2024 12:18:23 AM UTC, comment #2: 

I am just trying the basic example build, from the docs and getting this same error:

```sh
mkdir build
cd build
cmake ..
cmake --build .
```

Error:

```txt
/home/sly/Code/lwip/src/apps/snmp/snmp_traps.c:401:24: error: storing the address of local variable ‘snmp_v2_special_varbinds’ in ‘*varbinds.prev’ [-Werror=dangling-pointer=]
  401 |         varbinds->prev = &snmp_v2_special_varbinds[1];

```

So the question is, how do you use the app if it can't even build?  Surely there must be a way to build it, otherwise it is useless (how do you do releases).

Do we need to pass in a flag to ignore the warning or something?

(Or I did read some comments about the latest GCC now being stricter at checking this error, so maybe it didn't happen with earlier compilers. I am using GCC version 13.2.0)

Sly Gryphon <sgryphon>
Tue 10 Oct 2023 06:20:23 PM UTC, comment #1: 

You're right that it is storing the address of a variable on stack, but I don't think you're right that it is broken: as I see it the variable (although referenced by address) is only used during its lifetime, i.e. mainly for snmp_send_msg() and restored before the function is exited.

The code as it is should not have a real problem. I'm still open to change it to get rid of the warning you see, if you have any suggestion.

Simon Goldschmidt <goldsimon>
Group administrator
Sun 17 Sep 2023 09:42:22 AM UTC, original submission:  

When trying to build the fuzzer, I got this failure. Seems like it correctly detected where a pointer is given the address of a struct from the stack.

This has likely been broken since being added in patch #15072 in 2018.

../../src/apps/snmp/snmp_traps.c: In function ‘snmp_send_trap_or_notification_or_inform_generic’:
../../src/apps/snmp/snmp_traps.c:401:24: error: storing the address of local variable ‘snmp_v2_special_varbinds’ in ‘*varbinds.prev’ [-Werror=dangling-pointer=]
  401 |         varbinds->prev = &snmp_v2_special_varbinds[1];
      |         ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../src/apps/snmp/snmp_traps.c:356:23: note: ‘snmp_v2_special_varbinds’ declared here
  356 |   struct snmp_varbind snmp_v2_special_varbinds[] = {
      |                       ^~~~~~~~~~~~~~~~~~~~~~~~
../../src/apps/snmp/snmp_traps.c:347:176: note: ‘varbinds’ declared here
  347 | snmp_send_trap_or_notification_or_inform_generic(struct snmp_msg_trap *trap_msg, const struct snmp_obj_id *eoid, s32_t generic_trap, s32_t specific_trap, struct snmp_varbind *varbinds)
      |                                                                                                                                                           ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
cc1: all warnings being treated as errors

Erik Ekman <yarrick>
Group Member

 

(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 sgryphon (Posted a comment)
  • -email is unavailable- added by goldsimon (Posted a comment)
  • -email is unavailable- added by yarrick (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.

     

    No changes have been made to this item

    Back to the top

    Powered by Savane 3.13-caa5.
    Corresponding source code