-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue 727 #23
Issue 727 #23
Conversation
Please check #13 for more info about licensing issue. IMHO don't add LICENSE.md in this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make your branch end at 6473e32 and force-push, I'd like to avoid having these licenses in our history.
Other than that looks good.
Branch (and PR) reverted to 6473e32 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove the first commit which is related to websocket_test (rebase then force push) due to #30.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The general quality of this looks rather poor to me.
Perhaps better use https://github.com/boostorg/stacktrace or sth like that?
auto result = readlink("/proc/self/exe", my_path, 511); | ||
if( result < 0 ) | ||
{ | ||
std::cerr << "print_stacktrace_linenums() failed, could not read PID" << std::endl; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use elog() instead of cerr. I know that breaks the self-containment, but we're not using this as a standalone tool.
} | ||
|
||
std::ostringstream ss_cmd; | ||
ss_cmd << "addr2line -p -a -f -C -i -e " << my_path; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a classic shell injection bug. Avoid creating subprocesses using functions that execute a string as a shell command. Use something like execvp instead.
// I use something platform-specific and self-contained, rather than using | ||
// e.g. boost::process, because I want stacktrace to be small and self-contained | ||
// | ||
std::string run_command( const std::string& command ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make this function "static", it is not supposed to be used from outside.
|
||
// allocate string which will be filled with the demangled function name | ||
size_t funcnamesize = 256; | ||
char* funcname = (char*)malloc(funcnamesize); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't free'd if something further down throws.
|
||
// resolve addresses into strings containing "filename(function+address)", | ||
// this array must be free()-ed | ||
char** symbollist = backtrace_symbols(addrlist, addrlen); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't free'd if something further down throws.
void print_stacktrace( std::ostream& out, unsigned int max_frames /* = 63 */, void* caller_overwrite_hack /* = nullptr */ ) | ||
{ | ||
std::cerr << "print stacktrace\n"; | ||
assert( max_frames <= 128 ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace this assert with an actual check that prevents crashes.
assert( max_frames <= 128 ); | ||
void* callstack[ 128 ]; | ||
int frames = backtrace( callstack, max_frames ); | ||
char** strs = backtrace_symbols( callstack, frames ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't free'd if something further down throws.
Closed in favor of a solution for boost >= 1.65 |
This is the fc part of
bitshares/bitshares-core#727
The code was gleaned from the steem project, and modified to fit our purposes.
This PR also includes a tiny fix to a test (websocket_test.cpp) that was causing the only compiler warning for this project (on gcc at least).