{"id":2759,"date":"2022-08-30T15:27:32","date_gmt":"2022-08-30T15:27:32","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/02\/08\/problem-about-stack-unwinding-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:27:32","modified_gmt":"2022-08-30T15:27:32","slug":"problem-about-stack-unwinding-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/problem-about-stack-unwinding-collection-of-common-programming-errors\/","title":{"rendered":"problem about stack-unwinding-Collection of common programming errors"},"content":{"rendered":"<ul>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/73b48a562cf558749f46650f9f4d129e?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nlurscher<br \/>\nc++ exception-handling shared-ptr stack-unwinding<br \/>\nis there any pitfall of the following;if (someCondition)throw boost::shared_ptr&lt;SomeException&gt;( new SomeException( &#8220;foo!&#8221; ) );&#8230;catch( const boost::shared_ptr&lt;SomeException&gt;&amp; expRef ){}<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/e2cef525cef5d7b0078f33b707e30c69?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\n12 revs, 3 users 90%Aftershock<br \/>\nc++ compiler microsoft stack-unwinding<br \/>\nI have a c++ code, I use MSC9 to compile it. It keeps crashing randomly. For example it crashes if it is called from Perl using &#8220; but it does not crash when It is called from command line or from Ultimate++.I mean calling it from perl eg. f.exe arg1 arg2 arg3Stack trace does not show much. Tracing the program line by line proved that the program fails at the end when returning&#8230;So it is like thatint funcname() {return 0; &lt;&#8211; crashing after that&#8230; }I guess the stack is damaged, and after th<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/2a04086d7656ac97e09c20c4fe4d8266?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nsharptooth<br \/>\nc++ destructor stack-unwinding<br \/>\nC++ automagically calls destructors of all local variables in the block in reverse order regardless of whether the block is exited normally (control falls through) or an exception is thrown.Looks like the term stack unwinding only applies to the latter. How is the former process (the normal exit of the block) called concerning destroying local variables?<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/b4e3e96ba1b76fad8c90beaad7fd281d?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\ndecimus phostle<br \/>\nc++ exception exception-handling raii stack-unwinding<br \/>\nTIL that my notions of the &#8216;inter-twining&#8217; (for the lack of a better word) of RAII &amp; stack-unwinding are\/were quite(if not completely) wrong. My understanding was that using RAII, guarded against any\/all resource leaks &#8211; even ones potentially caused by unhandled exceptions. However writing this test program and subsequently stumbling upon this article\/documentation, made me realize that stack unwinding would only cause the RAII-enabled resource deallocation to kick in for automatic&#8217;s within<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/5bd89ec20b7530a1c813134da4ea64c4?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nihamer<br \/>\nc++ stack stack-unwinding<br \/>\nI have a simple C++ object that I create at the start of function F() to ensure two matched functions (OpDo, OpUndo) are called at the start and return of the F(), by using the object&#8217;s constructor and destructor. However, I don&#8217;t want the operation to be undone in case an exception was thrown within the body of F(). Is this possible to do cleanly? I have read about std::uncaught-exception, but its use does not seem to be recommended.<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/069df327874c5f889b6e1f83d4a4a6b3?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nbaskan<br \/>\njava c++ stack-unwinding<br \/>\nAs far as I know, in case of an uncaught exception, C++ destroys the local variables immediately, Java releases the references and leaves the rest for the garbage collector.Is this right? What exactly is the difference between Java and C++ on this issue? in other words, which of these two languages is considered better in terms of stack unwinding issue? \ud83d\ude42<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/78140b18051cbf367d39f10d10ef2c8b?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nAvio<br \/>\nlinker stack-trace undefined-reference undefined-symbol stack-unwinding<br \/>\n\/mnt\/workspace\/testproject\/misc-libs\/libunwind.a(Lresume.o): In function `_ULx86_local_resume&#8217;: (.text+0x4a): warning: warning: sigreturn is not implemented and will always failI&#8217;m getting this warning about libunwind when linking my project with -static flag enabled. Looking at this symbol inside the installed libunwind libraries, it seems that it&#8217;s actually undefined.\/usr\/lib\/libunwind.aU sigreturn \/usr\/lib\/libunwind-generic.aU sigreturn \/usr\/lib\/libunwind-x86.aU sigreturnAnd these are the lib<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/fedc103058a54e78d76bfc3a941c7327?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nlcbrevard<br \/>\nporting freebsd endianness configure stack-unwinding<br \/>\nlibunwind is available as a package (pkg_add -r libunwind) on FreeBSD 8.1 amd64.It is not available that way on FreeBSD 8.1 i386.When I download from http:\/\/www.nongnu.org\/libunwind\/ I cannot build it.The error is In file included from ptrace\/_UPT_elf.c:4: ..\/include\/libunwind_i.h:65:5: error: #error Host has unknown byte-order. * Error code 1This appears to be a .\/configure error. Is there a way to force this information at configuration time?<\/li>\n<\/ul>\n<p id=\"rop\"><small>Originally posted 2014-02-08 16:00:33. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>lurscher c++ exception-handling shared-ptr stack-unwinding is there any pitfall of the following;if (someCondition)throw boost::shared_ptr&lt;SomeException&gt;( new SomeException( &#8220;foo!&#8221; ) );&#8230;catch( const boost::shared_ptr&lt;SomeException&gt;&amp; expRef ){} 12 revs, 3 users 90%Aftershock c++ compiler microsoft stack-unwinding I have a c++ code, I use MSC9 to compile it. It keeps crashing randomly. For example it crashes if it is called [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2759","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2759","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=2759"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2759\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=2759"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=2759"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=2759"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}