public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "thomas.sanchz at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/60966] std::call_once sometime hangs
Date: Mon, 28 Apr 2014 07:55:00 -0000	[thread overview]
Message-ID: <bug-60966-4-qMkJU6uZi0@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-60966-4@http.gcc.gnu.org/bugzilla/>

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60966

--- Comment #4 from Thomas Sanchez <thomas.sanchz at gmail dot com> ---
(In reply to Jonathan Wakely from comment #3)
> > > N.B. the std::move in Manager::cancelConnection is redundant, the return
> > > value from cancel_connection is already an rvalue.
> > 
> > Yes, I know, the problem is I have some hard time to avoid doing this as it
> > is more for me and what I expect the compiler to do or the semantics I want
> > the code to have :)
> 
> OK, but it makes the code worse. Here the compiler will elide the move
> constructor (aka return value optimisation):
> 
>   auto future = cancel_connection(c);
> 
> Whereas here the compiler cannot do that and must call a move constructor:
> 
>   auto future = std::move(cancel_connection(c));

I did not meant to say I should continue, far from here :) Thank for the
notice!

Anyway, I pushed the actual code in this branch:
https://github.com/daedric/httpp/tree/bug-promise-test

I was able to do a small test that can *sometimes* reproduce the bug:
https://github.com/daedric/httpp/blob/bug-promise-test/tests/client/promise.cpp


Since I was able to trigger the problem, here are what you asked for:
>From the get side, (from here
https://github.com/daedric/httpp/blob/bug-promise-test/src/httpp/http/client/Manager.cpp#L113)

(gdb) print future
$1 = {
  <std::__basic_future<void>> = {
    <std::__future_base> = {<No data fields>}, 
    members of std::__basic_future<void>: 
    _M_state = std::shared_ptr (count 2, weak 0) 0x805468
  }, <No data fields>}
(gdb) print promise
$2 = {
  _M_future = std::shared_ptr (count 2, weak 0) 0x805468, 
  _M_storage = std::unique_ptr<std::__future_base::_Result<void>> containing
0x805780
}
(gdb) print &promise
$3 = (std::promise<void> *) 0x7fffffffce90


>From the thread calling the pthread_once:

#4  0x0000000000500d67 in std::promise<void>::set_value (this=0x7fffffffce90)
at /usr/include/c++/4.8/future:1197
1197        _M_future->_M_set_result(std::move(__setter));
(gdb) print *this
$4 = {
  _M_future = std::shared_ptr (count 2, weak 0) 0x805468, 
  _M_storage = std::unique_ptr<std::__future_base::_Result<void>> containing
0x805780
}

This is seems to be correct.
This has been produced with commit: 850ebba9a72d102b54de6912e820889618a4f30d

I'm testing now with the lambdas replaced :)





http://reproducible.io/


  parent reply	other threads:[~2014-04-28  7:55 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-25 13:57 [Bug libstdc++/60966] New: " thomas.sanchz at gmail dot com
2014-04-25 17:53 ` [Bug libstdc++/60966] " redi at gcc dot gnu.org
2014-04-25 18:36 ` redi at gcc dot gnu.org
2014-04-28  7:55 ` thomas.sanchz at gmail dot com [this message]
2014-04-28  8:09 ` thomas.sanchz at gmail dot com
2014-04-28  8:15 ` thomas.sanchz at gmail dot com
2014-04-28  8:22 ` redi at gcc dot gnu.org
2014-05-05  7:48 ` thomas.sanchz at gmail dot com
2014-05-05 15:16 ` redi at gcc dot gnu.org
2014-05-13 22:24 ` fawaka at gmail dot com
2014-05-14  1:58 ` hideaki.kimura at gmail dot com
2014-05-14  7:27 ` thomas.sanchz at gmail dot com
2014-05-14 10:43 ` redi at gcc dot gnu.org
2014-05-15  3:13 ` hideaki.kimura at gmail dot com
2014-05-15 21:05 ` redi at gcc dot gnu.org
2014-05-15 21:30 ` redi at gcc dot gnu.org
2014-05-15 22:02 ` hideaki.kimura at gmail dot com
2014-05-15 22:14 ` redi at gcc dot gnu.org
2014-05-15 22:55 ` redi at gcc dot gnu.org
2014-05-15 22:59 ` redi at gcc dot gnu.org
2014-05-15 23:39 ` redi at gcc dot gnu.org
2014-05-16  0:05 ` hideaki.kimura at gmail dot com
2014-05-16  0:15 ` redi at gcc dot gnu.org
2014-05-16  0:28 ` fawaka at gmail dot com
2014-05-16  7:18 ` redi at gcc dot gnu.org
2014-05-16  7:31 ` thomas.sanchz at gmail dot com
2014-05-17 12:59 ` redi at gcc dot gnu.org
2014-05-17 13:02 ` redi at gcc dot gnu.org
2014-05-17 13:09 ` redi at gcc dot gnu.org
2014-06-03 18:00 ` redi at gcc dot gnu.org
2014-06-03 18:01 ` redi at gcc dot gnu.org
2015-01-09 14:41 ` redi at gcc dot gnu.org
2015-01-09 14:41 ` redi at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-60966-4-qMkJU6uZi0@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).