You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Example simple_wget crashing from time to time with error: boost thread: trying joining itself: Resource deadlock avoided
How to reproduce
I turn off wi-fi and run command: simple_wget https://example.com/some/archive.tar.gz
Usually command exits with code 1 and message:
Saving to: archive.tar.gz
Host not found (authoritative)
which is expected and good, but sometimes application crash in libc++ with message:
libc++abi.dylib: terminating with unexpected exception of type boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::thread_resource_error> >: boost thread: trying joining itself: Resource deadlock avoided
Process 75882 stopped
So, the simple_wget example needs some love.
I don't think that it's just example issue, I have same troubles in other situations too.
Can you send a pull request to fix this example?
The problem is that I don't know how to fix it (: Maybe it some thread management issue,
async_client ctor called in one thread and dtor called in other. Maybe it's just corrupted memory or double destruction. Simple workaround is to catch expection and ignore it, but it's more like hack...
Right, this is not a simple issue to fix. I think it's because during the lifetime of the response object, a resolution error may happen and if there's an exception thrown during the fetching of the body (or any part of the response for that matter) it would cause the destruction of the async client (if they're in the same scope). What's really happening here is a lifetime issue -- perhaps there's a way to change the destruction semantics of the async client, but I'm not entirely sure what that should be. Maybe it's just a matter of swallowing exceptions that are trying to propagate out of the destructor?
Maybe it's just a matter of swallowing exceptions that are trying to propagate out of the destructor?
I don't save logs but last time I try it (see workaround above) I've got Segmentation Fault.
FYI looks like master branch is not suffering from this issue.
I think this issue is the same with #232. (client object lifetime)
So, it will just be fixed by avoiding self join. (leecoder@af17c77)
And, it will must always be used an outside io_service.
Activity
Workaround issue cpp-netlib#358
deanberris commentedon Jan 13, 2014
So, the simple_wget example needs some love. Can you send a pull request to fix this example? I would greatly appreciate it @ruslo.
ruslo commentedon Jan 13, 2014
So, the simple_wget example needs some love.I don't think that it's just example issue, I have same troubles in other situations too.
Can you send a pull request to fix this example?The problem is that I don't know how to fix it (: Maybe it some thread management issue,
async_client ctor called in one thread and dtor called in other. Maybe it's just corrupted memory or double destruction. Simple workaround is to catch expection and ignore it, but it's more like hack...
deanberris commentedon Jan 23, 2014
Right, this is not a simple issue to fix. I think it's because during the lifetime of the response object, a resolution error may happen and if there's an exception thrown during the fetching of the body (or any part of the response for that matter) it would cause the destruction of the async client (if they're in the same scope). What's really happening here is a lifetime issue -- perhaps there's a way to change the destruction semantics of the async client, but I'm not entirely sure what that should be. Maybe it's just a matter of swallowing exceptions that are trying to propagate out of the destructor?
ruslo commentedon Jan 23, 2014
I don't save logs but last time I try it (see workaround above) I've got
Segmentation Fault.FYI looks like master branch is not suffering from this issue.
leecoder commentedon Jun 17, 2014
I think this issue is the same with #232. (client object lifetime)
So, it will just be fixed by avoiding self join. (leecoder@af17c77)
And, it will must always be used an outside io_service.
Then, the following code works!
deanberris commentedon Jun 17, 2014
@leecoder Nice find. Can you send me a pull request on the 0.11-devel branch with that fix?
Merge pull request #402 from leecoder/0.11-devel
Merge pull request #405 from leecoder/0.11-devel
Merge pull request cpp-netlib#402 from leecoder/0.11-devel
Merge pull request cpp-netlib#405 from leecoder/0.11-devel
olegabr commentedon Feb 13, 2018
I've got the same error in the 0.13-release branch now.
The patch that fixes it that was applied in the 0.11-devel here: 1b11ec6#diff-c272e324d5e4a6288abe1e22553c4027
was reverted without any explanations here: 2be7e30#diff-c272e324d5e4a6288abe1e22553c4027
The question is why? And should we apply it back?
deanberris commentedon Feb 14, 2018
I think this was an oversight. Thanks for the fix!