<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: 64-bit program segmentation fault in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/64-bit-program-segmentation-fault/m-p/4997303#M776922</link>
    <description>Well, given that user allocated data on IPF HP-UX should start at 0x60000000'00000000, I&lt;BR /&gt;really doubt that TALLOC() [whatever it is] worked unless you're allocating shared address space using mmap() or shmget/shmat() under that macro.&lt;BR /&gt;&lt;BR /&gt;Garbage in, garbage out.&lt;BR /&gt;&lt;BR /&gt;What's TALLOC()? If its a custom allocation wrapper (as I suspect), does it check for allocation failure cleanly (as I suspect it doesn't)?</description>
    <pubDate>Tue, 15 Aug 2006 10:58:24 GMT</pubDate>
    <dc:creator>Don Morris_1</dc:creator>
    <dc:date>2006-08-15T10:58:24Z</dc:date>
    <item>
      <title>64-bit program segmentation fault</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/64-bit-program-segmentation-fault/m-p/4997302#M776921</link>
      <description>Hello.&lt;BR /&gt;&lt;BR /&gt;I use HP-UX in two servers: PA-RISC and IA64&lt;BR /&gt;I compile one 64-bit program with aCC compiler.&lt;BR /&gt;When i run program, it create core file with error "Segmentation Fault".&lt;BR /&gt;In gdb I see next:&lt;BR /&gt;&lt;BR /&gt;bash-3.00$ gdb pvm &lt;BR /&gt;HP gdb 5.0 for HP Itanium (32 or 64 bit) and target HP-UX 11.2x.&lt;BR /&gt;Copyright 1986 - 2001 Free Software Foundation, Inc.&lt;BR /&gt;Hewlett-Packard Wildebeest 5.0 (based on GDB) is covered by the&lt;BR /&gt;GNU General Public License. Type "show copying" to see the conditions to&lt;BR /&gt;change it and/or distribute copies. Type "show warranty" for warranty/support.&lt;BR /&gt;..&lt;BR /&gt;(gdb) b 363 &lt;BR /&gt;Breakpoint 1 at 0x4000000000018800:1: file ../../console/cons.c, line 363 from /home/ravil/local/pvm/lib/hppa/pvm.&lt;BR /&gt;(gdb) r &lt;BR /&gt;Starting program: /home/ravil/local/pvm/lib/hppa/pvm &lt;BR /&gt;&lt;BR /&gt;Breakpoint 1, main (argc=1, argv=0x9ffffffffffff5f0)&lt;BR /&gt;    at ../../console/cons.c:363&lt;BR /&gt;363             aliases = TALLOC(1, struct alias, "alias");&lt;BR /&gt;(gdb) print aliases &lt;BR /&gt;$1 = (struct alias *) 0x0&lt;BR /&gt;(gdb) n&lt;BR /&gt;364             BZERO((char*)aliases, sizeof(struct alias));&lt;BR /&gt;(gdb) print aliases&lt;BR /&gt;$2 = (struct alias *) 0x1df30&lt;BR /&gt;(gdb) print *aliases&lt;BR /&gt;Error accessing memory address 0x1df30: Bad address.&lt;BR /&gt;(gdb) n&lt;BR /&gt;&lt;BR /&gt;Program received signal SIGSEGV, Segmentation fault&lt;BR /&gt;  si_code: 1 - SEGV_MAPERR - Address not mapped to object.&lt;BR /&gt;0x9fffffff7c0a72a0:0 in memset+0x140 () from /usr/lib/hpux64/libc.so.1&lt;BR /&gt;(gdb) bt&lt;BR /&gt;#0  0x9fffffff7c0a72a0:0 in memset+0x140 () from /usr/lib/hpux64/libc.so.1&lt;BR /&gt;#1  0x9fffffff7c05d290:0 in bzero+0x30 () from /usr/lib/hpux64/libc.so.1&lt;BR /&gt;#2  0x4000000000018880:0 in main (argc=1, argv=0x9ffffffffffff5f0)&lt;BR /&gt;    at ../../console/cons.c:364&lt;BR /&gt;(gdb) c&lt;BR /&gt;Continuing.&lt;BR /&gt;&lt;BR /&gt;Program terminated with signal SIGSEGV, Segmentation fault.&lt;BR /&gt;The program no longer exists.&lt;BR /&gt;(gdb) q&lt;BR /&gt;bash-3.00$ &lt;BR /&gt;&lt;BR /&gt;What is wrong? &lt;BR /&gt;</description>
      <pubDate>Tue, 15 Aug 2006 07:04:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/64-bit-program-segmentation-fault/m-p/4997302#M776921</guid>
      <dc:creator>Ravil Bikmukhametov</dc:creator>
      <dc:date>2006-08-15T07:04:43Z</dc:date>
    </item>
    <item>
      <title>Re: 64-bit program segmentation fault</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/64-bit-program-segmentation-fault/m-p/4997303#M776922</link>
      <description>Well, given that user allocated data on IPF HP-UX should start at 0x60000000'00000000, I&lt;BR /&gt;really doubt that TALLOC() [whatever it is] worked unless you're allocating shared address space using mmap() or shmget/shmat() under that macro.&lt;BR /&gt;&lt;BR /&gt;Garbage in, garbage out.&lt;BR /&gt;&lt;BR /&gt;What's TALLOC()? If its a custom allocation wrapper (as I suspect), does it check for allocation failure cleanly (as I suspect it doesn't)?</description>
      <pubDate>Tue, 15 Aug 2006 10:58:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/64-bit-program-segmentation-fault/m-p/4997303#M776922</guid>
      <dc:creator>Don Morris_1</dc:creator>
      <dc:date>2006-08-15T10:58:24Z</dc:date>
    </item>
    <item>
      <title>Re: 64-bit program segmentation fault</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/64-bit-program-segmentation-fault/m-p/4997304#M776923</link>
      <description>TALLOC is wrapper for malloc (macros):&lt;BR /&gt;&lt;BR /&gt;#define MY_ALLOC(n,g)    malloc((unsigned)(n))&lt;BR /&gt;#define TALLOC(n,t,g)     (t*)MY_ALLOC((n)*sizeof(t),(g))&lt;BR /&gt;&lt;BR /&gt;I try to use malloc() without this wrapper -  also "Segmentation Fault".&lt;BR /&gt;</description>
      <pubDate>Tue, 15 Aug 2006 22:36:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/64-bit-program-segmentation-fault/m-p/4997304#M776923</guid>
      <dc:creator>Ravil Bikmukhametov</dc:creator>
      <dc:date>2006-08-15T22:36:56Z</dc:date>
    </item>
    <item>
      <title>Re: 64-bit program segmentation fault</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/64-bit-program-segmentation-fault/m-p/4997305#M776924</link>
      <description>Your ALLOC macros are rather scary. It appears that your TALLOC macro is kinda, sorta a calloc() but without calloc()'s implicit alignment. Consider allocating a array of odd-sized structs; you could have very serious alignment problems. In any event, I would make the compiler stop at the preprocess phase and have a look at how your macros are actually being instantiated.&lt;BR /&gt;</description>
      <pubDate>Tue, 15 Aug 2006 22:50:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/64-bit-program-segmentation-fault/m-p/4997305#M776924</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2006-08-15T22:50:52Z</dc:date>
    </item>
    <item>
      <title>Re: 64-bit program segmentation fault</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/64-bit-program-segmentation-fault/m-p/4997306#M776925</link>
      <description>aliases = TALLOC(1, struct alias, "alias");&lt;BR /&gt;&lt;BR /&gt;After preprocessing phase:&lt;BR /&gt;&lt;BR /&gt;aliases = (struct alias*)malloc((unsigned)((1)*sizeof(struct alias)));&lt;BR /&gt;</description>
      <pubDate>Tue, 15 Aug 2006 23:54:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/64-bit-program-segmentation-fault/m-p/4997306#M776925</guid>
      <dc:creator>Ravil Bikmukhametov</dc:creator>
      <dc:date>2006-08-15T23:54:11Z</dc:date>
    </item>
    <item>
      <title>Re: 64-bit program segmentation fault</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/64-bit-program-segmentation-fault/m-p/4997307#M776926</link>
      <description>Ok... so you're getting garbage from malloc() itself... which says to me "Corrupted the heap". Check the code before that point for double frees or buffer overrun/underruns.&lt;BR /&gt;&lt;BR /&gt;I think Purify would help here (&lt;A href="http://h21007.www2.hp.com/dspp/tech/tech_TechSoftwareDetailPage_IDX/1,1703,282,00.html)" target="_blank"&gt;http://h21007.www2.hp.com/dspp/tech/tech_TechSoftwareDetailPage_IDX/1,1703,282,00.html)&lt;/A&gt; - it looks like there's an evaluation period if you don't have it already and want to try it out. &lt;BR /&gt;&lt;BR /&gt;Barring that, I'd be looking at the flow of execution prior checking for double frees, buffer over or underruns.</description>
      <pubDate>Wed, 16 Aug 2006 10:52:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/64-bit-program-segmentation-fault/m-p/4997307#M776926</guid>
      <dc:creator>Don Morris_1</dc:creator>
      <dc:date>2006-08-16T10:52:38Z</dc:date>
    </item>
    <item>
      <title>Re: 64-bit program segmentation fault</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/64-bit-program-segmentation-fault/m-p/4997308#M776927</link>
      <description>I analyse the heap in program.&lt;BR /&gt;&lt;BR /&gt;-bash-3.00$ gdb pvm &lt;BR /&gt;Detected 64-bit executable.&lt;BR /&gt;Invoking /opt/langtools/bin/gdb64.&lt;BR /&gt;HP gdb 5.4.0 for PA-RISC 2.0 (wide), HP-UX 11.00&lt;BR /&gt;and target hppa2.0w-hp-hpux11.00.&lt;BR /&gt;Copyright 1986 - 2001 Free Software Foundation, Inc.&lt;BR /&gt;Hewlett-Packard Wildebeest 5.4.0 (based on GDB) is covered by the&lt;BR /&gt;GNU General Public License. Type "show copying" to see the conditions to&lt;BR /&gt;change it and/or distribute copies. Type "show warranty" for warranty/support.&lt;BR /&gt;..&lt;BR /&gt;(gdb) b 364 &lt;BR /&gt;Breakpoint 1 at 0x400000000000e958: file ../../console/cons.c, line 364 from /home/ravil/local/pvm/lib/hppa/pvm.&lt;BR /&gt;(gdb) set heap-check on &lt;BR /&gt;(gdb) r &lt;BR /&gt;Starting program: /home/ravil/local/pvm/lib/hppa/pvm &lt;BR /&gt;&lt;BR /&gt;Breakpoint 1, main (argc=1, argv=0x800003ff7fff0920) at ../../console/cons.c:364&lt;BR /&gt;364             aliases = (struct alias*)malloc(1*sizeof(struct alias));&lt;BR /&gt;Current language:  auto; currently c++&lt;BR /&gt;(gdb) n&lt;BR /&gt;365             BZERO((char*)aliases, sizeof(struct alias));&lt;BR /&gt;(gdb) info heap &lt;BR /&gt;Analyzing heap ...&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;48 bytes allocated in 1 blocks&lt;BR /&gt;&lt;BR /&gt;No.   Total bytes     Blocks         Address         Function&lt;BR /&gt;0        48             1       0x8000000100868c68   main()&lt;BR /&gt;(gdb) print aliases&lt;BR /&gt;$1 = (struct alias *) 0x868c68&lt;BR /&gt;(gdb) print sizeof(aliases)&lt;BR /&gt;$2 = 8&lt;BR /&gt;(gdb)&lt;BR /&gt;&lt;BR /&gt;malloc() work correctly, but assign wrong value to pointer (aliases)&lt;BR /&gt;If I manual set in gdb correct address (0x8000000100868c68) to pointer &lt;BR /&gt;(set aliases=0x8000000100868c68), program work  correctly (until next memory allocation)&lt;BR /&gt;&lt;BR /&gt;Where the problem?&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 16 Aug 2006 23:03:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/64-bit-program-segmentation-fault/m-p/4997308#M776927</guid>
      <dc:creator>Ravil Bikmukhametov</dc:creator>
      <dc:date>2006-08-16T23:03:41Z</dc:date>
    </item>
    <item>
      <title>Re: 64-bit program segmentation fault</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/64-bit-program-segmentation-fault/m-p/4997309#M776928</link>
      <description>Notice that the low-order 4 bytes are correct. It looks as though you have a type mismatch because the hi-order 4 bytes are being discarded.&lt;BR /&gt;</description>
      <pubDate>Wed, 16 Aug 2006 23:26:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/64-bit-program-segmentation-fault/m-p/4997309#M776928</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2006-08-16T23:26:05Z</dc:date>
    </item>
    <item>
      <title>Re: 64-bit program segmentation fault</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/64-bit-program-segmentation-fault/m-p/4997310#M776929</link>
      <description>..&lt;BR /&gt;(gdb) b 364 &lt;BR /&gt;Breakpoint 1 at 0x400000000000e948: file ../../console/cons.c, line 364 from /home/ravil/local/pvm/lib/hppa/pvm.&lt;BR /&gt;(gdb) set heap-check on &lt;BR /&gt;(gdb) r &lt;BR /&gt;Starting program: /home/ravil/local/pvm/lib/hppa/pvm &lt;BR /&gt;&lt;BR /&gt;Breakpoint 1, main (argc=1, argv=0x800003ff7fff0920) at ../../console/cons.c:364&lt;BR /&gt;364             printf("Malloc: 0x%lx\n",malloc(48));&lt;BR /&gt;Current language:  auto; currently c++&lt;BR /&gt;(gdb) n&lt;BR /&gt;Malloc: 0x8000000100868c88&lt;BR /&gt;365             unsigned long ptr = malloc(48);&lt;BR /&gt;(gdb) n&lt;BR /&gt;366             printf("Malloc: 0x%lx\n",ptr);&lt;BR /&gt;(gdb) n&lt;BR /&gt;Malloc: 0x86ad18&lt;BR /&gt;367             aliases = (struct alias*)malloc(1*sizeof(struct alias));&lt;BR /&gt;(gdb) print ptr&lt;BR /&gt;$1 = 8826136&lt;BR /&gt;(gdb) &lt;BR /&gt;&lt;BR /&gt;When I print malloc() return value, 64-bit value printed, if I at first assign malloc() return value to unsigned long variable, 32-bit value printed.&lt;BR /&gt;&lt;BR /&gt;Why so?&lt;BR /&gt;</description>
      <pubDate>Thu, 17 Aug 2006 00:18:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/64-bit-program-segmentation-fault/m-p/4997310#M776929</guid>
      <dc:creator>Ravil Bikmukhametov</dc:creator>
      <dc:date>2006-08-17T00:18:02Z</dc:date>
    </item>
    <item>
      <title>Re: 64-bit program segmentation fault</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/64-bit-program-segmentation-fault/m-p/4997311#M776930</link>
      <description>Did you include &lt;STDLIB.H&gt; in this file? (And when you compile, is there any warning about no definition for malloc, assuming return type of "int" perchance?&lt;BR /&gt;&lt;BR /&gt;If you don't include the proper header to define a function in C, the compilers will assume a return type of int. So malloc returns an int, which gets cast to an unsigned long (or a pointer) -- but you've already been truncated. [printf gets away with this due to the difference in how it uses argument definitions compared to lvalues... I don't remember details and its way too late to go look right now... ask on comp.lang.c if you want gory details...]&lt;BR /&gt;&lt;BR /&gt;To whit:&lt;BR /&gt;&lt;BR /&gt;# more bad.c&lt;BR /&gt;#include &lt;STDIO.H&gt;&lt;BR /&gt;&lt;BR /&gt;int&lt;BR /&gt;main(int argc, char *argv[])&lt;BR /&gt;{&lt;BR /&gt;        uintptr_t ptr = NULL;&lt;BR /&gt;&lt;BR /&gt;        printf("Malloc: 0x%lx\n", malloc(48));&lt;BR /&gt;&lt;BR /&gt;        ptr = malloc(48);&lt;BR /&gt;&lt;BR /&gt;        printf("ptr got: 0x%lx\n", ptr);&lt;BR /&gt;&lt;BR /&gt;        exit(0);&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;# cc +DD64 -o bad bad.c&lt;BR /&gt;# ./bad&lt;BR /&gt;Malloc: 0x80000001000042b0&lt;BR /&gt;ptr got: 0x6310&lt;BR /&gt;&lt;BR /&gt;# more good.c&lt;BR /&gt;#include &lt;STDIO.H&gt;&lt;BR /&gt;#include &lt;STDLIB.H&gt;&lt;BR /&gt;&lt;BR /&gt;int&lt;BR /&gt;main(int argc, char *argv[])&lt;BR /&gt;{&lt;BR /&gt;        uintptr_t ptr = NULL;&lt;BR /&gt;&lt;BR /&gt;        printf("Malloc: 0x%lx\n", malloc(48));&lt;BR /&gt;&lt;BR /&gt;        ptr = malloc(48);&lt;BR /&gt;&lt;BR /&gt;        printf("ptr got: 0x%lx\n", ptr);&lt;BR /&gt;&lt;BR /&gt;        exit(0);&lt;BR /&gt;}&lt;BR /&gt;# cc +DD64 -o good good.c&lt;BR /&gt;cc: "good.c", line 11: warning 526: Pointer implicitly converted to integral value in assignment.&lt;BR /&gt;# ./good&lt;BR /&gt;Malloc: 0x80000001000042b0&lt;BR /&gt;ptr got: 0x8000000100006310&lt;BR /&gt;&lt;BR /&gt;&lt;/STDLIB.H&gt;&lt;/STDIO.H&gt;&lt;/STDIO.H&gt;&lt;/STDLIB.H&gt;</description>
      <pubDate>Thu, 17 Aug 2006 00:29:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/64-bit-program-segmentation-fault/m-p/4997311#M776930</guid>
      <dc:creator>Don Morris_1</dc:creator>
      <dc:date>2006-08-17T00:29:20Z</dc:date>
    </item>
    <item>
      <title>Re: 64-bit program segmentation fault</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/64-bit-program-segmentation-fault/m-p/4997312#M776931</link>
      <description>Thank you very much for help.&lt;BR /&gt;&lt;BR /&gt;Insert #include &lt;STDLIB.H&gt; - work!!!&lt;BR /&gt;&lt;BR /&gt;&lt;/STDLIB.H&gt;</description>
      <pubDate>Thu, 17 Aug 2006 01:02:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/64-bit-program-segmentation-fault/m-p/4997312#M776931</guid>
      <dc:creator>Ravil Bikmukhametov</dc:creator>
      <dc:date>2006-08-17T01:02:42Z</dc:date>
    </item>
    <item>
      <title>Re: 64-bit program segmentation fault</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/64-bit-program-segmentation-fault/m-p/4997313#M776932</link>
      <description>Thank you all for help</description>
      <pubDate>Thu, 17 Aug 2006 01:05:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/64-bit-program-segmentation-fault/m-p/4997313#M776932</guid>
      <dc:creator>Ravil Bikmukhametov</dc:creator>
      <dc:date>2006-08-17T01:05:33Z</dc:date>
    </item>
    <item>
      <title>Re: 64-bit program segmentation fault</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/64-bit-program-segmentation-fault/m-p/4997314#M776933</link>
      <description>Ravil:&lt;BR /&gt;&lt;BR /&gt;I know the thread is closed and I will get no points for this, but I was going to add this comment yesterday before I got pulled away.&lt;BR /&gt;&lt;BR /&gt;1. Never cast the return of malloc/calloc calls.  This will mask the error you encountered every time.  The cast is not required.&lt;BR /&gt;&lt;BR /&gt;2. Always, always, always check the return from a molloc/calloc call to ensure that the call worked.</description>
      <pubDate>Thu, 17 Aug 2006 05:29:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/64-bit-program-segmentation-fault/m-p/4997314#M776933</guid>
      <dc:creator>Tom Henning</dc:creator>
      <dc:date>2006-08-17T05:29:59Z</dc:date>
    </item>
  </channel>
</rss>

