{"id":5525,"date":"2014-03-30T23:40:33","date_gmt":"2014-03-30T23:40:33","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/can-print-from-command-line-but-cannot-get-it-from-the-program-collection-of-common-programming-errors\/"},"modified":"2014-03-30T23:40:33","modified_gmt":"2014-03-30T23:40:33","slug":"can-print-from-command-line-but-cannot-get-it-from-the-program-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/can-print-from-command-line-but-cannot-get-it-from-the-program-collection-of-common-programming-errors\/","title":{"rendered":"can print from command line, but cannot get it from the program-Collection of common programming errors"},"content":{"rendered":"<p>I use gdb to debug my program, when I unpack a message and wanna print it, I got a problem. It seems that i can print from command line in the terminal, but when program goes to the <code>printf(\"%d has received msg: \", msg-&gt;connid);<\/code>, I got the problem,<\/p>\n<pre><code>Program received signal SIGSEGV, Segmentation fault.\n    0xb7ff6301 in ?? () from \/lib\/ld-linux.so.2\n\n(gdb)n\n154     LSPMessage* msg = lspmessage__unpack(NULL, msg_len, buf);\n(gdb) n\n156     memcpy(pld, msg-&gt;payload.data, msg-&gt;payload.len);\n(gdb) p msg-&gt;payload.data\n$1 = (uint8_t *) 0x804c038 \"Connectedrt,\\031\"\n(gdb) p msg-&gt;connid\n$2 = 1\n(gdb) p msg-&gt;payload.len\n$3 = 9\n174     printf(\"%d has received msg: \", msg-&gt;connid);  \/\/ required field\n(gdb) n\nProgram received signal SIGSEGV, Segmentation fault.\n0xb7ff6301 in ?? () from \/lib\/ld-linux.so.2\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I use gdb to debug my program, when I unpack a message and wanna print it, I got a problem. It seems that i can print from command line in the terminal, but when program goes to the printf(&#8220;%d has received msg: &#8220;, msg-&gt;connid);, I got the problem, Program received signal SIGSEGV, Segmentation fault. 0xb7ff6301 [&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-5525","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5525","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=5525"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5525\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=5525"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=5525"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=5525"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}