tbarbette / fastclick

FastClick - A faster version of the Click Modular Router featuring batching, advanced multi-processing and improved Netmap and DPDK support (ANCS'15). Check the metron branch for Metron specificities (NSDI'18). PacketMill modifications (ASPLOS'21) as well as MiddleClick(ToN, 2021) are merged in main.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Memory corruption with Token Buckets in a custom click element

caltom26 opened this issue · comments

Hi!

I'm creating my own element in Click and I'm wanting to use a TokenBucket. I have defined the token bucket in my header file by including the following:

#include <click/tokenbucket.hh>

I declared the Token bucket as follows:

TokenBucket tb;

As soon as these two lines are added to the element I get the following error when loading my router config:

*** Error in `click': malloc(): memory corruption: 0x0000000002651880 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x777e5)[0x7fcd4203c7e5]
/lib/x86_64-linux-gnu/libc.so.6(+0x8213e)[0x7fcd4204713e]
/lib/x86_64-linux-gnu/libc.so.6(__libc_malloc+0x54)[0x7fcd42049184]
/usr/lib/x86_64-linux-gnu/libstdc++.so.6(_Znwm+0x18)[0x7fcd42725e78]
click[0x5485fa]
click[0x591bfc]
click[0x5afab7]
click[0x54d467]
click[0x470064]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7fcd41fe5830]
click[0x472319]
======= Memory map: ========
00400000-00655000 r-xp 00000000 08:01 1149                               /usr/local/bin/click
00854000-00876000 r--p 00254000 08:01 1149                               /usr/local/bin/click
00876000-00877000 rw-p 00276000 08:01 1149                               /usr/local/bin/click
00877000-00878000 rw-p 00000000 00:00 0
02627000-0267a000 rw-p 00000000 00:00 0                                  [heap]

I'm using DPDK on an Ubuntu 16.04 machine. If I remove the two lines from the element, the router functions perfectly.

I would appreciate some advice on how to solve the memory allocation issue.

Thanks!

Can you please include more code than that? It isn't clear to me where you're putting the TokenBucket or how you're loading your Elements. I have some guesses, but the above is not detailed enough to help.

Additionally, you do not appear to be compiling with debugging symbols.

I have fixed the issue now, I had to declare the token bucket in the code file rather than the header file.

This often happens when you modify a .hh and do not recompile elements.cc. "make findelem" will force it.