{"id":410,"date":"2008-08-19T17:03:57","date_gmt":"2008-08-19T15:03:57","guid":{"rendered":"http:\/\/daniel.haxx.se\/blog\/?p=410"},"modified":"2008-08-21T08:17:42","modified_gmt":"2008-08-21T06:17:42","slug":"popen-in-pthreaded-program-confuses-gdb","status":"publish","type":"post","link":"https:\/\/daniel.haxx.se\/blog\/2008\/08\/19\/popen-in-pthreaded-program-confuses-gdb\/","title":{"rendered":"popen() in pthreaded program confuses gdb"},"content":{"rendered":"<p>I just thought I&#8217;d share a lesson I learned today:<\/p>\n<p>I&#8217;ve been struggling for a long time at work with a gdb problem. When I set a break-point and then single-step from that point, it sometimes (often) decides to act as if I had done &#8216;<strong>continue<\/strong>&#8216; and not &#8216;<strong>next<\/strong>&#8216;. It is highly annoying and makes debugging nasty problems really awkward.<\/p>\n<p>Today I searched around for the topic and after some experiments I can now confirm: if I remove all uses of popen() I no longer get the problems! I found posts that indicated that forking could confuse threaded programs, and since this program at work uses threads I could immediately identify that it uses both popen() and system() and both of them use fork() internally. (And yes, I believe my removal of popen() also removed the system() calls.)<\/p>\n<p>And now I can finally debug my crappy code again to become less crappy!<\/p>\n<p>My work PC runs glibc 2.6.1, gcc 4.1.3 and gdb 6.6. But I doubt the specific versions matter much.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I just thought I&#8217;d share a lesson I learned today: I&#8217;ve been struggling for a long time at work with a gdb problem. When I set a break-point and then single-step from that point, it sometimes (often) decides to act as if I had done &#8216;continue&#8216; and not &#8216;next&#8216;. It is highly annoying and makes &hellip; <a href=\"https:\/\/daniel.haxx.se\/blog\/2008\/08\/19\/popen-in-pthreaded-program-confuses-gdb\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">popen() in pthreaded program confuses gdb<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,6],"tags":[419],"class_list":["post-410","post","type-post","status-publish","format-standard","hentry","category-development","category-floss","tag-development"],"_links":{"self":[{"href":"https:\/\/daniel.haxx.se\/blog\/wp-json\/wp\/v2\/posts\/410","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/daniel.haxx.se\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/daniel.haxx.se\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/daniel.haxx.se\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/daniel.haxx.se\/blog\/wp-json\/wp\/v2\/comments?post=410"}],"version-history":[{"count":0,"href":"https:\/\/daniel.haxx.se\/blog\/wp-json\/wp\/v2\/posts\/410\/revisions"}],"wp:attachment":[{"href":"https:\/\/daniel.haxx.se\/blog\/wp-json\/wp\/v2\/media?parent=410"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/daniel.haxx.se\/blog\/wp-json\/wp\/v2\/categories?post=410"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/daniel.haxx.se\/blog\/wp-json\/wp\/v2\/tags?post=410"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}