- changed title to LPC callback that returns a reference produces a future containing a dangling reference
LPC callback that returns a reference produces a future containing a dangling reference
Issue #413
resolved
Test code:
#include <upcxx/upcxx.hpp>
#include "../util.hpp"
struct T {
bool valid = true;
~T() { valid = false; }
};
T global;
int main() {
upcxx::init();
print_test_header();
upcxx::persona &target = upcxx::current_persona();
upcxx::future<T const&> f =
target.lpc([]() -> T const & { return global; });
UPCXX_ASSERT_ALWAYS(f.wait_reference().valid);
print_test_success();
upcxx::finalize();
}
Result:
Test: issue413.cpp
Ranks: 1
*** FATAL ERROR (proc 0):
//////////////////////////////////////////////////////////////////////
UPC++ assertion failure:
on process 0 (marauder.local)
at test/regression/issue413.cpp:18
in function: int main()
Failed condition: f.wait_reference().valid
To have UPC++ freeze during these errors so you can attach a debugger,
rerun the program with GASNET_FREEZE_ON_ERROR=1 in the environment.
//////////////////////////////////////////////////////////////////////
NOTICE: Before reporting bugs, run with GASNET_BACKTRACE=1 in the environment to generate a backtrace.
*** Caught a fatal signal (proc 0): SIGABRT(6)
Abort trap: 6
Some relevant discussion in PR #272.
Comments (5)
-
reporter -
reporter Possible fix, if we decide that the reference is preserved:
diff --git a/src/persona.hpp b/src/persona.hpp index 49efb33e..6264d508 100644 --- a/src/persona.hpp +++ b/src/persona.hpp @@ -105,7 +105,11 @@ namespace upcxx { template<typename ...Args> void operator()(Args &&...args) { - std::tuple<typename std::decay<Args>::type...> results{ + std::tuple<typename std::conditional< + std::is_rvalue_reference<Args>::value, + typename std::decay<Args>::type, + Args + >::type...> results{ std::forward<Args>(args)... };
-
For the record, this issue is also responsible for compile errors seen on lpc-ctor-trace with Apple XCode up to Apple LLVM version 9.0.0 : nightly CI
-
reporter - changed status to resolved
Fix
#413. Add a test.→ <<cset 47911e8a11b7>>
-
reporter Merged in akamil/upcxx/issue413 (pull request #274)
Fix
#413and add a test.Approved-by: Dan Bonachea dobonachea@lbl.gov
→ <<cset 774c50969e8e>>
- Log in to comment