Started Segfaulting :frowning_face:

Last week I updated my Cygwin environment and this week I recompiled Kakoune. Now when I try to do a backward match with the ‘m’ key I get a segfault. I thought maybe it was just something to do with the latest release, but I’ve tried releases all the way back to 2019 and they all have the same problem. I know I’ve used a more recent release without issue, so I’m thinking it’s my build tools. I’m using g++ (GCC) 11.2.0, below is some data on the fault.

I’ve tried debugging this myself but I don’t have a lot of experience debugging C++ templates. Breaking at the select() and stepping down to the read_codepoint() is a tedious process. At frame 1, iterator ‘it’ looks fine so I’m thinking as the iterator is advanced it becomes invalid at some point. But I’m also thinking that my compiler/environment is messing this up somehow since I seem to be the only one with the issue.

Solved my own problem. Always happens after I post :sweat_smile:. I downgraded g++ to g++ (GCC) 10.2.0 in the Cygwin repo and it works properly now. I will say trying to compile master does result in this lovely error, but the last release tag works.

g++ -D_XOPEN_SOURCE=700 -O3 -pedantic -std=c++2a -g -Wall -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-address -Wno-init-list-lifetime -MD -MP -MF .client.opt.d -c -o .client.opt.o
In file included from face_registry.hh:5,
                 from scope.hh:5,
                 from buffer.hh:12,
                 from selection.hh:4,
                 from context.hh:4,
                 from input_handler.hh:6,
                 from client.hh:7,
utils.hh: In instantiation of ‘Kakoune::FunctionRef<Res(Args ...)>::FunctionRef(Target&&) [with Target = Kakoune::Client::generate_mode_line() const::<lambda(Kakoune::String)>; Res = Kakoune::String; Args = {Kakoune::String}]’:   required from here
utils.hh:181:31: internal compiler error: in tsubst_pack_expansion, at cp/pt.c:12928
  181 |             requires not std::is_same_v<FunctionRef, std::remove_cvref_t<Target>>;
      |                          ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Please submit a full bug report,
with preprocessed source if appropriate.
See <> for instructions.
make: *** [Makefile:104: .client.opt.o] Error 1

The README on the master branch says “GCC >= 10.3”, so it’s not surprising that 10.2.0 fails to build correctly. It’s weird that 11.2.0 fails to build correctly, though - I’ve been building with that version on Debian Linux and Kakoune seems fine - both m and <a-m> work for me.

On Cygwin, can you build Kakoune with make debug=yes sanitize=address or make debug=yes sanitize=undefined? If you can, do those builds crash in a more interesting/useful fashion?

Sanitize isn’t available for Cygwin g++ 11, but adding the debug flag prevents the ‘m’ segfault. I haven’t fully tested it yet, but I’ll install the debug version and use it for a few days to see if it crashes.