You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Logger use printf like format with variables.
For instance LOG_DEBUG(0, "Variable a = %d", varA) with varA an integer.
In case of user gives wrong format (For instance %s), a segfault is generated.
Issue
No nice error message displayed!
It is really hard from the end user point of view to understand the error comes from its log format. (And anyway, logger should be able to segfault the program like this.)
Compiler-time format checking is required. (For the vsnprintf call)
Reproduce the error
Run this beautiful piece of code
#include <logger/elephant.h>
int main(int argc, char** argv) {
elephant::init();
int counter = 20;
LOG_DEBUG(0, "Counter %s", counter); // %s should be %d -> segfault!
return 0;
}
To run, you can use g++ -g -Wall -I/path/to/logger/includes main.cpp /path/to/elephantlib/libelephant.a -pthread -lstdc++fs
(lstdc++fs is for the required experimental/filesystem)
Last words
Little elephant wish you good luck!
Your code:
The (only..) message you get
The text was updated successfully, but these errors were encountered:
geekymoose
changed the title
Wrong format in LOG generated error impossible to understand by end user
Add Compile-time checking of LOG arguments
Nov 26, 2017
geekymoose
changed the title
Add Compile-time checking of LOG arguments
Add Compile-time checking for LOG arguments
Nov 26, 2017
geekymoose
changed the title
Add Compile-time checking for LOG arguments
Add Compile-time checking of LOG arguments
Nov 26, 2017
Description
Logger use printf like format with variables.
For instance
LOG_DEBUG(0, "Variable a = %d", varA)
with varA an integer.In case of user gives wrong format (For instance %s), a segfault is generated.
Issue
No nice error message displayed!
It is really hard from the end user point of view to understand the error comes from its log format. (And anyway, logger should be able to segfault the program like this.)
Compiler-time format checking is required. (For the vsnprintf call)
Reproduce the error
Run this beautiful piece of code
To run, you can use
g++ -g -Wall -I/path/to/logger/includes main.cpp /path/to/elephantlib/libelephant.a -pthread -lstdc++fs
(lstdc++fs is for the required experimental/filesystem)
Last words
Little elephant wish you good luck!
The text was updated successfully, but these errors were encountered: