{"id":4737,"date":"2022-08-28T18:48:55","date_gmt":"2022-08-29T01:48:55","guid":{"rendered":"http:\/\/www.contrapositivediary.com\/?p=4737"},"modified":"2022-08-28T18:50:16","modified_gmt":"2022-08-29T01:50:16","slug":"sasm-crashes-on-section-in-a-comment","status":"publish","type":"post","link":"https:\/\/www.contrapositivediary.com\/?p=4737","title":{"rendered":"SASM Crashes on &#8220;Section&#8221; in a Comment"},"content":{"rendered":"<p>As most of you know, I&#8217;m grinding along on the fourth edition of my book <em>Assembly Language Step By Step,<\/em> updated to cover x64. I&#8217;m using <a href=\"https:\/\/dman95.github.io\/SASM\/english.html\" target=\"_blank\" rel=\"noopener\">the SASM IDE<\/a> for the example code because it provides seamless visual debugging using a front-end to gdb. Back in 2009 I created the third edition, and incorporated the Insight debugger front end for visual debugging. A month or so after the book appeared, Insight vanished from the Linux world. I tried a lot of debuggers and editors before I discovered SASM. It&#8217;s treated me very well.<\/p>\n<p>Until today.<\/p>\n<p>Now, I&#8217;ve been programming since 1970, in a lot of languages, on a lot of platforms, and I&#8217;ve made a lot of mistakes. Finding those mistakes is what debugging is about. Today, I was working on a short example program for the book. When I finished it, I clicked the Build button. It built as it should. I needed to single-step it to verify something about local labels, but when I clicked the debug button, SASM crashed. As Shakespeare would have put it, SASM died and gave no sign. The whole IDE just vanished. I tried it again. Same thing. I rebooted Linux. Same thing.<\/p>\n<p>Puzzled doesn&#8217;t quite capture it. I loaded another example program from the book. It built and debugged without any trouble. I loaded example after example, and they all worked perfectly. Then I copied the source from the malfunctioning example into a file called crashtest.asm, and began cutting things out of it. I got it down to a start label and a SYSCALL to the exit function. Still blew SASM away.<\/p>\n<p>Most of what was left was comments. I did a ctrl-X to cut the comment header onto the clipboard. Save, build, debug&#8211;and it worked perfectly.No crash, no errors, no problemo.<\/p>\n<p>Soooooooo&#8230;&#8230;.something in a <em>comment header<\/em> crashed the IDE? That would be a new one. So I dropped the comment header back into the file from the clipboard and started cutting out lines, one by one. I narrowed it down to one comment line, properly begun with a semicolon and containing no weird characters. The line that crashed SASM was this:<\/p>\n<pre>\n;         .bss sections.\n<\/pre>\n<p>I cut out the spaces and the period. No change. I cut out &#8220;.bss&#8221;. No change. I was left with the word &#8220;sections.&#8221; On a hunch, I lopped off the &#8220;s&#8221;. No change. Then I lopped off the &#8220;n&#8221;. Suddenly, it all worked.<\/p>\n<p>SASM was crashing on a comment containing the word &#8220;section.&#8221; I verified by deleting the line entirely and typing it in again. Crash!<\/p>\n<p>I stared at the damned thing for a long time. I loaded a couple of my other examples, and dropped the offending comment header into them. No problems. Twenty minutes later, I noticed something: In crashtest.asm, the fragment of comment header text was below the three section markers:<\/p>\n<p><code>section.bss<br \/>section.data<br \/>section.text<br \/><\/code><\/p>\n<p><code>; section<\/code><\/p>\n<p>Now, in my other examples, the ones that didn&#8217;t crash, the comment header was <em>above<\/em> the three section markers. So I went back to crashtest.asm, and moved the comment header to the very beginning of the file, above the section markers. Suddenly everything worked. No crashes.<\/p>\n<p>WTF? I assembled the offending crashtest binary from the command line without trouble. I loaded it into gdb from the command line and messed with it. No trouble.<\/p>\n<p>I wrote this entry not for answers so much as to provide a report that other SASM users can find in search engines. There are things about SASM that aren&#8217;t ideal. Sure. But I&#8217;ve never seen it crash before. I&#8217;ll see if I can send the crashtest.asm to the people who created SASM. I&#8217;m sure it&#8217;s just a bug. But it&#8217;s the weirdest damfool bug I&#8217;ve uncovered in a <em>whole<\/em> lot of years!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As most of you know, I&#8217;m grinding along on the fourth edition of my book Assembly Language Step By Step, updated to cover x64. I&#8217;m using the SASM IDE for the example code because it provides seamless visual debugging using a front-end to gdb. Back in 2009 I created the third edition, and incorporated the [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23],"tags":[125,32,20],"class_list":["post-4737","post","type-post","status-publish","format-standard","hentry","category-ideasandanalysis","tag-assembly","tag-programming","tag-writing"],"_links":{"self":[{"href":"https:\/\/www.contrapositivediary.com\/index.php?rest_route=\/wp\/v2\/posts\/4737","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.contrapositivediary.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.contrapositivediary.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.contrapositivediary.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.contrapositivediary.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4737"}],"version-history":[{"count":2,"href":"https:\/\/www.contrapositivediary.com\/index.php?rest_route=\/wp\/v2\/posts\/4737\/revisions"}],"predecessor-version":[{"id":4739,"href":"https:\/\/www.contrapositivediary.com\/index.php?rest_route=\/wp\/v2\/posts\/4737\/revisions\/4739"}],"wp:attachment":[{"href":"https:\/\/www.contrapositivediary.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4737"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.contrapositivediary.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4737"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.contrapositivediary.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4737"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}