Date: Sat, 13 Sep 2014 18:45:26 +0200 From: Dimitry Andric <dim@FreeBSD.org> To: Andrey Chernov <ache@freebsd.org> Cc: toolchain@freebsd.org Subject: Re: clang makes segfaulting code with -march=core2 on i386 Message-ID: <6FDF432B-8245-4BC7-952B-DFFEEA106D6F@FreeBSD.org> In-Reply-To: <54135D0B.7060701@freebsd.org> References: <54130AD0.8090103@freebsd.org> <A212D7AF-4DA7-4043-BB73-1746A5C2F42F@FreeBSD.org> <54133E1E.9030105@freebsd.org> <54135B24.5040905@freebsd.org> <54135D0B.7060701@freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
--Apple-Mail=_FC22A853-BF0E-4EA7-BF1F-26A338126E0C Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=koi8-r On 12 Sep 2014, at 22:52, Andrey Chernov <ache@freebsd.org> wrote: > On 13.09.2014 0:44, Andrey Chernov wrote: >> On 12.09.2014 22:40, Andrey Chernov wrote: >>> I don't have -current & i386 combination, but I can try -current & = x64 later (with different -march). >>=20 >> It works on -current, amd64, -march=3Dcore2. So it either -stable or >> i386-specific clang bug. >>=20 >=20 > I forget to say that real CPU on -current tested is not the same as = for > failing i386: QuadCore Intel Core i7-3820 After some massaging of gcc's source to disable its built-in segfault handlers, I get this backtrace: Program received signal SIGSEGV, Segmentation fault. find_parameter_packs_r (tp=3D0x2c3212fc, walk_subtrees=3D0xbfbfda60, = data=3D0xbfbfdb58) at .././../gcc-4.8.3/gcc/cp/pt.c:3063 3063 if (TYPE_P (t) (gdb) bt #0 find_parameter_packs_r (tp=3D0x2c3212fc, walk_subtrees=3D0xbfbfda60, = data=3D0xbfbfdb58) at .././../gcc-4.8.3/gcc/cp/pt.c:3063 #1 0x086a111c in walk_tree_1 (tp=3D<optimized out>, func=3D<optimized = out>, data=3D<optimized out>, pset=3D0x295e00a0, lh=3D<optimized out>) = at .././../gcc-4.8.3/gcc/tree.c:10700 #2 0x086a15f6 in walk_tree_1 (tp=3D<optimized out>, func=3D<optimized = out>, data=3D<optimized out>, pset=3D0x295e00a0, lh=3D<optimized out>) = at .././../gcc-4.8.3/gcc/tree.c:10954 #3 0x086a1555 in walk_tree_1 (tp=3D<optimized out>, func=3D<optimized = out>, data=3D<optimized out>, pset=3D<optimized out>, lh=3D<optimized = out>) at .././../gcc-4.8.3/gcc/tree.c:10747 #4 0x081ed0ef in cp_walk_subtrees (tp=3D0xbfbfdb68, = walk_subtrees_p=3D0x29401674, func=3D<optimized out>, data=3D<optimized = out>, pset=3D<optimized out>) at .././../gcc-4.8.3/gcc/cp/tree.c:3522 #5 0x086a118c in walk_tree_1 (tp=3D<optimized out>, func=3D<optimized = out>, data=3D<optimized out>, pset=3D<optimized out>, lh=3D<optimized = out>) at .././../gcc-4.8.3/gcc/tree.c:10723 #6 0x0813b6fc in check_for_bare_parameter_packs (t=3D0x2c388514) at = .././../gcc-4.8.3/gcc/cp/pt.c:3357 #7 0x081c4707 in check_return_expr (retval=3D0x2c388514, = no_warning=3D<optimized out>) at .././../gcc-4.8.3/gcc/cp/typeck.c:8156 #8 0x081da7b9 in finish_return_stmt (expr=3D0x2c388514) at = .././../gcc-4.8.3/gcc/cp/semantics.c:793 #9 0x0819a799 in cp_parser_jump_statement (parser=3D<optimized out>) at = .././../gcc-4.8.3/gcc/cp/parser.c:10150 #10 cp_parser_statement (parser=3D0x298ea1c0, in_statement_expr=3D0x0, = in_compound=3D<optimized out>, if_p=3D<optimized out>) at = .././../gcc-4.8.3/gcc/cp/parser.c:8877 #11 0x081990c8 in cp_parser_statement_seq_opt (parser=3D0x298ea1c0, = in_statement_expr=3D0x0) at .././../gcc-4.8.3/gcc/cp/parser.c:9241 #12 0x08198f5f in cp_parser_compound_statement (parser=3D<optimized = out>, in_statement_expr=3D<optimized out>, in_try=3D<optimized out>, = function_body=3D<optimized out>) at = .././../gcc-4.8.3/gcc/cp/parser.c:9195 #13 0x0819dd96 in cp_parser_implicitly_scoped_statement = (parser=3D<optimized out>, if_p=3D<optimized out>) at = .././../gcc-4.8.3/gcc/cp/parser.c:10237 #14 0x0819a8e4 in cp_parser_selection_statement (parser=3D0x298ea1c0, = if_p=3D0x0) at .././../gcc-4.8.3/gcc/cp/parser.c:9347 #15 cp_parser_statement (parser=3D0x298ea1c0, in_statement_expr=3D0x0, = in_compound=3D<optimized out>, if_p=3D0x0) at = .././../gcc-4.8.3/gcc/cp/parser.c:8864 #16 0x0819ddbb in cp_parser_implicitly_scoped_statement = (parser=3D<optimized out>, if_p=3D<optimized out>) at = .././../gcc-4.8.3/gcc/cp/parser.c:10244 #17 0x0819a8e4 in cp_parser_selection_statement (parser=3D0x298ea1c0, = if_p=3D0x0) at .././../gcc-4.8.3/gcc/cp/parser.c:9347 #18 cp_parser_statement (parser=3D0x298ea1c0, in_statement_expr=3D0x0, = in_compound=3D<optimized out>, if_p=3D0x0) at = .././../gcc-4.8.3/gcc/cp/parser.c:8864 #19 0x081990c8 in cp_parser_statement_seq_opt (parser=3D0x298ea1c0, = in_statement_expr=3D0x0) at .././../gcc-4.8.3/gcc/cp/parser.c:9241 #20 0x0819dbfe in cp_parser_already_scoped_statement (parser=3D0x298ea1c0)= at .././../gcc-4.8.3/gcc/cp/parser.c:10273 #21 0x0819a045 in cp_parser_iteration_statement (parser=3D<optimized = out>) at .././../gcc-4.8.3/gcc/cp/parser.c:9938 #22 cp_parser_statement (parser=3D0x298ea1c0, in_statement_expr=3D0x0, = in_compound=3D<optimized out>, if_p=3D<optimized out>) at = .././../gcc-4.8.3/gcc/cp/parser.c:8870 #23 0x081990c8 in cp_parser_statement_seq_opt (parser=3D0x298ea1c0, = in_statement_expr=3D0x0) at .././../gcc-4.8.3/gcc/cp/parser.c:9241 #24 0x08198f5f in cp_parser_compound_statement (parser=3D<optimized = out>, in_statement_expr=3D<optimized out>, in_try=3D<optimized out>, = function_body=3D<optimized out>) at = .././../gcc-4.8.3/gcc/cp/parser.c:9195 #25 0x08198e33 in cp_parser_function_body (parser=3D<optimized out>, = parser=3D<optimized out>, in_function_try_block=3D<optimized out>) at = .././../gcc-4.8.3/gcc/cp/parser.c:17816 #26 cp_parser_ctor_initializer_opt_and_function_body (parser=3D0x298ea1c0,= in_function_try_block=3D<optimized out>) at = .././../gcc-4.8.3/gcc/cp/parser.c:17852 #27 0x08198a14 in cp_parser_function_definition_after_declarator = (parser=3D0x298ea1c0, inline_p=3Dfalse) at = .././../gcc-4.8.3/gcc/cp/parser.c:21831 #28 0x08183dcb in = cp_parser_function_definition_from_specifiers_and_declarator = (parser=3D<optimized out>, decl_specifiers=3D<optimized out>, = attributes=3D<optimized out>, declarator=3D<optimized out>) at = .././../gcc-4.8.3/gcc/cp/parser.c:21752 #29 cp_parser_init_declarator (parser=3D0x298ea1c0, = decl_specifiers=3D<optimized out>, checks=3D<optimized out>, = function_definition_allowed_p=3D<optimized out>, member_p=3D<optimized = out>, declares_class_or_enum=3D<optimized out>, = function_definition_p=3D<optimized out>, maybe_range_for_decl=3D<optimized= out>) at .././../gcc-4.8.3/gcc/cp/parser.c:15905 #30 0x081abc32 in cp_parser_single_declaration (parser=3D0x298ea1c0, = checks=3D0x0, member_p=3D<optimized out>, = explicit_specialization_p=3Dfalse, friend_p=3D<optimized out>) at = .././../gcc-4.8.3/gcc/cp/parser.c:22127 #31 0x081ab137 in cp_parser_template_declaration_after_export = (parser=3D0x298ea1c0, member_p=3Dfalse) at = .././../gcc-4.8.3/gcc/cp/parser.c:21941 #32 0x0817d57e in cp_parser_template_declaration (parser=3D0x298ea1c0, = member_p=3Dfalse) at .././../gcc-4.8.3/gcc/cp/parser.c:12226 #33 cp_parser_declaration (parser=3D0x298ea1c0) at = .././../gcc-4.8.3/gcc/cp/parser.c:10404 #34 0x0817b387 in cp_parser_declaration_seq_opt (parser=3D0x298ea1c0) at = .././../gcc-4.8.3/gcc/cp/parser.c:10334 #35 0x0817e3a7 in cp_parser_namespace_body (parser=3D0x298ea1c0) at = .././../gcc-4.8.3/gcc/cp/parser.c:15136 #36 cp_parser_namespace_definition (parser=3D0x298ea1c0) at = .././../gcc-4.8.3/gcc/cp/parser.c:15117 #37 0x0817d4f8 in cp_parser_declaration (parser=3D0x298ea1c0) at = .././../gcc-4.8.3/gcc/cp/parser.c:10432 #38 0x0817b387 in cp_parser_declaration_seq_opt (parser=3D0x298ea1c0) at = .././../gcc-4.8.3/gcc/cp/parser.c:10334 #39 0x0817a4b2 in cp_parser_translation_unit (parser=3D<optimized out>) = at .././../gcc-4.8.3/gcc/cp/parser.c:3813 #40 c_parse_file () at .././../gcc-4.8.3/gcc/cp/parser.c:28334 #41 0x0824a304 in c_common_parse_file () at = .././../gcc-4.8.3/gcc/c-family/c-opts.c:1052 #42 0x0853aca8 in compile_file () at .././../gcc-4.8.3/gcc/toplev.c:547 #43 0x0853aac3 in do_compile () at .././../gcc-4.8.3/gcc/toplev.c:1870 #44 toplev_main (argc=3D43, argv=3D0xbfbfe1ec) at = .././../gcc-4.8.3/gcc/toplev.c:1946 #45 0x0810e6aa in _start1 () #46 0x0810e568 in _start () (gdb) list 3058 struct find_parameter_pack_data* ppd =3D=20 3059 (struct find_parameter_pack_data*)data; 3060 bool parameter_pack_p =3D false; 3061=09 3062 /* Handle type aliases/typedefs. */ 3063 if (TYPE_P (t) 3064 && TYPE_NAME (t) 3065 && TREE_CODE (TYPE_NAME (t)) =3D=3D TYPE_DECL 3066 && TYPE_DECL_ALIAS_P (TYPE_NAME (t))) 3067 { (gdb) print t $1 =3D (tree) 0x8 (gdb) print tp $2 =3D (tree *) 0x2c3212fc (gdb) print *tp $3 =3D (tree) 0x8 I think it's most likely this is some type of undefined behavior in gcc, which leads to randomly corrupted tree values. Of course, it could also be a clang bug, but I don't see any "64-bit" instructions in there at all. This needs to be investigated further, but it's very hard to understand what is going on the guts of gcc's parser. Let alone to reduce this to some sort of reproducible test case. -Dimitry --Apple-Mail=_FC22A853-BF0E-4EA7-BF1F-26A338126E0C Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP using GPGMail -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.22 (Darwin) iEYEARECAAYFAlQUdKoACgkQsF6jCi4glqN1ZACgoVkPGvB9I3F5vgg8fUqNKhBF pS0Ani61mdp+gvmiEt7dcq6F9onNEcWh =fbTu -----END PGP SIGNATURE----- --Apple-Mail=_FC22A853-BF0E-4EA7-BF1F-26A338126E0C--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6FDF432B-8245-4BC7-952B-DFFEEA106D6F>