From owner-freebsd-toolchain@FreeBSD.ORG Sat Sep 13 16:45:40 2014 Return-Path: Delivered-To: toolchain@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 624EC1FC; Sat, 13 Sep 2014 16:45:40 +0000 (UTC) Received: from tensor.andric.com (unknown [IPv6:2001:7b8:3a7:1:2d0:b7ff:fea0:8c26]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client CN "tensor.andric.com", Issuer "CAcert Class 3 Root" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id D6F99D28; Sat, 13 Sep 2014 16:45:39 +0000 (UTC) Received: from [IPv6:2001:7b8:3a7::b12a:a821:10d9:98f3] (unknown [IPv6:2001:7b8:3a7:0:b12a:a821:10d9:98f3]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by tensor.andric.com (Postfix) with ESMTPSA id 64D88B803; Sat, 13 Sep 2014 18:45:35 +0200 (CEST) Content-Type: multipart/signed; boundary="Apple-Mail=_FC22A853-BF0E-4EA7-BF1F-26A338126E0C"; protocol="application/pgp-signature"; micalg=pgp-sha1 Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\)) Subject: Re: clang makes segfaulting code with -march=core2 on i386 From: Dimitry Andric In-Reply-To: <54135D0B.7060701@freebsd.org> Date: Sat, 13 Sep 2014 18:45:26 +0200 Message-Id: <6FDF432B-8245-4BC7-952B-DFFEEA106D6F@FreeBSD.org> References: <54130AD0.8090103@freebsd.org> <54133E1E.9030105@freebsd.org> <54135B24.5040905@freebsd.org> <54135D0B.7060701@freebsd.org> To: Andrey Chernov X-Mailer: Apple Mail (2.1878.6) Cc: toolchain@freebsd.org X-BeenThere: freebsd-toolchain@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Maintenance of FreeBSD's integrated toolchain List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 13 Sep 2014 16:45:40 -0000 --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 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, func=3D, data=3D, pset=3D0x295e00a0, lh=3D) = at .././../gcc-4.8.3/gcc/tree.c:10700 #2 0x086a15f6 in walk_tree_1 (tp=3D, func=3D, data=3D, pset=3D0x295e00a0, lh=3D) = at .././../gcc-4.8.3/gcc/tree.c:10954 #3 0x086a1555 in walk_tree_1 (tp=3D, func=3D, data=3D, pset=3D, lh=3D) at .././../gcc-4.8.3/gcc/tree.c:10747 #4 0x081ed0ef in cp_walk_subtrees (tp=3D0xbfbfdb68, = walk_subtrees_p=3D0x29401674, func=3D, data=3D, pset=3D) at .././../gcc-4.8.3/gcc/cp/tree.c:3522 #5 0x086a118c in walk_tree_1 (tp=3D, func=3D, data=3D, pset=3D, lh=3D) 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) 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) at = .././../gcc-4.8.3/gcc/cp/parser.c:10150 #10 cp_parser_statement (parser=3D0x298ea1c0, in_statement_expr=3D0x0, = in_compound=3D, if_p=3D) 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, in_statement_expr=3D, in_try=3D, = function_body=3D) at = .././../gcc-4.8.3/gcc/cp/parser.c:9195 #13 0x0819dd96 in cp_parser_implicitly_scoped_statement = (parser=3D, if_p=3D) 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, if_p=3D0x0) at = .././../gcc-4.8.3/gcc/cp/parser.c:8864 #16 0x0819ddbb in cp_parser_implicitly_scoped_statement = (parser=3D, if_p=3D) 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, 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) at .././../gcc-4.8.3/gcc/cp/parser.c:9938 #22 cp_parser_statement (parser=3D0x298ea1c0, in_statement_expr=3D0x0, = in_compound=3D, if_p=3D) 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, in_statement_expr=3D, in_try=3D, = function_body=3D) at = .././../gcc-4.8.3/gcc/cp/parser.c:9195 #25 0x08198e33 in cp_parser_function_body (parser=3D, = parser=3D, in_function_try_block=3D) 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) 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, decl_specifiers=3D, = attributes=3D, declarator=3D) at = .././../gcc-4.8.3/gcc/cp/parser.c:21752 #29 cp_parser_init_declarator (parser=3D0x298ea1c0, = decl_specifiers=3D, checks=3D, = function_definition_allowed_p=3D, member_p=3D, declares_class_or_enum=3D, = function_definition_p=3D, maybe_range_for_decl=3D) at .././../gcc-4.8.3/gcc/cp/parser.c:15905 #30 0x081abc32 in cp_parser_single_declaration (parser=3D0x298ea1c0, = checks=3D0x0, member_p=3D, = explicit_specialization_p=3Dfalse, friend_p=3D) 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) = 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--