Summary: | [10 Regression] ICE in operation_could_trap_p, at tree-eh.c:2528 when compiling Python's Python/_warnings.c | ||
---|---|---|---|
Product: | gcc | Reporter: | Romain Geissler <romain.geissler> |
Component: | middle-end | Assignee: | Jakub Jelinek <jakub> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | dcb314, jakub, krebbel1, krebbel |
Priority: | P3 | ||
Version: | 10.0 | ||
Target Milestone: | 10.0 | ||
Host: | Target: | ||
Build: | Known to work: | ||
Known to fail: | Last reconfirmed: | 2019-10-11 00:00:00 | |
Attachments: |
preprocessed source
gcc10-pr92063.patch gcc10-pr92063.patch |
Description
Romain Geissler
2019-10-11 07:52:00 UTC
Python code is here: https://github.com/python/cpython/blob/v3.7.4/Python/_warnings.c#L753 #define ascii_lower(c) ((c <= 127) ? Py_TOLOWER(c) : 0) /* if filename.lower().endswith(".pyc"): */ if (len >= 4 && PyUnicode_READ(kind, data, len-4) == '.' && ascii_lower(PyUnicode_READ(kind, data, len-3)) == 'p' && ascii_lower(PyUnicode_READ(kind, data, len-2)) == 'y' && ascii_lower(PyUnicode_READ(kind, data, len-1)) == 'c') { *filename = PyUnicode_Substring(*filename, 0, PyUnicode_GET_LENGTH(*filename)-1); if (*filename == NULL) goto handle_error; } else Py_INCREF(*filename); Please attach preprocessed source, see http://gcc.gnu.org/bugs/ for details. Same problem here is the backtrace: COLLECT_GCC_OPTIONS='-pthread' '-c' '-Wsign-compare' '-D' 'NDEBUG' '-v' '-save-temps' '-pipe' '-march=native' '-O3' '-fwrapv' '-std=c99' '-Wextra' '-Wno-unused-result' '-Wno-unuse d-parameter' '-Wno-missing-field-initializers' '-Wno-cast-function-type' '-Werror=implicit-function-declaration' '-I' '.' '-I' './Include' '-I' '/usr/include/ncursesw' '-fPIC' '-D ' 'Py_BUILD_CORE' '-o' 'Python/_warnings.o' /usr/libexec/gcc/x86_64-pc-linux-gnu/10.0.0-pre9999/cc1 -fpreprocessed _warnings.i -march=skylake-avx512 -mmmx -mno-3dnow -msse -msse2 -msse3 -mssse3 -mno-sse4a -mcx16 -msahf -mm ovbe -maes -mno-sha -mpclmul -mpopcnt -mabm -mno-lwp -mfma -mno-fma4 -mno-xop -mbmi -mno-sgx -mbmi2 -mno-pconfig -mno-wbnoinvd -mno-tbm -mavx -mavx2 -msse4.2 -msse4.1 -mlzcnt -mrt m -mhle -mrdrnd -mf16c -mfsgsbase -mrdseed -mprfchw -madx -mfxsr -mxsave -mxsaveopt -mavx512f -mno-avx512er -mavx512cd -mno-avx512pf -mno-prefetchwt1 -mclflushopt -mxsavec -mxsave s -mavx512dq -mavx512bw -mavx512vl -mno-avx512ifma -mno-avx512vbmi -mno-avx5124fmaps -mno-avx5124vnniw -mclwb -mno-mwaitx -mno-clzero -mno-pku -mno-rdpid -mno-gfni -mno-shstk -mno -avx512vbmi2 -mno-avx512vnni -mno-vaes -mno-vpclmulqdq -mno-avx512bitalg -mno-movdiri -mno-movdir64b -mno-waitpkg -mno-cldemote -mno-ptwrite -mno-avx512bf16 -mno-enqcmd -mno-avx51 2vp2intersect --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=14080 -mtune=skylake-avx512 -quiet -dumpbase _warnings.c -auxbase-strip Python/_warnings .o -O3 -Wsign-compare -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Wno-cast-function-type -Werror=implicit-function-declaration -std=c99 -vers ion -fwrapv -fPIC -o _warnings.s GNU C99 (Gentoo 10.0.0_pre9999) version 10.0.0-pre9999 20191011 (experimental) (x86_64-pc-linux-gnu) compiled by GNU C version 10.0.0-pre9999 20191011 (experimental), GMP version 6.1.2, MPFR version 4.0.2, MPC version 1.1.0, isl version isl-0.21-GMP GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 GNU C99 (Gentoo 10.0.0_pre9999) version 10.0.0-pre9999 20191011 (experimental) (x86_64-pc-linux-gnu) compiled by GNU C version 10.0.0-pre9999 20191011 (experimental), GMP version 6.1.2, MPFR version 4.0.2, MPC version 1.1.0, isl version isl-0.21-GMP GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: 0221118538dfe651be51fb82b7b0281e Python/_warnings.c: In function ‘setup_context’: Python/_warnings.c:753:13: internal compiler error: in operation_could_trap_p, at tree-eh.c:2528 753 | ascii_lower(PyUnicode_READ(kind, data, len-1)) == 'c') | ^ 0x8859dd operation_could_trap_p(tree_code, bool, bool, tree_node*) /var/tmp/portage/sys-devel/gcc-10.0.0_pre9999/work/gcc-10.0.0_pre9999/gcc/tree-eh.c:2528 0x8859dd operation_could_trap_p(tree_code, bool, bool, tree_node*) /var/tmp/portage/sys-devel/gcc-10.0.0_pre9999/work/gcc-10.0.0_pre9999/gcc/tree-eh.c:2518 0x8859dd tree_could_trap_p(tree_node*) /var/tmp/portage/sys-devel/gcc-10.0.0_pre9999/work/gcc-10.0.0_pre9999/gcc/tree-eh.c:2635 0xf419c1 simple_operand_p_2 /var/tmp/portage/sys-devel/gcc-10.0.0_pre9999/work/gcc-10.0.0_pre9999/gcc/fold-const.c:4451 0xf3dfdf fold_truth_andor /var/tmp/portage/sys-devel/gcc-10.0.0_pre9999/work/gcc-10.0.0_pre9999/gcc/fold-const.c:8290 0xf32048 fold_binary_loc(unsigned int, tree_code, tree_node*, tree_node*, tree_node*) /var/tmp/portage/sys-devel/gcc-10.0.0_pre9999/work/gcc-10.0.0_pre9999/gcc/fold-const.c:10606 0xf30f29 fold_build2_loc(unsigned int, tree_code, tree_node*, tree_node*, tree_node*) /var/tmp/portage/sys-devel/gcc-10.0.0_pre9999/work/gcc-10.0.0_pre9999/gcc/fold-const.c:12382 0xe75b80 c_fully_fold_internal /var/tmp/portage/sys-devel/gcc-10.0.0_pre9999/work/gcc-10.0.0_pre9999/gcc/c/c-fold.c:535 0xe75a8d c_fully_fold_internal /var/tmp/portage/sys-devel/gcc-10.0.0_pre9999/work/gcc-10.0.0_pre9999/gcc/c/c-fold.c:513 0xe75a8d c_fully_fold_internal /var/tmp/portage/sys-devel/gcc-10.0.0_pre9999/work/gcc-10.0.0_pre9999/gcc/c/c-fold.c:513 0xe74fcc c_fully_fold(tree_node*, bool, bool*, bool) /var/tmp/portage/sys-devel/gcc-10.0.0_pre9999/work/gcc-10.0.0_pre9999/gcc/c/c-fold.c:125 0x133862b c_parser_condition /var/tmp/portage/sys-devel/gcc-10.0.0_pre9999/work/gcc-10.0.0_pre9999/gcc/c/c-parser.c:5677 0x13385ae c_parser_paren_condition /var/tmp/portage/sys-devel/gcc-10.0.0_pre9999/work/gcc-10.0.0_pre9999/gcc/c/c-parser.c:5695 0xe724c1 c_parser_if_statement /var/tmp/portage/sys-devel/gcc-10.0.0_pre9999/work/gcc-10.0.0_pre9999/gcc/c/c-parser.c:5874 0xe724c1 c_parser_statement_after_labels /var/tmp/portage/sys-devel/gcc-10.0.0_pre9999/work/gcc-10.0.0_pre9999/gcc/c/c-parser.c:5506 0xe6f363 c_parser_compound_statement_nostart /var/tmp/portage/sys-devel/gcc-10.0.0_pre9999/work/gcc-10.0.0_pre9999/gcc/c/c-parser.c:5185 0x1337970 c_parser_compound_statement /var/tmp/portage/sys-devel/gcc-10.0.0_pre9999/work/gcc-10.0.0_pre9999/gcc/c/c-parser.c:5019 0xe729e7 c_parser_if_body /var/tmp/portage/sys-devel/gcc-10.0.0_pre9999/work/gcc-10.0.0_pre9999/gcc/c/c-parser.c:5749 0xe729e7 c_parser_if_statement /var/tmp/portage/sys-devel/gcc-10.0.0_pre9999/work/gcc-10.0.0_pre9999/gcc/c/c-parser.c:5877 0xe729e7 c_parser_statement_after_labels /var/tmp/portage/sys-devel/gcc-10.0.0_pre9999/work/gcc-10.0.0_pre9999/gcc/c/c-parser.c:5506 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <https://bugs.gentoo.org/> for instructions. I will add the preprocessed source. Created attachment 47019 [details]
preprocessed source
Reduced testcase: int foo (int a, int b, int *c, short *d) { return (c[0] ? b : 0) == 'y' && ((a ? d[0] : c[0]) ? b : 0) == 'c'; } Started with r276659. The fix for this ICE is easy: --- gcc/tree-eh.c.jj 2019-10-07 17:30:31.028153702 +0200 +++ gcc/tree-eh.c 2019-10-11 11:46:37.376774860 +0200 @@ -2615,7 +2615,7 @@ tree_could_trap_p (tree expr) return false; /* For COND_EXPR and VEC_COND_EXPR only the condition may trap. */ - if (TREE_CODE (expr) == COND_EXPR || TREE_CODE (expr) == VEC_COND_EXPR) + while (TREE_CODE (expr) == COND_EXPR || TREE_CODE (expr) == VEC_COND_EXPR) expr = TREE_OPERAND (expr, 0); code = TREE_CODE (expr); though I'm a little bit worried about the tree-ssa-sccvn.c's operation_could_trap_helper_p call, whether it can't call it on COND_EXPR/VEC_COND_EXPR; while there is no assert in operation_could_trap_helper_p for COND_EXPR/VEC_COND_EXPR, if it is ever called, it might not give the right answer. Guess for those fp_operation would be whether the second/third operand and lhs are floating, which might not be related to whether condition is actually a floating point operation. Anyway, will handle the above part and defer the rest to Ilya. Created attachment 47021 [details] gcc10-pr92063.patch Untested fix. Fix works for me Created attachment 47022 [details] gcc10-pr92063.patch Updated patch based on IRC discussions. Hi Jakub, thanks for fixing this! FWIW the patch looks good to me. I have also run my signaling comparison tests on S/390 with it, and they still work. Is there something else I need to look at in context of this problem? Author: jakub Date: Sat Oct 12 12:21:45 2019 New Revision: 276915 URL: https://gcc.gnu.org/viewcvs?rev=276915&root=gcc&view=rev Log: PR middle-end/92063 * tree-eh.c (operation_could_trap_helper_p) <case COND_EXPR> <case VEC_COND_EXPR>: Return false with *handled = false. (tree_could_trap_p): For {,VEC_}COND_EXPR return false instead of recursing on the first operand. * fold-const.c (simple_operand_p_2): Use generic_expr_could_trap_p instead of tree_could_trap_p. * tree-ssa-sccvn.c (vn_nary_may_trap): Formatting fixes. * gcc.c-torture/compile/pr92063.c: New test. Added: trunk/gcc/testsuite/gcc.c-torture/compile/pr92063.c Modified: trunk/gcc/ChangeLog trunk/gcc/fold-const.c trunk/gcc/testsuite/ChangeLog trunk/gcc/tree-eh.c trunk/gcc/tree-ssa-sccvn.c Should be fixed now. *** Bug 92079 has been marked as a duplicate of this bug. *** |