From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1688 invoked by alias); 14 Feb 2005 19:00:02 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 1542 invoked by uid 48); 14 Feb 2005 18:59:52 -0000 Date: Mon, 14 Feb 2005 20:54:00 -0000 From: "sciance at gdls dot com" To: gcc-bugs@gcc.gnu.org Message-ID: <20050214185948.19957.sciance@gdls.com> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug c++/19957] New: Exception with Tornado C++ on PowerPC target X-Bugzilla-Reason: CC X-SW-Source: 2005-02/txt/msg01483.txt.bz2 List-Id: I get a data access exception running the following test driver on PowerPC 750 target board with VxWorks 5.4.2. The test driver is compiled with -O0 (no optimization) and -mlongcall. // This test driver reproduces the exception. static int b=0; static int a=0; enum Enumeration1 { MSG_NULL , MSG1 , MSG2 , MSG3 , MSG4 , MSG5 , MSG_TOTAL }; void doTest (void); // This struct is similar to the RoseRT RTTypedValue_Enumeration1, // except that type is int * instead of RTObject_class *. struct RTTypedValue_Enumeration1 { const void * data; const int * type; inline RTTypedValue_Enumeration1( const Enumeration1 & rtg_value, const int * rtg_type ) : data( &rtg_value ), type( rtg_type = &b) { } inline ~RTTypedValue_Enumeration1( void ) { } }; void doTest (void) { int j; Enumeration1 enumValue = MSG_NULL; for (int i = (MSG_NULL + 1); i < MSG_TOTAL; i++) { enumValue = (Enumeration1)i; j=1234; { // This gets the exception in VxWorks (2nd iteration of loop). RTTypedValue_Enumeration1 enumMsg( enumValue, &a); } j=5678; } } int main(void) { doTest(); } Something about calling the constructor inside a loop causes the exception. The exception does not occur if the code is not compiled with -mlongcall or if the code is compiled with optimization -O1 or higher. I am running the Wind River Tornado version 2.0.2 fork of the gnu compiler. This test driver is a simplified version of a bug we get with Rational Rose RealTime model built with Tornado gnu compiler, sending a signal in a loop. Can you tell me if this is a bug that has been fixed in gcc versions more recent than the Wind River Tornado fork? Below is the test1.s PowerPC assembly language generated by compiling with - save-temps. The bug is that register r29 is OK the first iteration of the loop, but r29 is modified and causes an exception on the second iteration of the loop. # GNU C++ cygnus-2.7.2-960126 egcs-971225 tornado 2.0 spr29516 # -fvolatile -fpeephole -ffunction-cse -fkeep-static-consts # -fpcc-struct-return -fexceptions -fsjlj-exceptions -fcommon -fgnu-linker # -mpowerpc -mnew-mnemonics -mlongcall -mstrict-align .file "test1.cpp" .stabs "/Tmp/Tornado/PPC604gnu/",100,0,0,.Ltext0 .stabs "C:/Tmp/Tornado/test1.cpp",100,0,0,.Ltext0 .section ".text" .Ltext0: .stabs "gcc2_compiled.", 0x3c, 0, 0, 0 .stabs "int:t(0,1)=r(0,1);-2147483648;2147483647;",128,0,0,0 .stabs "char:t(0,2)=r(0,2);0;255;",128,0,0,0 .stabs "long int:t(0,3)=r(0,3);-2147483648;2147483647;",128,0,0,0 .stabs "unsigned int:t(0,4)=r(0,4);0;-1;",128,0,0,0 .stabs "long unsigned int:t(0,5)=r(0,5);0;-1;",128,0,0,0 .stabs "long long int:t(0,6)=r (0,1);01000000000000000000000;0777777777777777777777;",128,0,0,0 .stabs "long long unsigned int:t(0,7)=r (0,1);0000000000000;01777777777777777777777;",128,0,0,0 .stabs "short int:t(0,8)=r(0,8);-32768;32767;",128,0,0,0 .stabs "short unsigned int:t(0,9)=r(0,9);0;65535;",128,0,0,0 .stabs "signed char:t(0,10)=r(0,10);-128;127;",128,0,0,0 .stabs "unsigned char:t(0,11)=r(0,11);0;255;",128,0,0,0 .stabs "float:t(0,12)=r(0,1);4;0;",128,0,0,0 .stabs "double:t(0,13)=r(0,1);8;0;",128,0,0,0 .stabs "long double:t(0,14)=r(0,1);8;0;",128,0,0,0 .stabs "complex int:t(0,15)=s8real:(0,1),0,32;imag:(0,1),32,32;;",128,0,0,0 .stabs "complex float:t(0,16)=r(0,16);4;0;",128,0,0,0 .stabs "complex double:t(0,17)=r(0,17);8;0;",128,0,0,0 .stabs "complex long double:t(0,18)=r(0,18);8;0;",128,0,0,0 .stabs "bool:t(0,19)=@s32;-16;",128,0,0,0 .stabs "void:t(0,20)=(0,20)",128,0,0,0 .stabs "__wchar_t:t(0,21)=r(0,21);0;65535;",128,0,0,0 .stabs "__vtbl_ptr_type:T(0,22)=s8__delta:(0,8),0,16;__index: (0,8),16,16;\\",128,0,0,0 .stabs "__pfn:(0,23)=*(0,20),32,32;__delta2:(0,8),32,16;;",128,0,0,0 .stabs "__vtbl_ptr_type:t(0,22)",128,0,0,0 .section ".data" .stabs "b:S(0,1)",38,0,3,b .align 2 .type b,@object .size b,4 b: .long 0 .stabs "a:S(0,1)",38,0,4,a .align 2 .type a,@object .size a,4 a: .long 0 .stabs "Enumeration1:t(0,24)=eMSG_NULL:0,MSG1:1,MSG2:2,\\",128,0,0,0 .stabs "MSG3:3,MSG4:4,MSG5:5,MSG_TOTAL:6,;",128,0,9,0 .stabs "RTTypedValue_Enumeration1:T(0,25)=s8data:(0,26)=* (0,20),0,32;\\",128,0,0,0 .stabs "type:(0,27)=*(0,1),32,32;__as::(0,28)=##(0,29)=& (0,25);:RC25RTTypedValue_Enumeration1;2A.;\\",128,0,0,0 .stabs "RTTypedValue_Enumeration1::(0,30)=##(0,31)=* (0,25);:RC25RTTypedValue_Enumeration1;2A.\\",128,0,0,0 .stabs "(0,32)=##(0,31);:RC12Enumeration1PCi;2A.(0,33)=#(0,25),(0,20),(0,31), (0,1),(0,20);:_$_25RTTypedValue_Enumeration1;2A.;;",128,0,0,0 .stabs "RTTypedValue_Enumeration1:Tt(0,25)",128,0,32,0 .section ".text" .align 2 .stabs "doTest__Fv:F(0,20)",36,0,37,doTest__Fv .globl doTest__Fv .type doTest__Fv,@function doTest__Fv: .stabn 68,0,37,.LM1-doTest__Fv .LM1: stwu 1,-64(1) mflr 0 stw 28,48(1) stw 29,52(1) stw 30,56(1) stw 31,60(1) stw 0,68(1) mr 31,1 .stabn 68,0,37,.LM2-doTest__Fv .LM2: addis 9,0,__get_eh_context@ha addi 29,9,__get_eh_context@l mtlr 29 blrl mr 0,3 mr 9,0 mr 0,9 mr 29,0 .stabn 68,0,37,.LM3-doTest__Fv .LM3: .LBB2: .stabn 68,0,39,.LM4-doTest__Fv .LM4: li 0,0 stw 0,12(31) .stabn 68,0,41,.LM5-doTest__Fv .LM5: li 0,1 stw 0,16(31) .L8: .LBB3: lwz 0,16(31) cmpwi 1,0,5 bc 4,5,.L11 b .L9 .L11: .stabn 68,0,43,.LM6-doTest__Fv .LM6: lwz 0,16(31) stw 0,12(31) .stabn 68,0,44,.LM7-doTest__Fv .LM7: li 0,1234 stw 0,8(31) .stabn 68,0,45,.LM8-doTest__Fv .LM8: .LBB4: .stabn 68,0,47,.LM9-doTest__Fv .LM9: addi 0,31,24 addi 9,31,12 mr 3,0 mr 4,9 addis 9,0,a@ha addi 5,9,a@l addis 9,0,__25RTTypedValue_Enumeration1RC12Enumeration1PCi@ha addi 28,9,__25RTTypedValue_Enumeration1RC12Enumeration1PCi@l mtlr 28 blrl mr 9,29 lwz 0,0(9) addic 9,0,4 lwz 0,0(9) stw 0,32(31) addis 11,0,_$_25RTTypedValue_Enumeration1@ha addi 0,11,_$_25RTTypedValue_Enumeration1@l stw 0,36(31) addi 0,31,24 stw 0,40(31) addi 0,31,32 stw 0,0(9) mr 9,29 lwz 0,0(9) addic 9,0,4 lwz 11,0(9) lwz 0,0(11) stw 0,0(9) addi 0,31,24 mr 3,0 li 4,2 addis 9,0,_$_25RTTypedValue_Enumeration1@ha addi 29,9,_$_25RTTypedValue_Enumeration1@l mtlr 29 blrl .LBE4: .stabn 68,0,49,.LM10-doTest__Fv .LM10: li 0,5678 stw 0,8(31) .LBE3: .stabn 68,0,50,.LM11-doTest__Fv .LM11: .L10: lwz 9,16(31) addi 0,9,1 mr 9,0 stw 9,16(31) b .L8 .L9: .LBE2: .L7: lwz 11,0(1) lwz 0,4(11) mtlr 0 lwz 28,-16(11) lwz 29,-12(11) lwz 30,-8(11) lwz 31,-4(11) mr 1,11 blr .Lfe1: .size doTest__Fv,.Lfe1-doTest__Fv .stabs "j:(0,1)",128,0,38,8 .stabs "enumValue:(0,24)",128,0,39,12 .stabs "i:(0,1)",128,0,41,16 .stabn 192,0,0,.LBB2-doTest__Fv .stabn 192,0,0,.LBB3-doTest__Fv .stabs "enumMsg:(0,25)",128,0,47,24 .stabn 192,0,0,.LBB4-doTest__Fv .stabn 224,0,0,.LBE4-doTest__Fv .stabn 224,0,0,.LBE3-doTest__Fv .stabn 224,0,0,.LBE2-doTest__Fv .align 2 .stabs "main:F(0,1)",36,0,55,main .globl main .type main,@function main: .stabn 68,0,55,.LM12-main .LM12: stwu 1,-16(1) mflr 0 stw 31,12(1) stw 0,20(1) mr 31,1 .stabn 68,0,55,.LM13-main .LM13: .stabn 68,0,55,.LM14-main .LM14: .LBB5: .stabn 68,0,56,.LM15-main .LM15: bl doTest__Fv .LBE5: li 3,0 b .L12 .L12: lwz 11,0(1) lwz 0,4(11) mtlr 0 lwz 31,-4(11) mr 1,11 blr .Lfe2: .size main,.Lfe2-main .stabn 192,0,0,.LBB5-main .stabn 224,0,0,.LBE5-main .align 2 .stabs "_$_25RTTypedValue_Enumeration1:F (0,20)",36,0,30,_$_25RTTypedValue_Enumeration1 .stabs "this:P(0,31)",64,0,30,29 .stabs "__in_chrg:P(0,1)",64,0,30,28 .weak _$_25RTTypedValue_Enumeration1 .type _$_25RTTypedValue_Enumeration1,@function _$_25RTTypedValue_Enumeration1: .stabn 68,0,30,.LM16-_$_25RTTypedValue_Enumeration1 .LM16: stwu 1,-32(1) mflr 0 stw 27,12(1) stw 28,16(1) stw 29,20(1) stw 30,24(1) stw 31,28(1) stw 0,36(1) mr 31,1 mr 29,3 mr 28,4 .stabn 68,0,30,.LM17-_$_25RTTypedValue_Enumeration1 .LM17: .stabn 68,0,30,.LM18-_$_25RTTypedValue_Enumeration1 .LM18: .LBB6: .LBE6: .L4: rlwinm 0,28,0,31,31 cmpwi 1,0,0 bc 12,6,.L6 mr 3,29 addis 9,0,__builtin_delete@ha addi 27,9,__builtin_delete@l mtlr 27 blrl b .L6 .L5: .L6: .L3: lwz 11,0(1) lwz 0,4(11) mtlr 0 lwz 27,-20(11) lwz 28,-16(11) lwz 29,-12(11) lwz 30,-8(11) lwz 31,-4(11) mr 1,11 blr .Lfe3: .size _$_25RTTypedValue_Enumeration1,.Lfe3- _$_25RTTypedValue_Enumeration1 .stabn 192,0,0,.LBB6-_$_25RTTypedValue_Enumeration1 .stabn 224,0,0,.LBE6-_$_25RTTypedValue_Enumeration1 .align 2 .stabs "__25RTTypedValue_Enumeration1RC12Enumeration1PCi:F (0,31)",36,0,26,__25RTTypedValue_Enumeration1RC12Enumeration1PCi .stabs "this:P(0,31)",64,0,26,11 .stabs "rtg_value:P(0,34)=&(0,24)",64,0,26,0 .stabs "rtg_type:P(0,27)",64,0,26,9 .weak __25RTTypedValue_Enumeration1RC12Enumeration1PCi .type __25RTTypedValue_Enumeration1RC12Enumeration1PCi,@function __25RTTypedValue_Enumeration1RC12Enumeration1PCi: .stabn 68,0,26,.LM19-__25RTTypedValue_Enumeration1RC12Enumeration1PCi .LM19: stwu 1,-16(1) stw 31,12(1) mr 31,1 mr 11,3 mr 0,4 mr 9,5 .stabn 68,0,26,.LM20-__25RTTypedValue_Enumeration1RC12Enumeration1PCi .LM20: .stabn 68,0,26,.LM21-__25RTTypedValue_Enumeration1RC12Enumeration1PCi .LM21: stw 0,0(11) addis 10,0,b@ha addi 9,10,b@l addis 8,0,b@ha addi 10,8,b@l stw 10,4(11) .stabn 68,0,27,.LM22-__25RTTypedValue_Enumeration1RC12Enumeration1PCi .LM22: .LBB7: .LBE7: .L2: mr 3,11 b .L1 .L1: lwz 11,0(1) lwz 31,-4(11) mr 1,11 blr .Lfe4: .size __25RTTypedValue_Enumeration1RC12Enumeration1PCi,.Lfe4- __25RTTypedValue_Enumeration1RC12Enumeration1PCi .stabn 192,0,0,.LBB7-__25RTTypedValue_Enumeration1RC12Enumeration1PCi .stabn 224,0,0,.LBE7-__25RTTypedValue_Enumeration1RC12Enumeration1PCi .stabs "",100,0,0,.Letext .Letext: .ident "GCC: (GNU) cygnus-2.7.2-960126 egcs-971225 tornado 2.0 spr29516" Below is a copy of some VxWorks sessions showing the exception, and showing single stepping with the debugger. 2/12/05 Tornado C++ Test driver gets exception in VxWorks. The program gets this data access exception: data access Exception current instruction address: 0x01ffc234 Machine Status Register: 0x0000b030 Data Access Register: 0x9421ffe4 Condition Register: 0x28000000 Data storage interrupt Register: 0x40000000 Task: 0x1e95180 "t1" due to access to invalid memory address 0x9421ffe4. The PowerPC machine code below gets the exception: 0x1ffc228 7fa9eb78 or r9,r29,r29 0x1ffc22c 80090000 lwz r0,0(r9) 0x1ffc230 31200004 addic r9,r0,4 0x1ffc234 80090000 lwz r0,0(r9) ******* This line gets exception!! Breakpoint and single step in the debugger shows OK value r29 = 1fff320 on the first pass through the loop, but different value the second pass. r29 = 1ffc304 The invalid value 0x1ffc304 is _$_25RTTypedValue_Enumeration1 which is RTTypedValue_Enumeration1 constructor or destructor I guess. r29 is set to that invalid value here: 0x1ffc280 3ba9c304 addi r29,r9,-15612 0x1ffc284 7fa803a6 mtspr LR,r29 0x1ffc288 4e800021 blrl I guess that is OK, except that r29 is used in the second pass of the loop like it expected it to be unchanged. -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ]]]]]]]]]]]]]]]]]]]]]]]]]]] VxWorks version 5.4.2 ]]]]]]]]]]]]]]]]]]]]]]]]]] KERNEL: WIND version 2.5 ]]]]]]]]]]]]]]]]]]]]]]]]] Copyright Wind River Systems, Inc., 1984-2000 CPU: Vista Controls-ScorePPC FCCP. Processor #0. Memory Size: 0x2000000. BSP version 1.2/0. WDB: Ready. -> cd "/asep/asep/mpu/steve" value = 0 = 0x0 -> ld < TestProject.out value = 33540392 = 0x1ffc928 = _dtors + 0x538 -> sp main task spawned: id = 0x1e95180, name = t1 value = 32067968 = 0x1e95180 -> data access Exception current instruction address: 0x01ffc234 Machine Status Register: 0x0000b030 Data Access Register: 0x9421ffe4 Condition Register: 0x28000000 Data storage interrupt Register: 0x40000000 Task: 0x1e95180 "t1" -> tt t1 1bb2f8 vxTaskEntry +60 : main () 1ffc2e4 main +18 : doTest__Fv () value = 0 = 0x0 -> ti t1 NAME ENTRY TID PRI STATUS PC SP ERRNO DELAY ---------- ------------ -------- --- ---------- -------- -------- ------- ----- t1 main 1e95180 100 SUSPEND 1ffc234 1e950d8 0 0 stack: base 0x1e95180 end 0x1e90360 size 19728 high 792 margin 18936 options: 0x1d VX_SUPERVISOR_MODE VX_DEALLOC_STACK VX_FP_TASK VX_STDIO r0 = 9421ffe0 sp = 1e950d8 r2 = 0 r3 = 1e950f0 r4 = 1e950e4 r5 = 1ffc3d4 r6 = 4 r7 = fffffff8 r8 = 2000000 r9 = 9421ffe4 r10 = 1ffc3d0 r11 = 1e950d8 r12 = 0 r13 = 0 r14 = 0 r15 = 0 r16 = 0 r17 = 0 r18 = 0 r19 = 0 r20 = 0 r21 = 0 r22 = 0 r23 = 0 r24 = 0 r25 = 0 r26 = 0 r27 = 0 r28 = 1ffc37c r29 = 1ffc304 r30 = 0 r31 = 1e950d8 msr = b030 lr = 1ffc228 ctr = 0 pc = 1ffc234 cr = 28000000 xer = 0 fpcsr = 0 fr0 = NaN fr1 = NaN fr2 = NaN fr3 = NaN fr4 = NaN fr5 = NaN fr6 = NaN fr7 = NaN fr8 = NaN fr9 = NaN fr10 = NaN fr11 = NaN fr12 = NaN fr13 = NaN fr14 = NaN fr15 = NaN fr16 = NaN fr17 = NaN fr18 = NaN fr19 = NaN fr20 = NaN fr21 = NaN fr22 = NaN fr23 = NaN fr24 = NaN fr25 = NaN fr26 = NaN fr27 = NaN fr28 = NaN fr29 = NaN fr30 = NaN fr31 = NaN data access Exception current instruction address: 0xva0lue = 1ffc234 Machine Status Register: 0x00000b030 Data Access Register: 0x = 09421ffe4x Condition Register: 0x028000000 Data storage interrupt Register: 0x->40000000 -> l 0x1ffc234 0x1ffc234 80090000 lwz r0,0(r9) 0x1ffc238 901f0020 stw r0,32(r31) 0x1ffc23c 3d600200 lis r11,512 0x1ffc240 380bc304 addi r0,r11,-15612 0x1ffc244 901f0024 stw r0,36(r31) 0x1ffc248 381f0018 addi r0,r31,24 0x1ffc24c 901f0028 stw r0,40(r31) 0x1ffc250 381f0020 addi r0,r31,32 0x1ffc254 90090000 stw r0,0(r9) 0x1ffc258 7fa9eb78 or r9,r29,r29 value = 33538652 = 0x1ffc25c = doTest__Fv + 0xcc Thanks for any help you can provide, Steve Sciance General Dynamics, Land Systems sciance@gdls.com (586)825-5068 -- Summary: Exception with Tornado C++ on PowerPC target Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P2 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: sciance at gdls dot com CC: gcc-bugs at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19957