message: Making sure that the proc FLR doesn't get deleted before lib_ (in FunctionBufferingResource).
diff: @@ -36,12 +36,14 @@ using FunctionBufferCallback = std::function<void(const BufferElement&)>;
  class FunctionBufferingResource : public ResourceBase {
  public:
  FunctionBufferingResource(FunctionLibraryRuntime* lib,
  + std::unique_ptr<ProcessFunctionLibraryRuntime> pflr,
  const NameAttrList& func, int64 buffer_size,
  const string& source_device,
  const string& target_device,
  const std::vector<Tensor>& func_args,
  int64 thread_pool_size)
  : lib_(lib),
  + pflr_(std::move(pflr)),
  func_(func),
  buffer_size_(buffer_size),
  source_device_(source_device),
  @@ -223,6 +225,7 @@ class FunctionBufferingResource : public ResourceBase {
  mutex mu_;
  FunctionLibraryRuntime* lib_;
  + std::unique_ptr<ProcessFunctionLibraryRuntime> pflr_;
  NameAttrList func_;
  const int64 buffer_size_;
  const string source_device_;
  @@ -242,7 +245,7 @@ class FunctionBufferingResource : public ResourceBase {
  class FunctionBufferResourceHandleOp : public OpKernel {
  public:
  explicit FunctionBufferResourceHandleOp(OpKernelConstruction* ctx)
  - : OpKernel(ctx), flib_def_(nullptr), pflr_(nullptr) {
  + : OpKernel(ctx), flib_def_(nullptr) {
  OP_REQUIRES_OK(ctx, ctx->GetAttr("f", &func_));
  OP_REQUIRES_OK(ctx, ctx->GetAttr("buffer_size", &buffer_size_));
  OP_REQUIRES_OK(ctx, ctx->GetAttr("container", &container_));
  @@ -283,18 +286,19 @@ class FunctionBufferResourceHandleOp : public OpKernel {
  if (!initialized_) {
  OP_REQUIRES_OK(ctx, cinfo_.Init(ctx->resource_manager(), def()));
  FunctionLibraryRuntime* clone_lib;
  - OP_REQUIRES_OK(ctx, lib->Clone(&flib_def_, &pflr_, &clone_lib));
  + std::unique_ptr<ProcessFunctionLibraryRuntime> pflr;
  + OP_REQUIRES_OK(ctx, lib->Clone(&flib_def_, &pflr, &clone_lib));
  // Create the resource.
  FunctionBufferingResource* buffer;
  OP_REQUIRES_OK(
  ctx,
  ctx->resource_manager()->LookupOrCreate<FunctionBufferingResource>(
  cinfo_.container(), cinfo_.name(), &buffer,
  - [clone_lib, &source_device, &target_device, func_args,
  + [clone_lib, &pflr, &source_device, &target_device, func_args,
  this](FunctionBufferingResource** ptr) {
  *ptr = new FunctionBufferingResource(
  - clone_lib, func_, buffer_size_, source_device,
  - target_device, func_args, thread_pool_size_);
  + clone_lib, std::move(pflr), func_, buffer_size_,
  + source_device, target_device, func_args, thread_pool_size_);
  return Status::OK();
  }));
  OP_REQUIRES_OK(ctx, buffer->Instantiate());
  @@ -311,7 +315,6 @@ class FunctionBufferResourceHandleOp : public OpKernel {
  ContainerInfo cinfo_ GUARDED_BY(mu_);
  bool initialized_ GUARDED_BY(mu_) = false;
  std::unique_ptr<FunctionLibraryDefinition> flib_def_;
  - std::unique_ptr<ProcessFunctionLibraryRuntime> pflr_;
  NameAttrList func_;
  int64 buffer_size_;
  string container_;
  