yse / easy_profiler

Lightweight profiler library for c++
MIT License
2.17k stars 189 forks source link

EASY_BLOCK can overrun w/ really large block names #157

Open inantop opened 5 years ago

inantop commented 5 years ago

In a creative (mis)use of EASY_BLOCK we are adding additional diagnostic data to some blocks in debug builds, sometimes this can be a long HTTP response for instance. In one such case we discovered that a buffer overrun was occurring.

The implicit block name limit didn't appear to be documented anywhere, but in addition to documentation perhaps it could be truncated by easy_profiler as well.

yse commented 5 years ago

Hello! Sorry for long time silence. Thank you for feedback. Quick investigation shows that about long name (3k length) for block cause crash =( It's seem to be a bug.

inantop commented 5 years ago

No problem! Thank you for looking into it.

cas4ey commented 5 years ago

Memory for the blocks is allocating with chunks of fixed length, this is done for optimization reasons. Really long name has exceed the size of the chunk which lead to crash - that's the reason. Definitely, we should truncate such names automatically to prevent crashes. As for additional diagnostic information, I would better suggest you to use EASY_VALUE blocks to store custom variables and data.