Skip to content
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

Closed
wants to merge 2 commits into from
Closed

Issue 727 #23

wants to merge 2 commits into from

Conversation

jmjatlanta
Copy link

@jmjatlanta jmjatlanta commented Mar 22, 2018

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).

@abitmore
Copy link
Member

Please check #13 for more info about licensing issue. IMHO don't add LICENSE.md in this PR.

Copy link

@pmconrad pmconrad left a 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.

@jmjatlanta
Copy link
Author

Branch (and PR) reverted to 6473e32

Copy link
Member

@abitmore abitmore left a 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.

@abitmore abitmore dismissed pmconrad’s stale review March 23, 2018 20:25

Change has been done.

Copy link

@pmconrad pmconrad left a 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;

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;

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 )

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);
Copy link

@pmconrad pmconrad Mar 23, 2018

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);
Copy link

@pmconrad pmconrad Mar 23, 2018

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 );

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 );
Copy link

@pmconrad pmconrad Mar 23, 2018

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.

@abitmore abitmore dismissed their stale review March 23, 2018 22:51

Changes are done.

@pmconrad
Copy link

pmconrad commented Apr 8, 2018

Closed in favor of a solution for boost >= 1.65

@pmconrad pmconrad closed this Apr 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants