Skip to content

Fix object lifetime and memory management problems in server code#248

Merged
murgatroid99 merged 4 commits intogrpc:masterfrom
murgatroid99:server_memory_management_fixes
Apr 3, 2018
Merged

Fix object lifetime and memory management problems in server code#248
murgatroid99 merged 4 commits intogrpc:masterfrom
murgatroid99:server_memory_management_fixes

Conversation

@murgatroid99
Copy link
Copy Markdown
Member

@murgatroid99 murgatroid99 commented Apr 2, 2018

This includes a few fixes:

  • Ensure that client and server credentials construction arguments are null-terminated.
  • Ensure that the callback for Server#tryShutdown is always called asynchronously.
  • Ensure that the server doesn't get garbage collected while it is running, and remove server destructor code the server down.

new grpc_ssl_pem_key_cert_pair[key_cert_pair_count];

grpc_ssl_pem_key_cert_pair key_cert_pairs[key_cert_pair_count];
StringOrNull key_strings[key_cert_pair_count];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#include <memory>
[...]
std::auto_ptr<StringOrNull> key_strings = new StringOrNull[key_cert_pair_count];
std::auto_ptr<StringOrNull> cert_strings = new StringOrNull[key_cert_pair_count];

And then later use cert_strings[i]->assign().

@nicolasnoble
Copy link
Copy Markdown
Contributor

Also, from tests:

E0402 15:50:47.195617365   31663 server.cc:1247]             assertion failed: gpr_atm_acq_load(&server->shutdown_flag) || !server->listeners

@murgatroid99 murgatroid99 merged commit 43dfc7f into grpc:master Apr 3, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Jan 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants