<?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: Can be r1 (gp) register overwritten by error in code? (run on Itanium with OpenVMS) in Operating System - OpenVMS</title>
    <link>https://community.hpe.com/t5/operating-system-openvms/can-be-r1-gp-register-overwritten-by-error-in-code-run-on/m-p/4489586#M42853</link>
    <description>&amp;gt;&amp;gt;&amp;gt;&lt;BR /&gt;DBG&amp;gt; show stack&lt;BR /&gt;Invocation block 0      Invocation handle 8786429167104&lt;BR /&gt;    GP:         0  &amp;lt;====================&lt;BR /&gt;...&lt;BR /&gt;Furthermore, R21 contains value of -2008616, what is FFFFFFFFFFE159D8 (virtual address where program crashes)&lt;BR /&gt;&amp;lt;&amp;lt;&amp;lt;&lt;BR /&gt;&lt;BR /&gt;Everything is fine except the contents of the GP. If you are wondering about the negative value in r21, that's because the add actually adds a negative number to zero. The compilers use short literals to get to addresses. Short means 22-bit sign-extended offsets, so add r21 = 2159D8, r1 is an add ffffffff.ffe159d8 to 0.&lt;BR /&gt;&lt;BR /&gt;How the GP got zeroed is the question. John had some answers. The previous GP, 4980736 (Hex = 004C0000) looks like a nice GP of a main image.&lt;BR /&gt;&lt;BR /&gt;Any ASTs involved? Not that I think they are the problem, but it looks like there is more going on than just some C code calling some other C code.&lt;BR /&gt;</description>
    <pubDate>Wed, 02 Sep 2009 15:30:45 GMT</pubDate>
    <dc:creator>H.Becker</dc:creator>
    <dc:date>2009-09-02T15:30:45Z</dc:date>
    <item>
      <title>Can be r1 (gp) register overwritten by error in code? (run on Itanium with OpenVMS)</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/can-be-r1-gp-register-overwritten-by-error-in-code-run-on/m-p/4489579#M42846</link>
      <description>&lt;!--!*#--&gt;Hello,&lt;BR /&gt;&lt;BR /&gt;below I pasted a piece of my function and related Instructions (unfortunatelly optimized) from dump analyzer.&lt;BR /&gt;&lt;BR /&gt;Register r21 is filled by adding constant (I guess position of gaul_trc_fld variable) and r1 (gp) register. It seems that r1 contains error value, because access to that memory causes "Access Violation". Is it possible? Can be r1 overwritten for example by buffer overflow or something like that?&lt;BR /&gt;&lt;BR /&gt;What I can not understand is that code crashes at instruction marked below just time to time. (Function is called many times per second, programs runs for example a week and then crashes).&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;21065: void queue_ev( T_MSG *pi_ar_msg,&lt;BR /&gt;               unsigned short pi_uw_event,&lt;BR /&gt;               unsigned short pi_uw_process,&lt;BR /&gt;               unsigned long pi_ul_cust,&lt;BR /&gt;               void *pi_ar_cust )&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;21072:    assert( pi_ar_msg != NULL );&lt;BR /&gt;&lt;BR /&gt;    /*&lt;BR /&gt;    ** Add the event to the queue:&lt;BR /&gt;    */&lt;BR /&gt;21077:    pi_ar_msg-&amp;gt;w_num_elem_queue++;&lt;BR /&gt;21078:    assert(pi_ar_msg-&amp;gt;w_num_elem_queue &amp;lt;= SIZE_QUEUE ); /* Should not happen */&lt;BR /&gt;&lt;BR /&gt;    /* Add to queue, when at end wrap around: */&lt;BR /&gt;21081:    pi_ar_msg-&amp;gt;w_last_elem_queue++;&lt;BR /&gt;21082:    if( pi_ar_msg-&amp;gt;w_last_elem_queue == SIZE_QUEUE )&lt;BR /&gt;    {&lt;BR /&gt;21084:        pi_ar_msg-&amp;gt;w_last_elem_queue = 0;&lt;BR /&gt;    }&lt;BR /&gt;&lt;BR /&gt;    /* Set the process and event: */&lt;BR /&gt;21088:    pi_ar_msg-&amp;gt;r_queue[pi_ar_msg-&amp;gt;w_last_elem_queue].uw_event   = pi_uw_event;&lt;BR /&gt;21089:    pi_ar_msg-&amp;gt;r_queue[pi_ar_msg-&amp;gt;w_last_elem_queue].uw_process = pi_uw_process;&lt;BR /&gt;21090:    pi_ar_msg-&amp;gt;r_queue[pi_ar_msg-&amp;gt;w_last_elem_queue].ul_cust    = pi_ul_cust;&lt;BR /&gt;21091:    pi_ar_msg-&amp;gt;r_queue[pi_ar_msg-&amp;gt;w_last_elem_queue].ar_cust    = pi_ar_cust;&lt;BR /&gt;    &lt;BR /&gt;21093:    if( ( (*gaul_trc_fld) &amp;amp; (gul_stm_msk) ) || ( (*gaul_trc_fld) &amp;amp; (0) )&lt;BR /&gt;{&lt;BR /&gt;   .....&lt;BR /&gt;&lt;BR /&gt;Some declarations:&lt;BR /&gt;unsigned long *gaul_trc_fld; &lt;BR /&gt;unsigned long gul_stm_msk;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt; 21065:        alloc       r38 = ar.pfs, 08, 08, 00&lt;BR /&gt;      :             mov         r37 = b0&lt;BR /&gt; 21072:        cmp4.eq     p7, p0 = r32, r0&lt;BR /&gt; 21065:        mov         r39 = r1&lt;BR /&gt; 21072:        (p7) br.cond.dpnt.few 0000010&lt;BR /&gt;      :             br.many     0000050 ;;&lt;BR /&gt;      :             add         r3 = 216560, r1&lt;BR /&gt;      :             add         r42 = 216550, r1&lt;BR /&gt;      :             mov         r25 = 000003 ;;&lt;BR /&gt;      :             ld8         r3 = [r3]&lt;BR /&gt;      :             ld8         r41 = [r42]&lt;BR /&gt;      :             mov         r42 = 0000FB ;;&lt;BR /&gt;      :             mov         r40 = r3&lt;BR /&gt;      :             nop.f       000000&lt;BR /&gt;      :             br.call.sptk.many b0 = 00AB8B0 ;;&lt;BR /&gt;      :             mov         r1 = r39&lt;BR /&gt;      :             nop.f       000000&lt;BR /&gt;      :             nop.i       000000&lt;BR /&gt; 21077:        mov         r3 = 0049CC&lt;BR /&gt;      :             mov         r8 = 0049CC&lt;BR /&gt; 21078:        mov         r9 = 0049CC ;;&lt;BR /&gt; 21077:        add         r3 = r32, r3&lt;BR /&gt;      :             add         r8 = r32, r8&lt;BR /&gt; 21078:        add         r9 = r32, r9 ;;&lt;BR /&gt; 21077:        ld2         r3 = [r3] ;;&lt;BR /&gt;      :             nop.m       000000&lt;BR /&gt;      :             sxt2        r3 = r3 ;;&lt;BR /&gt;      :             add         r3 = 0001, r3 ;;&lt;BR /&gt;      :             st2         [r8] = r3&lt;BR /&gt;      :             nop.i       000000 ;;&lt;BR /&gt; 21078:        ld2         r9 = [r9] ;;&lt;BR /&gt;      :             nop.m       000000&lt;BR /&gt;      :             sxt2        r9 = r9 ;;&lt;BR /&gt;      :             cmp.lt      p7, p0 = 19, r9&lt;BR /&gt;      :        (p7) br.cond.dpnt.few 0000010&lt;BR /&gt;      :             br.many     0000050 ;;&lt;BR /&gt;      :             add         r42 = 216550, r1&lt;BR /&gt;      :             add         r10 = 216568, r1&lt;BR /&gt;      :             mov         r25 = 000003 ;;&lt;BR /&gt;      :             ld8         r41 = [r42]&lt;BR /&gt;      :             ld8         r40 = [r10]&lt;BR /&gt;      :             mov         r42 = 000101&lt;BR /&gt;      :             nop.m       000000&lt;BR /&gt;      :             nop.f       000000&lt;BR /&gt;      :             br.call.sptk.many b0 = 00AB830 ;;&lt;BR /&gt;      :             mov         r1 = r39&lt;BR /&gt;      :             nop.f       000000&lt;BR /&gt;      :             nop.i       000000&lt;BR /&gt; 21081:        mov         r3 = 0049D0&lt;BR /&gt;      :             mov         r8 = 0049D0 ;;&lt;BR /&gt;      :             add         r3 = r32, r3&lt;BR /&gt;      :             add         r8 = r32, r8 ;;&lt;BR /&gt;      :             ld2         r3 = [r3]&lt;BR /&gt;      :             nop.i       000000 ;;&lt;BR /&gt;      :             nop.m       000000&lt;BR /&gt;      :             sxt2        r3 = r3 ;;&lt;BR /&gt;      :             add         r3 = 0001, r3 ;;&lt;BR /&gt;      :             nop.m       000000&lt;BR /&gt;      :             zxt2        r3 = r3 ;;&lt;BR /&gt; 21082:        cmp.eq      p0, p6 = 19, r3&lt;BR /&gt; 21081:        st2         [r8] = r3&lt;BR /&gt;      :             nop.f       000000&lt;BR /&gt; 21082:        (p6) br.cond.dpnt.few 0000030 ;;&lt;BR /&gt; 21084:        mov         r9 = 0049D0 ;;&lt;BR /&gt;      :             add         r9 = r32, r9&lt;BR /&gt;      :             nop.i       000000 ;;&lt;BR /&gt;      :             st2         [r9] = r0&lt;BR /&gt;      :             nop.f       000000&lt;BR /&gt;      :             nop.i       000000&lt;BR /&gt; 21088:        mov         r10 = 0049D0&lt;BR /&gt; 21093:        add         r21 = 2159D8, r1&lt;BR /&gt; 21088:        mov         r17 = 0049D4 ;;&lt;BR /&gt;      :             add         r10 = r32, r10&lt;BR /&gt; 21089:        mov         r18 = 0049D6&lt;BR /&gt; 21090:        mov         r19 = 0049D8&lt;BR /&gt; 21091:        mov         r20 = 0049DC ;;&lt;BR /&gt; 21088:        ld2         r44 = [r10]&lt;BR /&gt; 21093:        add         r22 = 215AF8, r1&lt;BR /&gt;      :             ld8         r21 = [r21] ;; &amp;lt;=============== %SYSTEM-F-ACCVIO, access violation, reason mask=00, virtual address=FFFFFFFFFFE159D8, PC=000000000014C800, PS=0000001B&lt;BR /&gt;break on unhandled exception at XXX_MISC\queue_ev\%LINE 21093+14&lt;BR /&gt;      :             ld8         r22 = [r22]&lt;BR /&gt; 21088:        sxt2        r45 = r44 ;;&lt;BR /&gt;      :             shladd      r11 = r45, 1, r45 ;;&lt;BR /&gt;      :             nop.m       000000&lt;BR /&gt;      :             sxt4        r11 = r11 ;;&lt;BR /&gt;      :             shladd      r11 = r11, 2, r32 ;;&lt;BR /&gt;      :             add         r17 = r11, r17&lt;BR /&gt; 21089:        add         r18 = r11, r18&lt;BR /&gt; 21090:        add         r19 = r11, r19&lt;BR /&gt; 21091:        add         r20 = r11, r20&lt;BR /&gt;      :             nop.i       000000 ;;&lt;BR /&gt; 21088:        st2         [r17] = r33&lt;BR /&gt; 21089:        st2         [r18] = r34&lt;BR /&gt;      :             nop.i       000000 ;;&lt;BR /&gt; 21090:        st4         [r19] = r35&lt;BR /&gt; 21091:        st4         [r20] = r36&lt;BR /&gt;      :             nop.i       000000 ;;&lt;BR /&gt; 21093:        ld4         r21 = [r21]&lt;BR /&gt;      :             ld4         r23 = [r22]&lt;BR /&gt;      :             nop.i       000000 ;;&lt;BR /&gt;      :             nop.m       000000&lt;BR /&gt;      :             sxt4        r21 = r21&lt;BR /&gt;      :             nop.b       000000 ;;&lt;BR /&gt;      :             ld4         r21 = [r21] ;;&lt;BR /&gt;      :             and         r21 = r21, r23&lt;BR /&gt;      :             nop.i       000000 ;;&lt;BR /&gt;      :             cmp4.eq     p9, p0 = r0, r21&lt;BR /&gt;      :             nop.f       000000&lt;BR /&gt;      :        (p9) br.cond.dpnt.few 00003A0 ;;</description>
      <pubDate>Tue, 01 Sep 2009 10:37:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/can-be-r1-gp-register-overwritten-by-error-in-code-run-on/m-p/4489579#M42846</guid>
      <dc:creator>Krax</dc:creator>
      <dc:date>2009-09-01T10:37:25Z</dc:date>
    </item>
    <item>
      <title>Re: Can be r1 (gp) register overwritten by error in code? (run on Itanium with OpenVMS)</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/can-be-r1-gp-register-overwritten-by-error-in-code-run-on/m-p/4489580#M42847</link>
      <description>Why are You guessing and fiddling with machine code, better use the source language debugger!&lt;BR /&gt;&lt;BR /&gt;Obviously the access violation happens at&lt;BR /&gt;if( ( (*gaul_trc_fld) &amp;amp; (gul_stm_msk) ) || ( (*gaul_trc_fld) &amp;amp; (0) )&lt;BR /&gt;when dereferencing the pointer gaul_trc_fld:&lt;BR /&gt;just the variable You don't show us.&lt;BR /&gt;look with the debugger at the content, and try to find out where it is set (with an invalid address).&lt;BR /&gt;</description>
      <pubDate>Tue, 01 Sep 2009 12:50:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/can-be-r1-gp-register-overwritten-by-error-in-code-run-on/m-p/4489580#M42847</guid>
      <dc:creator>Joseph Huber_1</dc:creator>
      <dc:date>2009-09-01T12:50:08Z</dc:date>
    </item>
    <item>
      <title>Re: Can be r1 (gp) register overwritten by error in code? (run on Itanium with OpenVMS)</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/can-be-r1-gp-register-overwritten-by-error-in-code-run-on/m-p/4489581#M42848</link>
      <description>Ok, so this is what looks to be a memory queue, this is likely involving an Integrity multiprocessor, it's transient, and you've hit a clobbered value.  &lt;BR /&gt;&lt;BR /&gt;My bet?  Contention.  I see no interlocking on that queue, which means the code is potentially vulnerable to contention.  &lt;BR /&gt;&lt;BR /&gt;What to do?  Switch to the C builtin.h interlocked queue routines, or to the analogous RTL queue calls, or set up spinlocks or such, or implement one of Knuth's algorithms existing code that ensure the queue access is "safe", or...&lt;BR /&gt;&lt;BR /&gt;If you want to test this stuff, hack this particular queue code out of the enveloping application code and build a skeleton that hammers on these queues from multiple threads or multiple processes.  Get rid of everything else in the application around this code that can reduce contention on these queues.  Let this stuff run full-tilt.&lt;BR /&gt;</description>
      <pubDate>Tue, 01 Sep 2009 12:51:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/can-be-r1-gp-register-overwritten-by-error-in-code-run-on/m-p/4489581#M42848</guid>
      <dc:creator>Hoff</dc:creator>
      <dc:date>2009-09-01T12:51:44Z</dc:date>
    </item>
    <item>
      <title>Re: Can be r1 (gp) register overwritten by error in code? (run on Itanium with OpenVMS)</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/can-be-r1-gp-register-overwritten-by-error-in-code-run-on/m-p/4489582#M42849</link>
      <description>And yes, since it happens only somtime, the pointer variable has been filled with a wrong/invalid address, could well be by buffer overflow or array index violation.&lt;BR /&gt;&lt;BR /&gt;Compile with CC/NOOPT/CHECK=(BOUNDS)/DEBUG and hope to catch the error (if using dimensioned arrays, not only pointers).&lt;BR /&gt;&lt;BR /&gt;But any other language but C is probably better in avoiding such errors...</description>
      <pubDate>Tue, 01 Sep 2009 12:59:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/can-be-r1-gp-register-overwritten-by-error-in-code-run-on/m-p/4489582#M42849</guid>
      <dc:creator>Joseph Huber_1</dc:creator>
      <dc:date>2009-09-01T12:59:28Z</dc:date>
    </item>
    <item>
      <title>Re: Can be r1 (gp) register overwritten by error in code? (run on Itanium with OpenVMS)</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/can-be-r1-gp-register-overwritten-by-error-in-code-run-on/m-p/4489583#M42850</link>
      <description>ps: This sort of stuff is a bit more involved to implement on OpenVMS than on other platforms (and Itanium isn't "fun" for multithreading; see the KP Threads services if that requirement is involved here), but OpenVMS has one tool that can be brought to bear here: program the OpenVMS Debugger to break on the failing code and conditionally check for the corruption or error (preferably within the test harness mentioned earlier), and turn it loose waiting for the corruption to arise.  But again, queues need to be interlocked or bad things happen when contention arises.</description>
      <pubDate>Tue, 01 Sep 2009 13:45:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/can-be-r1-gp-register-overwritten-by-error-in-code-run-on/m-p/4489583#M42850</guid>
      <dc:creator>Hoff</dc:creator>
      <dc:date>2009-09-01T13:45:47Z</dc:date>
    </item>
    <item>
      <title>Re: Can be r1 (gp) register overwritten by error in code? (run on Itanium with OpenVMS)</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/can-be-r1-gp-register-overwritten-by-error-in-code-run-on/m-p/4489584#M42851</link>
      <description>So are you sure that is really the failing instruction?  The GP is saved into R39 in the prologue and restored back to R1 after the external routine calls.  Unfortunately, since you can't reproduce it everytime, it would be interesting to see what is really in R1 (although you can reverse engineer that with the failing VA).&lt;BR /&gt;&lt;BR /&gt;So how could R39 get trashed?  The only way I can think of is that the called routines (which call other routines, etc.) eventually use enough registers that the R39 from this frame eventually got pushed out to the register backing store.  In theory, you could trash it there and eventually when it gets reloaded back into the chip and finally back into the frame when the routine returns, the saved R1 in R39 is the wrong value.  That said, I've never seen such a failure.  The register backing store isn't anywhere near the rest of your data or the memory stack. &lt;BR /&gt;&lt;BR /&gt;Of course, there could be a bug in the OS (notably SWIS) dealing with saved register values, etc.   Did you say what version of OpenVMS you are running and what ECOs you have installed?  Did you say what version of the compiler you are running?&lt;BR /&gt;&lt;BR /&gt;For those confused, the real fetches of the user data (ie, the pointers) occur later in the instruction stream as:&lt;BR /&gt;&lt;BR /&gt;ld4 r21 = [r21]&lt;BR /&gt;ld4 r23 = [r22]&lt;BR /&gt;</description>
      <pubDate>Tue, 01 Sep 2009 18:49:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/can-be-r1-gp-register-overwritten-by-error-in-code-run-on/m-p/4489584#M42851</guid>
      <dc:creator>John Reagan</dc:creator>
      <dc:date>2009-09-01T18:49:49Z</dc:date>
    </item>
    <item>
      <title>Re: Can be r1 (gp) register overwritten by error in code? (run on Itanium with OpenVMS)</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/can-be-r1-gp-register-overwritten-by-error-in-code-run-on/m-p/4489585#M42852</link>
      <description>&lt;!--!*#--&gt;Hi John,&lt;BR /&gt;&lt;BR /&gt;OpenVMS debugger/analyzer marked this instruction with small triangle on the left.&lt;BR /&gt;&lt;BR /&gt;Thank you for confirming that it crashes before accessing referenced data, i.e. it crashes at reading pointer value and not referenced data.&lt;BR /&gt;&lt;BR /&gt;It is compiled with: HP C V7.2-022 on OpenVMS IA64 V8.3. &lt;BR /&gt;I have been trying to find out information on system where it crashed. I will supply this information when I find it out.&lt;BR /&gt;&lt;BR /&gt;Other strange thing that I dug out from analyzer:&lt;BR /&gt;&lt;BR /&gt;DBG&amp;gt; show stack&lt;BR /&gt;Invocation block 0      Invocation handle 8786429167104&lt;BR /&gt;    GP:         0  &amp;lt;====================&lt;BR /&gt;    PC:         XXX_MISC\queue_ev\%LINE 21093+14&lt;BR /&gt;    RETURN PC:  XXX_MISC\queue_event\%LINE 21058+14&lt;BR /&gt;    SP:         2059492768&lt;BR /&gt;    BSP:        8786429167104&lt;BR /&gt;    Is register stack frame:&lt;BR /&gt;        previous BSP:   8786429167056&lt;BR /&gt;    CFM:        1040&lt;BR /&gt;        Ins/Locals R32:R39      Outs R40:R47&lt;BR /&gt;Invocation block 1      Invocation handle 8786429167056&lt;BR /&gt;    GP:         4980736&lt;BR /&gt;    PC:         XXX_MISC\tcap_queue_event\%LINE 21058+14&lt;BR /&gt;    RETURN PC:  XXX_TO\to_data\%LINE 21622+16&lt;BR /&gt;    SP:         2059492768&lt;BR /&gt;    BSP:        8786429167056&lt;BR /&gt;    Is register stack frame:&lt;BR /&gt;        previous BSP:   8786429166960&lt;BR /&gt;    CFM:        650&lt;BR /&gt;        Ins/Locals R32:R36      Outs R37:R41&lt;BR /&gt;&lt;BR /&gt;Contents of GP is really... "interesting". R39 contains 0 as well.&lt;BR /&gt;&lt;BR /&gt;Furthermore, R21 contains value of -2008616, what is FFFFFFFFFFE159D8 (virtual address where program crashes)&lt;BR /&gt;&lt;BR /&gt;Any ideas?</description>
      <pubDate>Wed, 02 Sep 2009 14:01:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/can-be-r1-gp-register-overwritten-by-error-in-code-run-on/m-p/4489585#M42852</guid>
      <dc:creator>Krax</dc:creator>
      <dc:date>2009-09-02T14:01:06Z</dc:date>
    </item>
    <item>
      <title>Re: Can be r1 (gp) register overwritten by error in code? (run on Itanium with OpenVMS)</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/can-be-r1-gp-register-overwritten-by-error-in-code-run-on/m-p/4489586#M42853</link>
      <description>&amp;gt;&amp;gt;&amp;gt;&lt;BR /&gt;DBG&amp;gt; show stack&lt;BR /&gt;Invocation block 0      Invocation handle 8786429167104&lt;BR /&gt;    GP:         0  &amp;lt;====================&lt;BR /&gt;...&lt;BR /&gt;Furthermore, R21 contains value of -2008616, what is FFFFFFFFFFE159D8 (virtual address where program crashes)&lt;BR /&gt;&amp;lt;&amp;lt;&amp;lt;&lt;BR /&gt;&lt;BR /&gt;Everything is fine except the contents of the GP. If you are wondering about the negative value in r21, that's because the add actually adds a negative number to zero. The compilers use short literals to get to addresses. Short means 22-bit sign-extended offsets, so add r21 = 2159D8, r1 is an add ffffffff.ffe159d8 to 0.&lt;BR /&gt;&lt;BR /&gt;How the GP got zeroed is the question. John had some answers. The previous GP, 4980736 (Hex = 004C0000) looks like a nice GP of a main image.&lt;BR /&gt;&lt;BR /&gt;Any ASTs involved? Not that I think they are the problem, but it looks like there is more going on than just some C code calling some other C code.&lt;BR /&gt;</description>
      <pubDate>Wed, 02 Sep 2009 15:30:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/can-be-r1-gp-register-overwritten-by-error-in-code-run-on/m-p/4489586#M42853</guid>
      <dc:creator>H.Becker</dc:creator>
      <dc:date>2009-09-02T15:30:45Z</dc:date>
    </item>
    <item>
      <title>Re: Can be r1 (gp) register overwritten by error in code? (run on Integrity with OpenVMS)</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/can-be-r1-gp-register-overwritten-by-error-in-code-run-on/m-p/4489587#M42854</link>
      <description>&lt;P&gt;&amp;gt;Can be r1 overwritten for example by buffer overflow or something like that?&lt;BR /&gt;&lt;BR /&gt;(My experience is for HP-UX.)&lt;BR /&gt;It would be very hard to do. The registers are typically saved in the RSE stack, not the user stack.&lt;BR /&gt;GP: 0&lt;BR /&gt;SP: 2059492768&lt;BR /&gt;BSP: 8786429167104&lt;BR /&gt;(It would be better if this was in hex.)&lt;BR /&gt;&lt;BR /&gt;&amp;gt;Contents of GP is really... "interesting". R39 contains 0 as well.&lt;BR /&gt;&lt;BR /&gt;This isn't good. r1 was bad when this function was called. You need to look there.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;Joseph: Why are You guessing and fiddling with machine code, better use the source language debugger!&lt;BR /&gt;&lt;BR /&gt;This is a case to look for zebras, not horses. ;-)&lt;BR /&gt;A horse tool isn't likely to find why r1 is 0.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;John: since you can't reproduce it every time, it would be interesting to see what is really in R1&lt;BR /&gt;&lt;BR /&gt;On HP-UX, I found where BOR calls weren't thread safe and corrupted R1. I was lucky to guess the cause, for something that occurred very infrequently. Fixes had to be made in the compiler, linker and dld. With an extra change in the linker to help detect if the other two weren't fixed, setting dummy GP to -1.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;I've never seen such a failure. The register backing store isn't anywhere near the rest of your data or the memory stack.&lt;BR /&gt;&lt;BR /&gt;You haven't lived long enough. ;-)&lt;BR /&gt;I had an example where a move was reversed and shuffled the whole stack down.&lt;BR /&gt;Also a thread stack overflow would do it.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;H.Becker: Short means 22-bit sign-extended offsets, so add r21 = 2159D8, r1 is an add ffffffff.ffe159d8 to 0.&lt;BR /&gt;&lt;BR /&gt;Actually it means the disassembler is broken. All literals should be signed extended to 64 bits, to make it easier to understand.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;The previous GP, 0x004C0000, looks like a nice GP of a main image.&lt;BR /&gt;&lt;BR /&gt;On HP-UX, when (possibly) transferring from one load module to another, the PC and GP are fetched from the Procedure Linkage Table and if this is overwritten, bad things can happen. But typically both are corrupted so you end up in an invalid location, not the right location but wrong GP.&lt;/P&gt;</description>
      <pubDate>Sat, 31 Mar 2012 08:38:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/can-be-r1-gp-register-overwritten-by-error-in-code-run-on/m-p/4489587#M42854</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2012-03-31T08:38:59Z</dc:date>
    </item>
    <item>
      <title>Re: Can be r1 (gp) register overwritten by error in code? (run on Itanium with OpenVMS)</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/can-be-r1-gp-register-overwritten-by-error-in-code-run-on/m-p/4489588#M42855</link>
      <description>&lt;!--!*#--&gt;Hi Dennis,&lt;BR /&gt;&lt;BR /&gt;thank you for valuable comments.&lt;BR /&gt;&lt;BR /&gt;Calling function is located in the same module as function where crash occurs. There is an output of "show stack" in my previous post - you can see that GP was fine when queue_ev function was called.&lt;BR /&gt;&lt;BR /&gt;Calling function looks very simple:&lt;BR /&gt;&lt;BR /&gt;21054: void queue_event( T_MSG *pi_ar_imsg,&lt;BR /&gt;                       unsigned short pi_uw_event,&lt;BR /&gt;                       unsigned short pi_uw_process )&lt;BR /&gt;       {&lt;BR /&gt;21058:     queue_ev( pi_ar_imsg,&lt;BR /&gt;21059:                  pi_uw_event,&lt;BR /&gt;21060:                  pi_uw_process,&lt;BR /&gt;21061:                  0,&lt;BR /&gt;21062:                  NULL );&lt;BR /&gt;21063:  }&lt;BR /&gt;&lt;BR /&gt;And related instructions:&lt;BR /&gt;&lt;BR /&gt; 21054:        alloc       r36 = ar.pfs, 05, 05, 00&lt;BR /&gt; 21059:        mov         r8 = 00FFFF&lt;BR /&gt; 21054:        mov         r35 = b0 ;;&lt;BR /&gt; 21058:        mov         r41 = r0&lt;BR /&gt;      :             mov         r40 = 000000&lt;BR /&gt;      :             mov         r37 = r32&lt;BR /&gt; 21060:        and         r39 = r34, r8 ;;&lt;BR /&gt; 21059:        and         r38 = r33, r8&lt;BR /&gt;      :             nop.i       000000&lt;BR /&gt;      :             nop.m       000000&lt;BR /&gt;      :             nop.f       000000&lt;BR /&gt; 21058:        br.call.sptk.many b0 = 0000030 ;;&lt;BR /&gt;      :             nop.m       000000&lt;BR /&gt; 21063:        mov.i       ar.pfs = r36 ;;&lt;BR /&gt;      :             mov         b0 = r35&lt;BR /&gt;      :             nop.m       000000&lt;BR /&gt;      :             nop.f       000000&lt;BR /&gt;      :             br.ret.sptk.many b0 ;;&lt;BR /&gt;      &lt;BR /&gt;I don't see anything what could get wrong, what could corrupt GP. &lt;BR /&gt;&lt;BR /&gt;Some information about target system:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; tcpip sh ver&lt;BR /&gt;&lt;BR /&gt;HP TCP/IP Services for OpenVMS Industry Standard 64 Version V5.6 - ECO 2   on an HP BL860c  (1.59GHz/9.0MB) running OpenVMS V8.3-1H1&lt;BR /&gt;&lt;BR /&gt;&amp;gt; product sh hist&lt;BR /&gt;&lt;BR /&gt;------------------------------------ ----------- ----------- --- -----------&lt;BR /&gt;PRODUCT                              KIT TYPE    OPERATION   VAL DATE&lt;BR /&gt;------------------------------------ ----------- ----------- --- -----------&lt;BR /&gt;HP I64VMS OVPA V4.0-37               Full LP     Install     (U) 13-FEB-2009&lt;BR /&gt;HP I64VMS OVPA V4.0-37               Full LP     Install     (U) 11-FEB-2009&lt;BR /&gt;HP I64VMS OVPA V4.0-37               Full LP     Install     (U) 30-JAN-2009&lt;BR /&gt;HP I64VMS OVPA V4.0-37               Full LP     Install     (U) 30-JAN-2009&lt;BR /&gt;HP I64VMS VMSSPI V8.0-1              Full LP     Install     Val 23-OCT-2008&lt;BR /&gt;HP I64VMS OVEAAGT V8.0-1             Full LP     Install     Val 23-OCT-2008&lt;BR /&gt;HP I64VMS OVCTRL V8.0-1              Full LP     Install     Val 23-OCT-2008&lt;BR /&gt;HP I64VMS OVDEPL V8.0-1              Full LP     Install     Val 23-OCT-2008&lt;BR /&gt;HP I64VMS OVSECCC V8.0-1             Full LP     Install     Val 23-OCT-2008&lt;BR /&gt;HP I64VMS OVBBC V8.0-1               Full LP     Install     Val 23-OCT-2008&lt;BR /&gt;HP I64VMS OVSECCO V8.0-1             Full LP     Install     Val 23-OCT-2008&lt;BR /&gt;HP I64VMS OVCONF V8.0-1              Full LP     Install     Val 23-OCT-2008&lt;BR /&gt;HP I64VMS OVXPL V8.0-1               Full LP     Install     Val 23-OCT-2008&lt;BR /&gt;HP I64VMS SEA V5.1                   Full LP     Install     (U) 06-JUN-2008&lt;BR /&gt;HP I64VMS WEBES V5.1                 Platform    Install     (U) 06-JUN-2008&lt;BR /&gt;HP I64VMS WCCPROXY V2.1              Full LP     Install     (U) 06-JUN-2008&lt;BR /&gt;HP I64VMS VMS831H1I_UPDATE V1.0      Patch       Install     Val 25-MAR-2008&lt;BR /&gt;HP I64VMS AVAIL_MAN_BASE V8.3-1H1    Full LP     Install     (U) 06-NOV-2007&lt;BR /&gt;HP I64VMS CDSA V2.3-306              Full LP     Install     Val 06-NOV-2007&lt;BR /&gt;HP I64VMS DECNET_PLUS V8.3-1H1       Full LP     Install     Val 06-NOV-2007&lt;BR /&gt;HP I64VMS DWMOTIF_SUPPORT V8.3-1H1   Full LP     Install     (U) 06-NOV-2007&lt;BR /&gt;HP I64VMS KERBEROS V3.1-152          Full LP     Install     Val 06-NOV-2007&lt;BR /&gt;HP I64VMS OPENVMS V8.3-1H1           Platform    Install     Sys 06-NOV-2007&lt;BR /&gt;HP I64VMS TCPIP V5.6-9ECO2           Full LP     Install     Val 06-NOV-2007&lt;BR /&gt;HP I64VMS TDC_RT V2.3-1              Full LP     Install     Val 06-NOV-2007&lt;BR /&gt;HP I64VMS VMS V8.3-1H1               Oper System Install     Sys 06-NOV-2007&lt;BR /&gt;HP I64VMS WBEMCIM V2.61-A070728      Full LP     Install     Val 06-NOV-2007&lt;BR /&gt;HP I64VMS WBEMPROVIDERS V1.5-31      Full LP     Install     Val 06-NOV-2007&lt;BR /&gt;HP I64VMS DWMOTIF_ECO01 V1.6         Patch       Install     Val 04-APR-2007&lt;BR /&gt;JFP I64VMS PYTHON250 V1.18-0         Full LP     Install     (U) 02-MAR-2007&lt;BR /&gt;JFP I64VMS ZLIB V1.2-3               Full LP     Install     (U) 02-MAR-2007&lt;BR /&gt;JFP I64VMS LIBBZ2 V1.0-2             Full LP     Install     (U) 02-MAR-2007&lt;BR /&gt;HP I64VMS MSA_UTIL V1.0-1            Full LP     Install     Val 05-FEB-2007&lt;BR /&gt;HP I64VMS DFU V3.1-1                 Full LP     Install     (U) 17-AUG-2006&lt;BR /&gt;HP I64VMS DWMOTIF V1.6               Full LP     Install     Val 14-AUG-2006&lt;BR /&gt;HP I64VMS SSL V1.3-284               Full LP     Install     Val 14-AUG-2006&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 11 Sep 2009 13:24:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/can-be-r1-gp-register-overwritten-by-error-in-code-run-on/m-p/4489588#M42855</guid>
      <dc:creator>Krax</dc:creator>
      <dc:date>2009-09-11T13:24:43Z</dc:date>
    </item>
    <item>
      <title>Re: Can be r1 (gp) register overwritten by error in code? (run on Itanium with OpenVMS)</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/can-be-r1-gp-register-overwritten-by-error-in-code-run-on/m-p/4489589#M42856</link>
      <description>&amp;gt;&amp;gt;&amp;gt;&lt;BR /&gt;On HP-UX, when (possibly) transferring from one load module to another, the&lt;BR /&gt;PC and GP are fetched from the Procedure Linkage Table and of this is&lt;BR /&gt;overwritten, bad things can happen. But typically both are corrupted so you&lt;BR /&gt;end up in an invalid location, not the right location but wrong GP.&lt;BR /&gt;&amp;lt;&amp;lt;&amp;lt;&lt;BR /&gt;Later info states that the shown functions are in one module. On VMS this is usually a source or object module, which is linked into one image. On VMS, when transferring from one image to another image PC and GP are fetched from function descriptors in short data. By default function descriptors live in read-only memory. Only explicitly linking with /segment=short=write makes them (and other linker generated  short data) writable.&lt;BR /&gt;</description>
      <pubDate>Fri, 11 Sep 2009 20:33:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/can-be-r1-gp-register-overwritten-by-error-in-code-run-on/m-p/4489589#M42856</guid>
      <dc:creator>H.Becker</dc:creator>
      <dc:date>2009-09-11T20:33:27Z</dc:date>
    </item>
    <item>
      <title>Re: Can be r1 (gp) register overwritten by error in code? (run on Itanium with OpenVMS)</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/can-be-r1-gp-register-overwritten-by-error-in-code-run-on/m-p/4489590#M42857</link>
      <description>&amp;gt;you can see that GP was fine when queue_ev function was called.&lt;BR /&gt;&lt;BR /&gt;On HP-UX GP isn't part of the unwind info so it can't be restored.  While doing exception handling, the unwinder can look search the module table by PC and then get a value.  Perhaps the debugger is displaying what it should be and for the top frame what's actually there?&lt;BR /&gt;&lt;BR /&gt;&amp;gt;Calling function looks very simple:&lt;BR /&gt;&lt;BR /&gt;Yes, very simple.&lt;BR /&gt;&lt;BR /&gt;&amp;gt; 21058: br.call.sptk.many b0 = 0000030 ;;&lt;BR /&gt;&lt;BR /&gt;You might want to display the value of GP before the call and single step at the instruction level to watch how GP changes.&lt;BR /&gt;&lt;BR /&gt;Is it actually going to 0x30, is this a broken disassembler that doesn't show the actual target, just the offset?&lt;BR /&gt;&lt;BR /&gt;&amp;gt;H.Becker: By default function descriptors live in read-only memory.&lt;BR /&gt;&lt;BR /&gt;On HP-UX this can't occur since these can be dynamically changed at loadtime and the dynamic loader needs to modify them.</description>
      <pubDate>Sat, 12 Sep 2009 03:26:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/can-be-r1-gp-register-overwritten-by-error-in-code-run-on/m-p/4489590#M42857</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-09-12T03:26:27Z</dc:date>
    </item>
    <item>
      <title>Re: Can be r1 (gp) register overwritten by error in code? (run on Itanium with OpenVMS)</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/can-be-r1-gp-register-overwritten-by-error-in-code-run-on/m-p/4489591#M42858</link>
      <description>&amp;gt;&amp;gt;&amp;gt;&lt;BR /&gt;On HP-UX this can't occur since these can be dynamically changed at loadtime and the dynamic loader needs to modify them.&lt;BR /&gt;&amp;lt;&amp;lt;&amp;lt;&lt;BR /&gt;On VMS, the corresponding changes (fixups and relocations) are done in inner mode. Before tranferring control to the program, the pages are set to read-only.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;&amp;gt;&amp;gt;&lt;BR /&gt;On HP-UX GP isn't part of the unwind info so it can't be restored. While doing exception handling, the unwinder can look search the module table by PC and then get a value. Perhaps the debugger is displaying what it should be and for the top frame what's actually there?&lt;BR /&gt;&amp;lt;&amp;lt;&amp;lt;&lt;BR /&gt;This isn't different on VMS, the GP is not in the unwind info. I don't know what the debugger shows, but it seems to behave as you describe.&lt;BR /&gt;&lt;BR /&gt;It looks like it uses r1 for the current call stack and the (image) GP for the other call &lt;BR /&gt;stacks in this image. A simple example where I zeroed r1 before calling other functions supports this assumption: SHOW STACK only shows the zero for the current, top call stack,&lt;BR /&gt;&lt;BR /&gt;So the GP of the caller looks good in the SHOW STACK output, but may already be zero for the caller.&lt;BR /&gt;</description>
      <pubDate>Mon, 14 Sep 2009 20:04:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/can-be-r1-gp-register-overwritten-by-error-in-code-run-on/m-p/4489591#M42858</guid>
      <dc:creator>H.Becker</dc:creator>
      <dc:date>2009-09-14T20:04:27Z</dc:date>
    </item>
    <item>
      <title>Re: Can be r1 (gp) register overwritten by error in code? (run on Itanium with OpenVMS)</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/can-be-r1-gp-register-overwritten-by-error-in-code-run-on/m-p/4489592#M42859</link>
      <description>&amp;gt;H.Becker: Before transferring control to the program, the pages are set to read-only.&lt;BR /&gt;&lt;BR /&gt;Ah, we have an option +protect to do that.  It would have to align on page boundaries to do mprotect(2), so it isn't done by default.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;So the GP of the caller looks good in the SHOW STACK output, but may already be zero for the caller.&lt;BR /&gt;&lt;BR /&gt;So the debugger is showing you what you want to see but not what it is.  :-)&lt;BR /&gt;So looking at the caller and the caller's caller may be helpful.&lt;BR /&gt;(gdb's info shared will show the GPs and addresses for each shlib.)</description>
      <pubDate>Mon, 14 Sep 2009 21:27:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/can-be-r1-gp-register-overwritten-by-error-in-code-run-on/m-p/4489592#M42859</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-09-14T21:27:37Z</dc:date>
    </item>
  </channel>
</rss>

