From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12316 invoked by alias); 8 Dec 2012 18:01:08 -0000 Received: (qmail 12303 invoked by uid 22791); 8 Dec 2012 18:01:07 -0000 X-SWARE-Spam-Status: No, hits=-1.5 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,MSGID_MULTIPLE_AT,TW_GD,TW_SM,TW_YM X-Spam-Check-By: sourceware.org Received: from mailhost.u-strasbg.fr (HELO mailhost.u-strasbg.fr) (130.79.200.154) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 08 Dec 2012 18:01:00 +0000 Received: from md15.u-strasbg.fr (md15.u-strasbg.fr [130.79.200.204]) by mailhost.u-strasbg.fr (8.14.3/jtpda-5.5pre1) with ESMTP id qB8I0sp3069523 ; Sat, 8 Dec 2012 19:00:54 +0100 (CET) (envelope-from pierre.muller@ics-cnrs.unistra.fr) Received: from mailserver.u-strasbg.fr (ms18.u-strasbg.fr [130.79.204.118]) by md15.u-strasbg.fr (8.14.3/jtpda-5.5pre1) with ESMTP id qB8I0rb3016909 ; Sat, 8 Dec 2012 19:00:53 +0100 (envelope-from pierre.muller@ics-cnrs.unistra.fr) Received: from E6510Muller (lec67-4-82-230-53-140.fbx.proxad.net [82.230.53.140]) (user=mullerp mech=LOGIN) by mailserver.u-strasbg.fr (8.14.3/jtpda-5.5pre1) with ESMTP id qB8I0ppC030848 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO) ; Sat, 8 Dec 2012 19:00:51 +0100 (envelope-from pierre.muller@ics-cnrs.unistra.fr) From: "Pierre Muller" To: "'asmwarrior'" Cc: "'Joel Brobecker'" , "'Eli Zaretskii'" , References: <20121024194517.GK3555@adacore.com> <011901cdb2ab$48076b90$d81642b0$@muller@ics-cnrs.unistra.fr> <20121105171121.GA2972@adacore.com> <50991f5f.8382440a.1100.ffff82abSMTPIN_ADDED@mx.google.com> <509ABA17.30507@redhat.com> <000301cdbd96$f5cd9f10$e168dd30$@muller@ics-cnrs.unistra.fr> <20121122173019.GF9964@adacore.com> <15690.5992342674$1353883881@news.gmane.org> <87624si9ur.fsf@fleche.redhat.com> <001501cdccaf$ad85e9b0$0891bd10$@muller@ics-cnrs.unistra.fr> <20121207071035.GG31477@adacore.com> <50C20A66.70002@gmail.com> <29545.4593528577$1354894901@news.gmane.org> <50C21696.7040006@gmail.com> <50c218e5.2850b40a.0281.ffffbef4SMTPIN_ADDED_BROKEN@mx.google.com> <50C34C75.3050803@gmail.com> In-Reply-To: <50C34C75.3050803@gmail.com> Subject: RE: [RFC-v5] Fix .text section offset for windows DLL (was Calling __stdcall functions in the inferior) Date: Sat, 08 Dec 2012 18:01:00 -0000 Message-ID: <009001cdd56d$f7310970$e5931c50$@muller@ics-cnrs.unistra.fr> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-12/txt/msg00215.txt.bz2 Hi Yuanhui, thanks again for trying to debug that problem... > -----Message d'origine----- > De : gdb-patches-owner@sourceware.org [mailto:gdb-patches- > owner@sourceware.org] De la part de asmwarrior > Envoy=C3=A9 : samedi 8 d=C3=A9cembre 2012 15:20 > =C3=80 : Pierre Muller > Cc : 'Joel Brobecker'; 'Eli Zaretskii'; gdb-patches@sourceware.org > Objet : Re: [RFC-v5] Fix .text section offset for windows DLL (was Calling > __stdcall functions in the inferior) >=20 > On 2012-12-8 0:27, Pierre Muller wrote: > > > >> -----Message d'origine----- > >> De : gdb-patches-owner@sourceware.org [mailto:gdb-patches- > >> owner@sourceware.org] De la part de asmwarrior > >> Envoy=C3=A9 : vendredi 7 d=C3=A9cembre 2012 17:17 > >> =C3=80 : Pierre Muller > >> Cc : 'Joel Brobecker'; 'Eli Zaretskii'; gdb-patches@sourceware.org > >> Objet : Re: [RFC-v5] Fix .text section offset for windows DLL (was > Calling > >> __stdcall functions in the inferior) > >> > >> On 2012-12-7 23:40, Pierre Muller wrote: > >>> Hi Yuanhui, > >>> thanks for trying to debug this... > >>> > >>> First, concerning the optimized out problems, > >>> it would be easier if you would recompile > >>> GDB without optimization: > >>> > >>> make clean all CFLAGS=3D"-gdwarf-2 -O0" > >>> > >>> After that, you should get optimized out variables... > >> I will did this if I have more time. > >> > >> > >>> I also installed CodeBlocks to test if I can reproduce your crash, > >>> but I never got any ... > >> The codeblocks.exe was built myself, which has debug information in it. > > I tried to recompile the sources, but > > compilation fails on not found wxWorks headers... > > Despite the fact that I compiled wxWorks 2.9.4 without problems. > Note: Codeblocks currently can build against wxWidgets 2.8.12 library. I > think it was not stable to build against wxWidgets 2.9.x. Thanks for the information. =20 > >>> Could it be that some weird DLL's have unnamed > >>> sections? > >>> Could you try to insert > >>> if (sections[i] && section[i].name) > >>> before > >>>> if (strcmp (sections[i].section_name, section_name) =3D=3D 0) > >>>> return i; > >>> to confirm that the problem originates here? > >>> > >> I add a line: > >> static int > >> get_pe_section_index (const char *section_name, > >> struct read_pe_section_data *sections, > >> int nb_sections) > >> { > >> int i; > >> for (i =3D 0; i < nb_sections; i++) > >> if (section_name && (§ions[i]) && sections[i].section_name) > >> if (strcmp (sections[i].section_name, section_name) =3D=3D 0) > >> return i; > >> return PE_SECTION_INDEX_INVALID; > >> } > >> > >> > >> But still the same crash in strcmp(). > > Could you try to check that section_name ansd sections array are > valid... > > It will probably require that you recompile GDB :( > Hi, today, I build gdb with "-O0 -g", here is the variables I see when it > crashed. >=20 > Program received signal SIGSEGV, Segmentation fault. > 0x77c47784 in strcmp () from C:\WINDOWS\system32\msvcrt.dll > (gdb) bt > #0 0x77c47784 in strcmp () from C:\WINDOWS\system32\msvcrt.dll > #1 0x00562eb9 in get_pe_section_index (section_name=3D0x5548638 ".data", > sections=3D0x4b33b38, nb_sections=3D5) at ../../gdb/gdb/coff-pe-read= .c:113 > #2 0x00562f08 in get_section_vmas (abfd=3D0x4caede8, sectp=3D0x55496e8, > context=3D0x285f5ec) at ../../gdb/gdb/coff-pe-read.c:134 > #3 0x0064e7ee in bfd_map_over_sections (abfd=3D0x4caede8, > operation=3D0x562ed5 , user_storage=3D0x285f5ec) > at ../../gdb/bfd/section.c:1329 > #4 0x00563d2c in read_pe_exported_syms (objfile=3D0x5615090) > at ../../gdb/gdb/coff-pe-read.c:525 > #5 0x00560887 in coff_symtab_read (symtab_offset=3D0, nsyms=3D0, > objfile=3D0x5615090) at ../../gdb/gdb/coffread.c:1127 > #6 0x0055f660 in coff_symfile_read (objfile=3D0x5615090, symfile_flags= =3D8) > at ../../gdb/gdb/coffread.c:610 > #7 0x004f1cc4 in read_symbols (objfile=3D0x5615090, add_flags=3D8) > at ../../gdb/gdb/symfile.c:885 > #8 0x004f203b in syms_from_objfile (objfile=3D0x5615090, addrs=3D0x2e043= 98, > offsets=3D0x0, num_offsets=3D0, add_flags=3D8) at > ../../gdb/gdb/symfile.c:1020 > #9 0x004f2206 in symbol_file_add_with_addrs_or_offsets (abfd=3D0x4caede8, > add_flags=3D8, addrs=3D0x2e04398, offsets=3D0x0, num_offsets=3D0, fl= ags=3D2, > parent=3D0x0) at ../../gdb/gdb/symfile.c:1123 > #10 0x004f23bf in symbol_file_add_from_bfd (abfd=3D0x4caede8, add_flags= =3D8, > addrs=3D0x2e04398, flags=3D2, parent=3D0x0) at ../../gdb/gdb/symfile= .c:1213 > #11 0x0060ef33 in solib_read_symbols (so=3D0x4bdb6b0, flags=3D8) > at ../../gdb/gdb/solib.c:608 > #12 0x0060f50d in solib_add (pattern=3D0x0, from_tty=3D0, > target=3D0x9ec6c0 , readsyms=3D1) at > ../../gdb/gdb/solib.c:919 > #13 0x0050146f in post_create_inferior (target=3D0x9ec6c0 , > from_tty=3D0) at ../../gdb/gdb/infcmd.c:477 > #14 0x0050175b in run_command_1 (args=3D0x0, from_tty=3D1, tbreak_at_main= =3D0) > at ../../gdb/gdb/infcmd.c:631 > #15 0x005017b0 in run_command (args=3D0x0, from_tty=3D1) > at ../../gdb/gdb/infcmd.c:645 > #16 0x00447794 in do_cfunc (c=3D0x2d65ed0, args=3D0x0, from_tty=3D1) > at ../../gdb/gdb/cli/cli-decode.c:114 > #17 0x0044a0ce in cmd_func (cmd=3D0x2d65ed0, args=3D0x0, from_tty=3D1) > at ../../gdb/gdb/cli/cli-decode.c:1859 > #18 0x005f6ebf in execute_command (p=3D0x294321 "", from_tty=3D1) > at ../../gdb/gdb/top.c:491 > #19 0x00524cda in command_handler (command=3D0x294320 "") > at ../../gdb/gdb/event-top.c:429 > #20 0x0052524e in command_line_handler (rl=3D0x2e29fe0 "r") > at ../../gdb/gdb/event-top.c:630 > #21 0x00630133 in rl_callback_read_char () > at ../../gdb/readline/callback.c:220 > #22 0x0052481f in rl_callback_read_char_wrapper (client_data=3D0x0) > at ../../gdb/gdb/event-top.c:163 > #23 0x00524c04 in stdin_event_handler (error=3D0, client_data=3D0x0) > at ../../gdb/gdb/event-top.c:369 > #24 0x00523df9 in handle_file_event (data=3D...) > at ../../gdb/gdb/event-loop.c:827 > #25 0x0052353d in process_event () at ../../gdb/gdb/event-loop.c:401 > #26 0x00523602 in gdb_do_one_event () at ../../gdb/gdb/event-loop.c:465 > #27 0x00523654 in start_event_loop () at ../../gdb/gdb/event-loop.c:490 > #28 0x00524848 in cli_command_loop () at ../../gdb/gdb/event-top.c:176 > #29 0x0051cdcf in current_interp_command_loop () > at ../../gdb/gdb/interps.c:332 > #30 0x0051d6e9 in captured_command_loop (data=3D0x0) at > ../../gdb/gdb/main.c:256 > #31 0x0051be8c in catch_errors (func=3D0x51d6d4 , > func_args=3D0x0, errstring=3D0x7af593 <__PRETTY_FUNCTION__.13689+121= > "", > mask=3D6) at ../../gdb/gdb/exceptions.c:546 > #32 0x0051e8c7 in captured_main (data=3D0x285fee0) at > ../../gdb/gdb/main.c:1032 > #33 0x0051be8c in catch_errors (func=3D0x51d923 , > func_args=3D0x285fee0, > errstring=3D0x7af593 <__PRETTY_FUNCTION__.13689+121> "", mask=3D6) > at ../../gdb/gdb/exceptions.c:546 > #34 0x0051e8fd in gdb_main (args=3D0x285fee0) at ../../gdb/gdb/main.c:1041 > #35 0x00401737 in main (argc=3D1, argv=3D0x293ea0) at ../../gdb/gdb/gdb.c= :34 > (gdb) frame 1 > #1 0x00562eb9 in get_pe_section_index (section_name=3D0x5548638 ".data", > sections=3D0x4b33b38, nb_sections=3D5) at ../../gdb/gdb/coff-pe-read= .c:113 > 113 if (strcmp (sections[i].section_name, section_name) =3D=3D 0) > (gdb) p section_name > $1 =3D 0x5548638 ".data" > (gdb) p i > $2 =3D 2 > (gdb) p sections[i].section_name > $3 =3D 0xabababab
> (gdb) print *sections@nb_sections > $4 =3D {{vma_offset =3D 2089811968, rva_start =3D 4096, rva_end =3D 51580= 2, > ms_type =3D mst_text, section_name =3D 0x7cd4a0 ".= text"}, > { > vma_offset =3D 2868903936, rva_start =3D 2880154539, rva_end =3D 288= 0154539, > ms_type =3D mst_unknown, section_name =3D 0x0}, {vma_offset =3D 3932= 21, > rva_start =3D 35784515, rva_end =3D 1920168494, ms_type =3D 28801106= 91, > section_name =3D 0xabababab
}, { > vma_offset =3D 0, rva_start =3D 536576, rva_end =3D 716408, ms_type = =3D > mst_data, > section_name =3D 0x4b33b68 ".rsrc"}, {vma_offset =3D 0, rva_start = =3D 716800, > rva_end =3D 728800, ms_type =3D mst_data, section_name =3D 0x4b33be0 > ".reloc"}} >=20 >=20 >=20 > Look, the value "0xabababab", I'm not sure why gdb report: out of bounds, > where does this value come from? This memory corruption is rather odd... it seems that the rva_end of index=3D2 seems to contains the same data as the section_name for index 4... This array is really created only inside read_pe_exported_syms so that it would be worth trying to add a breakpoint at that function, and step over it for ntdll.dll to understand when the data gets corrupted... Would it be possible for you to upload the codeblocks executable that tri= ggers the problem somewhere so I could check if I get the same errors and debug further? I have no idea what is going on... Pierre Muller