Skip to content

0.66 fails to build from source (autotests fail) on several architectures #1428

Closed

Description

@gerasiov

I've uploaded 0.66 into archive and got build errors on armel/i386/mips64el/s390x

Please see
https://buildd.debian.org/status/package.php?p=uncrustify
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=881249

The problem is in the test:

...
555/798 Test #557: cpp_33057 ........................***Failed    0.10 sec
Files "/<<BUILDDIR>>/uncrustify-0.66+dfsg1/tests/results/cpp/33057-bug_1349.cpp" to "/<<BUILDDIR>>/uncrustify-0.66+dfsg1/tests/output/cpp/33057-bug_1349.cpp" are different.
CMake Error at /<<BUILDDIR>>/uncrustify-0.66+dfsg1/tests/run_test.cmake:54 (message):
  MISSMATCH: results/cpp/33057-bug_1349.cpp does not match
  output/cpp/33057-bug_1349.cpp
...
The following tests FAILED:
	557 - cpp_33057 (Failed)
Errors while running CTest
Makefile:142: recipe for target 'test' failed
make[1]: *** [test] Error 8

I'll try to check the problem as soon as I have free time, but you are welcome to do the analysis yourself (at least on i386).

Activity

  1. added
    Engineering
    on Nov 9, 2017
  2. gerasiov commented on Nov 10, 2017

    @gerasiov
    ContributorAuthor

    Ok, I need to pause my research for now =(

    What did I found.

    1. Problem occurs only in optimized version. (-O1 or -O2)
    2. On i386 output file differs, on amd64 - not.
    3. If you use -p flag uncustify segfaults on both archs. (Looks like this problem is somehow linked with original one.)
    4. segfault occurs with gcc 6.3, gcc 7.2 but not with clang (3.8)

    Steps to reproduce segfault:

    $ cat bug_1349.cfg

    align_struct_init_span = 5
    

    $ cat bug_1349.cpp

    uint8_t a[][8]={{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}};
    

    Then run the following commands:

    rm -rf build && mkdir build
    (
    cd build
    export CXXFLAGS="-g -O1" 
    cmake .. -DCMAKE_VERBOSE_MAKEFILE=ON
    make 
    )
    
    "./build/uncrustify" -q -c bug_1349.cfg -f bug_1349.cpp  -o /tmp/33057-bug_1349.cpp -p /tmp/33057-bug_1349.cpp.unc
    

    And you should catch segmentation fault.

    There are also some differences in logfile produced with -LA if you compare optimized and no-optimized versions.

  3. gerasiov commented on Nov 10, 2017

    @gerasiov
    ContributorAuthor

    Ah. I checked old versions and found the problem exists at least since switch to cmake.

  4. gerasiov commented on Nov 10, 2017

    @gerasiov
    ContributorAuthor

    Stracktrace itself:

    Program received signal SIGSEGV, Segmentation fault.
    0x00005555555b255a in std::char_traits<char>::length (__s=0x170 <error: Cannot access memory at address 0x170>) at /usr/include/c++/6/bits/char_traits.h:267
    267	      { return __builtin_strlen(__s); }
    (gdb) where
    #0  0x00005555555b255a in std::char_traits<char>::length (__s=0x170 <error: Cannot access memory at address 0x170>) at /usr/include/c++/6/bits/char_traits.h:267
    #1  std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string (__a=..., __s=0x170 <error: Cannot access memory at address 0x170>, this=0x7fffffffc420)
        at /usr/include/c++/6/bits/basic_string.h:456
    #2  op_val_to_string[abi:cxx11](argtype_e, op_val_t) (argtype=AT_STRING, op_val=...)
        at ./src/options.cpp:2782
    #3  0x00005555555b2979 in save_option_file_kernel (pfile=pfile@entry=0x5555558f7130, withDoc=withDoc@entry=false, only_not_default=only_not_default@entry=true)
        at ./src/options.cpp:2295
    #4  0x00005555555b46a7 in output_parsed (pfile=0x5555558f7130) at ./src/output.cpp:410
    #5  0x00005555555dd740 in uncrustify_file (fm=..., pfout=0x555555883a40, parsed_file=0x7fffffffe26b "/tmp/33057-bug_1349.cpp.unc", defer_uncrustify_end=<optimized out>)
        at ./src/uncrustify.cpp:1941
    #6  0x00005555555de52b in do_source_file (filename_in=0x7fffffffe240 "bug_1349.cpp", filename_out=<optimized out>, parsed_file=0x7fffffffe26b "/tmp/33057-bug_1349.cpp.unc", 
        no_backup=<optimized out>, keep_mtime=<optimized out>) at ./src/uncrustify.cpp:1326
    #7  0x00005555555df7a9 in main (argc=<optimized out>, argv=<optimized out>)
        at ./src/uncrustify.cpp:780
    
  5. CDanU commented on Nov 10, 2017

    @CDanU
    Collaborator

    Thanks for the trace, I however don't really see a problem in the op_val_to_string function.

    I actually have a blank line at 2782, so that should be either

    return(tfi_to_string(op_val.tfi));

    but that can't happen as there currently no TFI options to trigger this
    or

    fprintf(stderr, "%s(%d): Unknown argtype '%d'\n", __func__, __LINE__, argtype);

    Only the number_to_string function in op_val_to_string is slightly sketchy, that is going to be replaced by std::to_string soon.


    Ohh maybe it is accessing the union in a wrong way


    -p has to be used to enter the output_parsed function
    note that this happens on the 33057-bug_1349.cpp.unc file, I think this happens on the rerun test step


    the tests don't use the -p flag ...
    @gerasiov: did you use the -p flag here? If so this might be an entirely different bug.


    I modified the check_option.py script a bit, all cpd.settings[<option>].XXX union accessors seem to be the proper ones.

  6. guy-maurel commented on Nov 10, 2017

    @guy-maurel
    Contributor

    I am working on it.
    The problem seams to be very deep.

  7. guy-maurel commented on Nov 10, 2017

    @guy-maurel
    Contributor

    The use of export CXXFLAGS="-g -O1" produce also at me many errors.
    The problem is not at the output.cpp but deeper.

  8. CDanU commented on Nov 10, 2017

    @CDanU
    Collaborator

    Keep in mind that you are throwing away the -std=gnu++0x, the compiler might complain that we are using c++11 stuff.
    Building with -Wall -Wextra -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -g -O1 -std=gnu++0x I don't get errors or warnings on my box.

    Why are we using -std=gnu++0x here instead of -std=c++11?

  9. guy-maurel commented on Nov 11, 2017

    @guy-maurel
    Contributor

    Error found.
    At align.cpp about lines 1688.. is:

                cpd.al[cpd.al_cnt].type = pc->type;
                cpd.al[cpd.al_cnt].col  = pc->column;
                cpd.al[cpd.al_cnt].len  = token_width;
    

    Nothing to control cpd.al_cnt which becomes 81 at column 358 from the input file bug_139.cpp,
    but the array al is declared as:
    align_t al[80];
    which is the address of
    cpd.settings[1].n
    There might be some more places that must be controled.

  10. guy-maurel commented on Nov 12, 2017

    @guy-maurel
    Contributor

    #1438 is a bugfix proposal. Look also at #1349
    Please test it and report.

  11. misery commented on Nov 15, 2017

    @misery

    Same on AlpineLinux: alpinelinux/aports@8dd2436

  12. guy-maurel commented on Nov 16, 2017

    @guy-maurel
    Contributor

    Could you please test the current git version at 82c2a89
    and report.

  13. gerasiov commented on Nov 17, 2017

    @gerasiov
    ContributorAuthor

    4597d37 works fine for me.
    All autotests pass on several architectures I tried.
    Waiting for release to upload it into Debian. Good work.

  14. misery commented on Nov 24, 2017

    @misery

    Thanks... 0.66.1 fixed Alpine, too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Engineering

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions