Opened 5 years ago

Closed 4 years ago

Last modified 4 years ago

#5749 closed defect (fixed)

Segmentation fault during omc compilation with gcc (v1.14.0)

Reported by: florentine.rosiere@… Owned by: Adrian Pop
Priority: high Milestone: 1.16.0
Component: Build Environment Version:
Keywords: Cc:

Description

Hello,

With gcc 8.3.1 and Fedora29 I get a segmentation while compiling omc v1.14.0:

make omc

...
<OM_PATH>/build/bin/omc -d=failtrace -g=MetaModelica OpenModelicaScriptingAPI.mos

Limited backtrace at point of segmentation fault
<OM_PATH>/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaRuntimeC.so(+0x17c54)[0x7f179b81bc54]
/lib64/libc.so.6(+0x38600)[0x7f179b93e600]
<OM_PATH>/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(omc_FGraphBuildEnv_mkProgramGraph+0x33)[0x7f179bfeed63]
<OM_PATH>/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(omc_Builtin_initialGraph+0x1a1)[0x7f179c2e0271]
<OM_PATH>/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(omc_Inst_makeEnvFromProgram+0x40)[0x7f179c1a1330]
<OM_PATH>/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(omc_SymbolTable_buildEnv+0x43)[0x7f179bf4bc43]
<OM_PATH>/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(omc_Interactive_evaluateExpr+0x108)[0x7f179bfb0868]
<OM_PATH>/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(omc_Interactive_evaluateExprToStr+0x1b3)[0x7f179bfb0c23]
<OM_PATH>/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(omc_Interactive_evaluate2+0x1c5)[0x7f179bfb2e05]
<OM_PATH>/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(omc_Interactive_evaluateToStdOut+0x9e)[0x7f179bfb380e]
<OM_PATH>/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(omc_Main_translateFile+0x5d3)[0x7f179bdc20d3]
<OM_PATH>/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(omc_Main_main2+0x468)[0x7f179bdc3bb8]
<OM_PATH>/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(omc_Main_main+0x414)[0x7f179bdc4294]
<OM_PATH>/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(omc_main+0x1e6)[0x7f179c30ab66]
/lib64/libc.so.6(
libc_start_main+0xf3)[0x7f179b92a413]
make[5]: * [Makefile.common:4: OpenModelicaScriptingAPI.mo] Erreur de segmentation (core dump créé)

with clang it compiles properly.

Thank you and Regards

Change History (18)

comment:1 by florentine.rosiere@…, 4 years ago

Hi,

This issue is still there in 1.14.2.

Regards

comment:2 by Francesco Casella, 4 years ago

@florentine, we are going to release 1.16.0-beta.01 next week. Could you try with the latest 1.16.0 nightly build and report if you still have this issue?

Thanks!

comment:3 by florentine.rosiere@…, 4 years ago

Hi,

I tried on the master yesterday and the issue was still there.
This is preventing us from using latest versions of OpenModelica.

Thank you for your response!
Regards,
Florentine

comment:4 by Adrian Pop, 4 years ago

Can you try to configure with CFLAGS=-g?

./configure CC=gcc CXX=g++ CFLAGS='-g'

and see if you don't get a crash?

You could also try to compile with Clang:

./configure CC=clang CXX=clang++

As far as I can see it dies while using the newly build omc to generate the Qt API for OMEdit.
I'll see if I can get my hand on a VM image with Fedora29 and gcc 8.3.1 to do proper testing.

comment:5 by florentine.rosiere@…, 4 years ago

Hi,

The compilation passes with the CFLAGS='-g' option.
It also passes with clang in all the cases, but we do need to compile with gcc as our servers does not support clang.

Thank you,
Regards,
Florentine

comment:6 by Francesco Casella, 4 years ago

Component: *unknown*Installation program
Milestone: Future1.16.0
Owner: changed from somebody to Adrian Pop
Status: newassigned

comment:7 by Adrian Pop, 4 years ago

Component: Installation programBuild Environment
Status: assignedaccepted

comment:8 by Adrian Pop, 4 years ago

What Fedora 29 distribution do you have? Workstation? Server?

comment:9 by Adrian Pop, 4 years ago

Also, I assume you have 64 bit OS, not 32 bit one.

comment:10 by florentine.rosiere@…, 4 years ago

Hi,

this is Fedora 29 Workstation Edition 64 bit.
We are currently trying to compile the master with a more recent gcc version, we'll let you know if it passes asap.

Thank you,
Regards,
Florentine

comment:11 by gautier.bureau@…, 4 years ago

The error can be reproduced with the following steps:

docker run -it fedora:29

dnf install -y git gcc gcc-c++ gcc-gfortran autoconf automake make libtool cmake hwloc java-1.8.0-openjdk-devel blas-devel lapack-devel lpsolve-devel expat-devel glibc-devel sqlite-devel xerces-c-devel libarchive-devel zlib-devel qt-devel gettext patch wget python-devel clang llvm-devel ncurses-devel readline-devel unzip perl-Digest-MD5 vim gcovr python-pip python-psutil boost-devel lcov gtest-devel gmock-devel xz rsync python-lxml graphviz clang-devel OpenSceneGraph-devel qtwebkit qtwebkit-devel qt5-qtwebkit qt5-qtwebkit-devel qwt python-sphinx qwt-devel OpenSceneGraph-qt-devel OpenSceneGraph-devel OpenSceneGraph-libs OpenSceneGraph-qt OpenSceneGraph-qt-devel qwt5-qt4-devel glibc-static libstdc++-static omniORB-devel poppler-devel flex bison maven curl-devel uuid-devel qt5-linguist qt5-qtsvg-devel qt5-qtxmlpatterns-devel

git clone https://github.com/OpenModelica/OpenModelica.git \
&& cd OpenModelica \
&& git submodule init \
&& git submodule update \
&& git submodule foreach --recursive 'git submodule init' \
&& git submodule foreach --recursive 'git submodule update'

autoconf \
&& ./configure CC=gcc CXX=g++ --disable-modelica3d --disable-omnotebook --disable-omshell-terminal --with-qwt=NO \
&& make omc

A similar procedure with an ubuntu:20.04 docker has been tested and worked, gcc version is 9.3.0.

comment:12 by Adrian Pop, 4 years ago

I could reproduce it on my Fedora 29 Workstation VirtualBox VM. I'm debugging it now.

comment:13 by Adrian Pop, 4 years ago

Slicing down through gcc -O2 flags to see which one is to blame is really fun. I started with the last one that is different from -O1: -ftree-vrp.

  • .txt"

    diff --git a/O1-opts.txt b/O2-opts.txt
    index c872fb9..8f13d1c 100644
    old new The following options control optimizations:  
    55  -Os                             
    66  -faggressive-loop-optimizations   [enabled]
    77  -falign-functions               [disabled]
    8   -falign-functions=              1
     8  -falign-functions=              16
    99  -falign-jumps                   [disabled]
    10   -falign-jumps=                  1
    11   -falign-labels                  [disabled]
    12   -falign-labels=                 1
     10  -falign-jumps=                  16
     11  -falign-labels                  [enabled]
     12  -falign-labels=                 0
    1313  -falign-loops                   [disabled]
    14   -falign-loops=                  1
     14  -falign-loops=                  16
    1515  -fassociative-math              [disabled]
    1616  -fasynchronous-unwind-tables    [enabled]
    1717  -fauto-inc-dec                  [enabled]
    The following options control optimizations:  
    2020  -fbranch-target-load-optimize   [disabled]
    2121  -fbranch-target-load-optimize2  [disabled]
    2222  -fbtr-bb-exclusive              [disabled]
    23   -fcaller-saves                  [disabled]
    24   -fcode-hoisting                 [disabled]
     23  -fcaller-saves                  [enabled]
     24  -fcode-hoisting                 [enabled]
    2525  -fcombine-stack-adjustments     [enabled]
    2626  -fcompare-elim                  [enabled]
    2727  -fconserve-stack                [disabled]
    2828  -fcprop-registers               [enabled]
    29   -fcrossjumping                  [disabled]
    30   -fcse-follow-jumps              [disabled]
     29  -fcrossjumping                  [enabled]
     30  -fcse-follow-jumps              [enabled]
    3131  -fcx-fortran-rules              [disabled]
    3232  -fcx-limited-range              [disabled]
    3333  -fdce                           [enabled]
    The following options control optimizations:  
    3535  -fdelayed-branch                [disabled]
    3636  -fdelete-dead-exceptions        [disabled]
    3737  -fdelete-null-pointer-checks    [enabled]
    38   -fdevirtualize                  [disabled]
    39   -fdevirtualize-speculatively    [disabled]
     38  -fdevirtualize                  [enabled]
     39  -fdevirtualize-speculatively    [enabled]
    4040  -fdse                           [enabled]
    4141  -fearly-inlining                [enabled]
    4242  -fexceptions                    [disabled]
    43   -fexpensive-optimizations       [disabled]
     43  -fexpensive-optimizations       [enabled]
    4444  -ffast-math                     
    4545  -ffinite-math-only              [disabled]
    4646  -ffloat-store                   [disabled]
    The following options control optimizations:  
    4848  -ffp-contract=[off|on|fast]     fast
    4949  -ffp-int-builtin-inexact        [enabled]
    5050  -ffunction-cse                  [enabled]
    51   -fgcse                          [disabled]
     51  -fgcse                          [enabled]
    5252  -fgcse-after-reload             [disabled]
    5353  -fgcse-las                      [disabled]
    5454  -fgcse-lm                       [enabled]
    The following options control optimizations:  
    5757  -fgraphite-identity             [disabled]
    5858  -fguess-branch-probability      [enabled]
    5959  -fhandle-exceptions             
    60   -fhoist-adjacent-loads          [disabled]
     60  -fhoist-adjacent-loads          [enabled]
    6161  -fif-conversion                 [enabled]
    6262  -fif-conversion2                [enabled]
    63   -findirect-inlining             [disabled]
     63  -findirect-inlining             [enabled]
    6464  -finline                        [enabled]
    6565  -finline-atomics                [enabled]
    6666  -finline-functions              [disabled]
    6767  -finline-functions-called-once  [enabled]
    68   -finline-small-functions        [disabled]
    69   -fipa-bit-cp                    [disabled]
    70   -fipa-cp                        [disabled]
     68  -finline-small-functions        [enabled]
     69  -fipa-bit-cp                    [enabled]
     70  -fipa-cp                        [enabled]
    7171  -fipa-cp-clone                  [disabled]
    72   -fipa-icf                       [disabled]
    73   -fipa-icf-functions             [disabled]
    74   -fipa-icf-variables             [disabled]
     72  -fipa-icf                       [enabled]
     73  -fipa-icf-functions             [enabled]
     74  -fipa-icf-variables             [enabled]
    7575  -fipa-profile                   [enabled]
    7676  -fipa-pta                       [disabled]
    7777  -fipa-pure-const                [enabled]
    78   -fipa-ra                        [disabled]
     78  -fipa-ra                        [enabled]
    7979  -fipa-reference                 [enabled]
    80   -fipa-sra                       [disabled]
    81   -fipa-vrp                       [disabled]
     80  -fipa-sra                       [enabled]
     81  -fipa-vrp                       [enabled]
    8282  -fira-algorithm=[CB|priority]   CB
    8383  -fira-hoist-pressure            [enabled]
    8484  -fira-loop-pressure             [disabled]
    The following options control optimizations:  
    8686  -fira-share-save-slots          [enabled]
    8787  -fira-share-spill-slots         [enabled]
    8888  -fisolate-erroneous-paths-attribute   [disabled]
    89   -fisolate-erroneous-paths-dereference   [disabled]
     89  -fisolate-erroneous-paths-dereference   [enabled]
    9090  -fivopts                        [enabled]
    9191  -fjump-tables                   [enabled]
    9292  -fkeep-gc-roots-live            [disabled]
    The following options control optimizations:  
    9898  -floop-nest-optimize            [disabled]
    9999  -floop-parallelize-all          [disabled]
    100100  -floop-unroll-and-jam           [disabled]
    101   -flra-remat                     [disabled]
     101  -flra-remat                     [enabled]
    102102  -fmath-errno                    [enabled]
    103103  -fmodulo-sched                  [disabled]
    104104  -fmodulo-sched-allow-regmoves   [disabled]
    The following options control optimizations:  
    107107  -fnothrow-opt                   [disabled]
    108108  -fomit-frame-pointer            [enabled]
    109109  -fopt-info                      [disabled]
    110   -foptimize-sibling-calls        [disabled]
    111   -foptimize-strlen               [disabled]
     110  -foptimize-sibling-calls        [enabled]
     111  -foptimize-strlen               [enabled]
    112112  -fpack-struct                   [disabled]
    113113  -fpack-struct=<number>         
    114   -fpartial-inlining              [disabled]
     114  -fpartial-inlining              [enabled]
    115115  -fpatchable-function-entry=     
    116116  -fpeel-loops                    [disabled]
    117117  -fpeephole                      [enabled]
    118   -fpeephole2                     [disabled]
     118  -fpeephole2                     [enabled]
    119119  -fplt                           [enabled]
    120120  -fpredictive-commoning          [disabled]
    121121  -fprefetch-loop-arrays          [enabled]
    The following options control optimizations:  
    124124  -freg-struct-return             [enabled]
    125125  -frename-registers              [enabled]
    126126  -freorder-blocks                [enabled]
    127   -freorder-blocks-algorithm=[simple|stc]   simple
    128   -freorder-blocks-and-partition  [disabled]
    129   -freorder-functions             [disabled]
    130   -frerun-cse-after-loop          [disabled]
     127  -freorder-blocks-algorithm=[simple|stc]   stc
     128  -freorder-blocks-and-partition  [enabled]
     129  -freorder-functions             [enabled]
     130  -frerun-cse-after-loop          [enabled]
    131131  -freschedule-modulo-scheduled-loops   [disabled]
    132132  -frounding-math                 [disabled]
    133133  -frtti                          [enabled]
    The following options control optimizations:  
    149149  -fsched2-use-superblocks        [disabled]
    150150  -fschedule-fusion               [enabled]
    151151  -fschedule-insns                [disabled]
    152   -fschedule-insns2               [disabled]
     152  -fschedule-insns2               [enabled]
    153153  -fsection-anchors               [disabled]
    154154  -fsel-sched-pipelining          [disabled]
    155155  -fsel-sched-pipelining-outer-loops  [disabled]
    The following options control optimizations:  
    178178  -fstack-protector-strong        [disabled]
    179179  -fstack-reuse=[all|named_vars|none]   all
    180180  -fstdarg-opt                    [enabled]
    181   -fstore-merging                 [disabled]
    182   -fstrict-aliasing               [disabled]
     181  -fstore-merging                 [enabled]
     182  -fstrict-aliasing               [enabled]
    183183  -fstrict-enums                  [disabled]
    184184  -fstrict-volatile-bitfields     [enabled]
    185   -fthread-jumps                  [disabled]
     185  -fthread-jumps                  [enabled]
    186186  -fno-threadsafe-statics         [enabled]
    187187  -ftracer                        [disabled]
    188188  -ftrapping-math                 [enabled]
    The following options control optimizations:  
    210210  -ftree-parallelize-loops=<number>   1
    211211  -ftree-partial-pre              [disabled]
    212212  -ftree-phiprop                  [enabled]
    213   -ftree-pre                      [disabled]
     213  -ftree-pre                      [enabled]
    214214  -ftree-pta                      [enabled]
    215215  -ftree-reassoc                  [enabled]
    216216  -ftree-scev-cprop               [enabled]
    The following options control optimizations:  
    218218  -ftree-slp-vectorize            [disabled]
    219219  -ftree-slsr                     [enabled]
    220220  -ftree-sra                      [enabled]
    221   -ftree-switch-conversion        [disabled]
    222   -ftree-tail-merge               [disabled]
     221  -ftree-switch-conversion        [enabled]
     222  -ftree-tail-merge               [enabled]
    223223  -ftree-ter                      [enabled]
    224224  -ftree-vectorize               
    225   -ftree-vrp                      [disabled]
     225  -ftree-vrp                      [enabled]
    226226  -funconstrained-commons         [disabled]
    227227  -funroll-all-loops              [disabled]
    228228  -funroll-loops                  [disabled]
    The following options control optimizations:  
    234234  -fvar-tracking-assignments-toggle   [disabled]
    235235  -fvar-tracking-uninit           [disabled]
    236236  -fvariable-expansion-in-unroller  [disabled]
    237   Specifies the cost model for vectorization. -fvect-cost-model=[unlimited|dynamic|cheap]   [default]
     237  Specifies the cost model for vectorization. -fvect-cost-model=[unlimited|dynamic|cheap]   cheap
    238238  -fvpt                           [disabled]
    239239  -fweb                           [enabled]
    240240  -fwrapv                         [disabled]

It seems to work with gcc 8.3.1 using:

./configure CFLAGS='-g -O2 -fno-tree-vrp'

I will investigate more and if this is the case I will fix configure to disable optimization -ftree-vrp after -O2. We do similar stuff for gcc 5.3 as it has some bad optimizations as well.

Version 1, edited 4 years ago by Adrian Pop (previous) (next) (diff)

comment:14 by Adrian Pop, 4 years ago

Fixed with: 62e977/OpenModelica.
Please test and reopen if needed.

comment:15 by Adrian Pop, 4 years ago

Resolution: fixed
Status: acceptedclosed

comment:16 by Francesco Casella, 4 years ago

Milestone: 1.16.01.17.0

I guess this is fixed in 1.17.0 but not in 1.16.0, unless the commit is back-ported.

@sjoelund.se, would that be easy to do?

comment:18 by Francesco Casella, 4 years ago

Milestone: 1.17.01.16.0

Thank you @adrpo!

Note: See TracTickets for help on using tickets.