rr-debugger / rr-debugger/rr

src/MonitoredSharedMemory.cc:46:32: error: possibly dangling reference to a temporary

Open
#3,484 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
10.7k
Forks
662
Avg merge
2d 3h
Merged PRs (30d)
2

Description

Followup to

/home/jdanek/repos/rr/src/MonitoredSharedMemory.cc: In static member function ‘static void rr::MonitoredSharedMemory::maybe_monitor(rr::RecordTask*, const std::string&, const rr::AddressSpace::Mapping&, int, uint64_t)’:
/home/jdanek/repos/rr/src/MonitoredSharedMemory.cc:46:32: error: possibly dangling reference to a temporary [-Werror=dangling-reference]
   46 |   const AddressSpace::Mapping& shared =
      |                                ^~~~~~
/home/jdanek/repos/rr/src/MonitoredSharedMemory.cc:47:29: note: the temporary was destroyed at the end of the full expression ‘rr::Session::steal_mapping(remote, (* & m), std::shared_ptr<rr::MonitoredSharedMemory>((* & std::move<shared_ptr<rr::MonitoredSharedMemory>&>(result))))’
   47 |       Session::steal_mapping(remote, m, std::move(result));
      |       ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1plus: all warnings being treated as errors
/home/jdanek/repos/rr/src/Session.cc: In static member function ‘static void rr::Session::make_private_shared(rr::AutoRemoteSyscalls&, rr::AddressSpace::Mapping)’:
/home/jdanek/repos/rr/src/Session.cc:618:32: error: possibly dangling reference to a temporary [-Werror=dangling-reference]
  618 |   const AddressSpace::Mapping& new_m = steal_mapping(remote2, m);
      |                                ^~~~~
/home/jdanek/repos/rr/src/Session.cc:618:53: note: the temporary was destroyed at the end of the full expression ‘rr::Session::steal_mapping(remote2, m, std::shared_ptr<rr::MonitoredSharedMemory>(nullptr))’
  618 |   const AddressSpace::Mapping& new_m = steal_mapping(remote2, m);
      |                                        ~~~~~~~~~~~~~^~~~~~~~~~~~
cc1plus: all warnings being treated as errors

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read src/MonitoredSharedMemory.cc around lines 46-47 and src/Session.cc around line 618, then inspect the return value and lifetime behavior of Session::steal_mapping. Reproduce the compiler diagnostics with warnings treated as errors and verify that both dangling-reference warnings are resolved without introducing new build failures.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.