gansm / finalcut

A text-based widget toolkit
https://github.com/gansm/finalcut/wiki/First-steps#first-steps-with-the-final-cut-widget-toolkit
GNU Lesser General Public License v3.0
981 stars 52 forks source link

.configure wrong for CPPUNIT #104

Open Barchfeld opened 2 years ago

Barchfeld commented 2 years ago

Describe the bug

I have to comment the line

PKG_CHECK_MODULES(CPPUNIT, cppunit > 1.12.0)

How to reproduce the bug?

if this line is uncommented, an error message will appear ./configure: line 14540: syntax error near unexpected token CPPUNIT,' ./configure: line 14540: PKG_CHECK_MODULES(CPPUNIT, cppunit > 1.12.0)'

What behavior did you expect?

No error message

In which environment did the bug occur?

gansm commented 2 years ago

That's odd. Ubuntu 20.04 should provide CppUnit in version 1.15.1-2.

What screen output do you get with these commands?

pkg-config --print-provides cppunit
dpkg -s $(dpkg -l '*cppunit*' | grep 'libcppunit-[0-9]' | cut -d' ' -f3) | grep '^Version:'
Barchfeld commented 2 years ago

thanks for the quick reply

pkg-config --print-provides cppunit cppunit = 1.15.1

dpkg -s $(dpkg -l 'cppunit' | grep 'libcppunit-[0-9]' | cut -d' ' -f3) | grep '^Version:' Version: 1.15.1-2build1

cat /etc/os-release NAME="Ubuntu" VERSION="20.04.4 LTS (Focal Fossa)" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu 20.04.4 LTS" VERSION_ID="20.04"

I've made a 'make distclean' followed by 'autoreconf ... etc.' --> no error ...

gansm commented 2 years ago

Sorry to ask again, did you not install anything afterwards (e.g. pkg-config) between your two tests?

Barchfeld commented 2 years ago

Could be. I have installed other packages in the meantime. I did the same for Ubuntu 20.04 on WSL (Windows 10). No errors. Must have been my mistake.

After no more errors were displayed, I ran the following:

make distclean
autoreconf --install --force
./configure --prefix=/usr CXXFLAGS="-g -O0 -DDEBUG -DUNIT_TEST" --with-unit-test
make test
gcc is gcc-12.1.0

cat test-suite.log
=========================================
   finalcut 0.8.1: test/test-suite.log
=========================================

# TOTAL: 28
# PASS:  27
# SKIP:  0
# XFAIL: 0
# FAIL:  1
# XPASS: 0
# ERROR: 0

.. contents:: :depth: 2

FAIL: fkeyboard_test
====================

FKeyboardTest::classNameTest : OK
FKeyboardTest::noArgumentTest : OK
FKeyboardTest::KeyLengthTest : OK
FKeyboardTest::escapeKeyTest
FAIL fkeyboard_test (exit status: 139)
gansm commented 2 years ago

This looks like the problem I fixed last week. Since the Linux kernel 5.13.0-1023 the behavior of the ioctl TIOCSTI has changed, so that after an EOT no further characters can be read. Therefore, I had to change input("A"); input("B"); to input("AB"); in my fkeyboard unit test.

The fix: https://github.com/gansm/finalcut/commit/317883a82bc9c7bba9137746b115bfffcf3bba25#diff-0aa01eb3aba1ae0b403c91b3478d00fae585cf400b0bea930a50eba1b87b99c2

I think you are still using a version before May 25, 2022 that did not have this fix in it. Please try again with the latest version.

Barchfeld commented 2 years ago

I moved the "old" directory and start:

$ git clone https://github.com/gansm/finalcut.git
$ cd finalcut
$ git status
On branch main
Your branch is up to date with 'origin/main'.

nothing to commit, working tree clean

$ git pull https://github.com/gansm/finalcut.git
From https://github.com/gansm/finalcut
 * branch              HEAD       -> FETCH_HEAD
Already up to date.

$ autoreconf --install --force

$ ./configure --prefix=/usr CXXFLAGS="-g -O0 -DDEBUG -DUNIT_TEST" --with-unit-test

$ make test
...
make[3]: Entering directory '/home/astro/projects/finalcut/test'
PASS: fcallback_test
PASS: fcolorpair_test
PASS: fdata_test
PASS: fevent_test
PASS: char_ringbuffer_test
^[O[../test-driver: line 107: 19567 Segmentation fault      "$@" > $log_file 2>&1
FAIL: fkeyboard_test
PASS: flogger_test
PASS: fmouse_test
PASS: fobject_test
PASS: foptiattr_test
PASS: foptimove_test
PASS: fpoint_test
PASS: frect_test
PASS: fsize_test
PASS: fstringstream_test
PASS: fstring_test
PASS: fstyle_test
PASS: ftermcapquirks_test
PASS: ftermcap_test
PASS: ftermdata_test
PASS: ftermdetection_test
PASS: ftermfreebsd_test
PASS: fterm_functions_test
PASS: ftermlinux_test
PASS: ftermopenbsd_test
PASS: fvterm_test
PASS: fvtermattribute_test
PASS: fvtermbuffer_test
============================================================================
Testsuite summary for finalcut 0.8.1
============================================================================
# TOTAL: 28
# PASS:  27
# SKIP:  0
# XFAIL: 0
# FAIL:  1
# XPASS: 0
# ERROR: 0
============================================================================
See test/test-suite.log
============================================================================

$ cat test-suite.log
=========================================
   finalcut 0.8.1: test/test-suite.log
=========================================

# TOTAL: 28
# PASS:  27
# SKIP:  0
# XFAIL: 0
# FAIL:  1
# XPASS: 0
# ERROR: 0

.. contents:: :depth: 2

FAIL: fkeyboard_test
====================

FKeyboardTest::classNameTest : OK
FKeyboardTest::noArgumentTest : OK
FKeyboardTest::KeyLengthTest : OK
FKeyboardTest::escapeKeyTest
FAIL fkeyboard_test (exit status: 139)
gansm commented 2 years ago

What happens if you start the unit test separately?

& test/fkeyboard_test

Please do not make any keystrokes while the test is running. Ensure that no background processes are running that can output characters to the terminal.

When the process crashes, a backtrace would be helpful.

& LD_LIBRARY_PATH=final/.libs/ gdb test/.libs/fkeyboard_test
(gdb) run
(gdb) bt

By the way, here is a successful run of all unit tests on Ubuntu 20.04.4:

https://github.com/gansm/finalcut/runs/6643674091?check_suite_focus=true (Section "Build with with gcov")

Barchfeld commented 2 years ago
(gdb) run
Starting program:
No executable file specified.

$ file test/fkeyboard_test
test/fkeyboard_test: Bourne-Again shell script, ASCII text executable

Therefor I've started (in the meantime i have added some debug output ;-) ):

$ test/.libs/fkeyboard_test
FKeyboardTest::classNameTest : OK
FKeyboardTest::noArgumentTest : OK
FKeyboardTest::KeyLengthTest : OK
FKeyboardTest::escapeKeyTest
Start escapeKeyTest:
Mintty: input
^[O[Mintty: processInput
Segmentation fault

(gdb) run
Starting program: /home/astro/projects/finalcut/test/.libs/fkeyboard_test
warning: File "/usr/local/gcc-12.1.0/lib64/libstdc++.so.6.0.30-gdb.py" auto-loading has been declined by your `auto-load safe-path' set to "$debugdir:$datadir/auto-load".
To enable execution of this file add
        add-auto-load-safe-path /usr/local/gcc-12.1.0/lib64/libstdc++.so.6.0.30-gdb.py
line to your configuration file "/home/astro/.gdbinit".
To completely disable this security protection add
        set auto-load safe-path /
line to your configuration file "/home/astro/.gdbinit".
For more information about this security protection see the
"Auto-loading safe path" section in the GDB manual.  E.g., run from the shell:
        info "(gdb)Auto-loading safe path"
FKeyboardTest::classNameTest : OK
FKeyboardTest::noArgumentTest : OK
FKeyboardTest::KeyLengthTest : OK
FKeyboardTest::escapeKeyTest
Start escapeKeyTest:
Mintty: input
^[O[Mintty: processInput
Program received signal SIGSEGV, Segmentation fault.
__strncmp_avx2 () at ../sysdeps/x86_64/multiarch/strcmp-avx2.S:693
693     ../sysdeps/x86_64/multiarch/strcmp-avx2.S: No such file or directory.

(gdb) bt
#0  __strncmp_avx2 () at ../sysdeps/x86_64/multiarch/strcmp-avx2.S:693
#1  0x00007ffff7ea5ecb in finalcut::FKeyboard::parseKeyString() () from /lib/libfinal.so.0
#2  0x00007ffff7ea73d1 in finalcut::FKeyboard::parseKeyBuffer() () from /lib/libfinal.so.0
#3  0x0000000000455c5e in FKeyboardTest::processInput (this=0x4894d0) at fkeyboard-test.cpp:3096
#4  0x000000000040dc56 in FKeyboardTest::escapeKeyTest (this=0x4894d0) at fkeyboard-test.cpp:460
#5  0x000000000045b79e in std::__invoke_impl<void, void (FKeyboardTest::*&)(), FKeyboardTest*&> (
    __f=@0x485c50: (void (FKeyboardTest::*)(FKeyboardTest * const)) 0x40db70 <FKeyboardTest::escapeKeyTest()>, __t=@0x485c60: 0x4894d0)
    at /usr/local/gcc-12.1.0/include/c++/12.1.0/bits/invoke.h:74
#6  0x000000000045b6cb in std::__invoke<void (FKeyboardTest::*&)(), FKeyboardTest*&> (
    __fn=@0x485c50: (void (FKeyboardTest::*)(FKeyboardTest * const)) 0x40db70 <FKeyboardTest::escapeKeyTest()>) at /usr/local/gcc-12.1.0/include/c++/12.1.0/bits/invoke.h:96
#7  0x000000000045b5ce in std::_Bind<void (FKeyboardTest::*(FKeyboardTest*))()>::__call<void, , 0ul>(std::tuple<>&&, std::_Index_tuple<0ul>) (this=0x485c50, __args=...)
    at /usr/local/gcc-12.1.0/include/c++/12.1.0/functional:484
#8  0x000000000045b1fc in std::_Bind<void (FKeyboardTest::*(FKeyboardTest*))()>::operator()<, void>() (this=0x485c50) at /usr/local/gcc-12.1.0/include/c++/12.1.0/functional:567
#9  0x000000000045acca in std::__invoke_impl<void, std::_Bind<void (FKeyboardTest::*(FKeyboardTest*))()>&>(std::__invoke_other, std::_Bind<void (FKeyboardTest::*(FKeyboardTest*))()>&) (
    __f=...) at /usr/local/gcc-12.1.0/include/c++/12.1.0/bits/invoke.h:61
#10 0x000000000045a7c7 in std::__invoke_r<void, std::_Bind<void (FKeyboardTest::*(FKeyboardTest*))()>&>(std::_Bind<void (FKeyboardTest::*(FKeyboardTest*))()>&) (__fn=...)
    at /usr/local/gcc-12.1.0/include/c++/12.1.0/bits/invoke.h:154
#11 0x000000000045a22d in std::_Function_handler<void (), std::_Bind<void (FKeyboardTest::*(FKeyboardTest*))()> >::_M_invoke(std::_Any_data const&) (__functor=...)
    at /usr/local/gcc-12.1.0/include/c++/12.1.0/bits/std_function.h:290
#12 0x0000000000458b5a in std::function<void ()>::operator()() const (this=0x4895a0) at /usr/local/gcc-12.1.0/include/c++/12.1.0/bits/std_function.h:591
#13 0x000000000045bafe in CppUnit::TestCaller<FKeyboardTest>::runTest (this=0x489560) at /usr/include/cppunit/TestCaller.h:175
#14 0x00007ffff7dd5615 in CppUnit::TestCaseMethodFunctor::operator()() const () from /lib/x86_64-linux-gnu/libcppunit-1.15.so.1
#15 0x00007ffff7dccd76 in CppUnit::DefaultProtector::protect(CppUnit::Functor const&, CppUnit::ProtectorContext const&) () from /lib/x86_64-linux-gnu/libcppunit-1.15.so.1
#16 0x00007ffff7dd3390 in CppUnit::ProtectorChain::protect(CppUnit::Functor const&, CppUnit::ProtectorContext const&) () from /lib/x86_64-linux-gnu/libcppunit-1.15.so.1
#17 0x00007ffff7ddad8b in CppUnit::TestResult::protect(CppUnit::Functor const&, CppUnit::Test*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) ()
   from /lib/x86_64-linux-gnu/libcppunit-1.15.so.1
#18 0x00007ffff7dd53f9 in CppUnit::TestCase::run(CppUnit::TestResult*) () from /lib/x86_64-linux-gnu/libcppunit-1.15.so.1
#19 0x00007ffff7dd5973 in CppUnit::TestComposite::doRunChildTests(CppUnit::TestResult*) () from /lib/x86_64-linux-gnu/libcppunit-1.15.so.1
#20 0x00007ffff7dd5874 in CppUnit::TestComposite::run(CppUnit::TestResult*) () from /lib/x86_64-linux-gnu/libcppunit-1.15.so.1
#21 0x00007ffff7dd5973 in CppUnit::TestComposite::doRunChildTests(CppUnit::TestResult*) () from /lib/x86_64-linux-gnu/libcppunit-1.15.so.1
#22 0x00007ffff7dd5874 in CppUnit::TestComposite::run(CppUnit::TestResult*) () from /lib/x86_64-linux-gnu/libcppunit-1.15.so.1
#23 0x00007ffff7ddacb7 in CppUnit::TestResult::runTest(CppUnit::Test*) () from /lib/x86_64-linux-gnu/libcppunit-1.15.so.1
#24 0x00007ffff7ddd443 in CppUnit::TestRunner::run(CppUnit::TestResult&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) ()
   from /lib/x86_64-linux-gnu/libcppunit-1.15.so.1
#25 0x0000000000455ec9 in main () at ./main-test.inc:21
(gdb)

If I look at https://github.com/maxmind/libmaxminddb/issues/216 it seems, that something is missing at the function call. But it is for strlen, not strcmp.

gansm commented 2 years ago

Sorry for the incorrect gdb command.

#3  0x0000000000455c5e in FKeyboardTest::processInput (this=0x4894d0) at fkeyboard-test.cpp:3096

Very strange, in line 3096 there is no call at all.

grafik

What do you have in line 3096?

sed -n '3096p' test/fkeyboard-test.cpp

Do you get the same result with these commands?

& make distclean
& ./build.sh unit-test

Maybe you still have an old version of libfinal.so.0 installed?

& ldd test/.libs/fkeyboard_test

Even helpful would be to call these debug commands after the crash.

(gdb) frame 3
(gdb) list
(gdb) info locals 
(gdb) frame 2
(gdb) list
(gdb) info locals
Barchfeld commented 2 years ago

Thanks a lot for your service!

grafik

grafik

make distclean
./build.sh unit-test

no difference.

ldd test/.libs/fkeyboard_test
        linux-vdso.so.1 (0x00007ffc6e9a3000)
        libfinal.so.0 => /usr/lib/libfinal.so.0 (0x00007f9e01082000)
        libcppunit-1.15.so.1 => /usr/lib/x86_64-linux-gnu/libcppunit-1.15.so.1 (0x00007f9e01040000)
        libstdc++.so.6 => /usr/local/gcc-12.1.0/lib64/libstdc++.so.6 (0x00007f9e00e18000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f9e00cc9000)
        libgcc_s.so.1 => /usr/local/gcc-12.1.0/lib64/libgcc_s.so.1 (0x00007f9e00ca8000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f9e00ab6000)
        libtinfo.so.6 => /lib/x86_64-linux-gnu/libtinfo.so.6 (0x00007f9e00a84000)
        libgpm.so.2 => /usr/lib/x86_64-linux-gnu/libgpm.so.2 (0x00007f9e0087e000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f9e00878000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f9e01256000)

On a complete new virtual machine on Win 10 (wsl and Ubuntu 20.04) I get other errors, but also for keyboard...

gansm commented 2 years ago

And the library /usr/lib/libfinal.so.0 is really from the current source code?

& ls -l /usr/lib/libfinal.so.0
& ls -l final/.libs/libfinal.so.0
& dpkg -S /usr/lib/libfinal.so.0
& ldconfig -v | grep 'libfinal'
Barchfeld commented 2 years ago
make distclean
autoreconf --install --force
./build.sh unit-test
make install
make test
...
PASS: fevent_test
PASS: char_ringbuffer_test
^[O[../test-driver: line 107: 350897 Segmentation fault      "$@" > $log_file 2>&1
FAIL: fkeyboard_test
PASS: flogger_test
...
root@h2951296:~/projects/finalcut# ls -l /usr/lib/libfinal.so.0
lrwxrwxrwx 1 root root 17 Jun  1 12:12 /usr/lib/libfinal.so.0 -> libfinal.so.0.8.1
root@h2951296:~/projects/finalcut# ls -l final/.libs/libfinal.so.0
lrwxrwxrwx 1 root root 17 Jun  1 12:10 final/.libs/libfinal.so.0 -> libfinal.so.0.8.1
root@h2951296:~/projects/finalcut# dpkg -S /usr/lib/libfinal.so.0
dpkg-query: Kein Pfad gefunden, der auf Muster /usr/lib/libfinal.so.0 passt
root@h2951296:~/projects/finalcut# ldconfig -v | grep 'libfinal'
/sbin/ldconfig.real: Can't stat /usr/local/lib/x86_64-linux-gnu: No such file or directory
/sbin/ldconfig.real: Path `/lib/x86_64-linux-gnu' given more than once
/sbin/ldconfig.real: Path `/usr/lib/x86_64-linux-gnu' given more than once
/sbin/ldconfig.real: /lib/x86_64-linux-gnu/ld-2.31.so is the dynamic linker, ignoring

        libfinal.so.0 -> libfinal.so.0.8.1
root@h2951296:~/projects/finalcut#

I checked the difference of the 2 libraries:

root@h2951296:~/projects/finalcut# cmp -l /usr/lib/libfinal.so.0 final/.libs/libfinal.so.0 | gawk '{printf "%08X %02X %02X\n", $1, strtonum(0$2), strtonum(0$3)}'
root@h2951296:~/projects/finalcut#

In the file './final/input/fkeyboard.cpp' I#ve made some 'DEBUG BY PRINT':

grafik

' ./test/fkeyboard_test' shows:

...
#### kstr='0x1b4f72' with length ( 3 )
#### kstr='0x1b4f77' with length ( 3 )
#### kstr='0x1b4f79' with length ( 3 )
#### kstr='0x1b4f75' with length ( 3 )
#### kstr='0x1b4f71' with length ( 3 )
#### kstr='0x1b4f73' with length ( 3 )
#### kstr='0xSegmentation fault
gansm commented 2 years ago

Okay, we have the following situation:

It looks like the memory behind kstr was not allocated.

We have the following escape sequences:

 1b 4f 72
ESC  O  r

 1b 4f 77
ESC  O  w

 1b 4f 79 
ESC  O  y

 1b 4f 75
ESC  O  u

 1b 4f 71
ESC  O  q

 1b 4f 73
ESC  O  s

Segmentation fault

input("\033Os") is the last call made by sequencesTest(). The next test is mouseTest(). The first entry here is input("\033[M Z2")

What would be helpful now is buf_len and the content of fifo_buf.

The output of infocmp -x may also be relevant.

Barchfeld commented 2 years ago

grafik

buf_len = 1
#### kstr='0x1b4f77' with length ( 3 )
###### fifo_buf ='0x1b' with length ( 1 )

buf_len = 1
#### kstr='0x1b4f79' with length ( 3 )
###### fifo_buf ='0x1b' with length ( 1 )

buf_len = 1
#### kstr='0x1b4f75' with length ( 3 )
###### fifo_buf ='0x1b' with length ( 1 )

buf_len = 1
#### kstr='0x1b4f71' with length ( 3 )
###### fifo_buf ='0x1b' with length ( 1 )

buf_len = 1
#### kstr='0x1b4f73' with length ( 3 )
###### fifo_buf ='0x1b' with length ( 1 )

buf_len = 1
#### kstr='0xSegmentation fault
root@h2951296:~/projects/finalcut# infocmp -x
#       Reconstructed via infocmp from file: /lib/terminfo/x/xterm
xterm|xterm-debian|X11 terminal emulator,
        OTbs, am, bce, km, mc5i, mir, msgr, npc, xenl, AX, XT,
        colors#8, cols#80, it#8, lines#24, pairs#64,
        acsc=``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
        bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, civis=\E[?25l,
        clear=\E[H\E[2J, cnorm=\E[?12l\E[?25h, cr=\r,
        csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H,
        cud=\E[%p1%dB, cud1=\n, cuf=\E[%p1%dC, cuf1=\E[C,
        cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
        cvvis=\E[?12;25h, dch=\E[%p1%dP, dch1=\E[P, dim=\E[2m,
        dl=\E[%p1%dM, dl1=\E[M, ech=\E[%p1%dX, ed=\E[J, el=\E[K,
        el1=\E[1K, flash=\E[?5h$<100/>\E[?5l, home=\E[H,
        hpa=\E[%i%p1%dG, ht=^I, hts=\EH, ich=\E[%p1%d@,
        il=\E[%p1%dL, il1=\E[L, ind=\n, indn=\E[%p1%dS,
        invis=\E[8m, is2=\E[!p\E[?3;4l\E[4l\E>, kDC=\E[3;2~,
        kEND=\E[1;2F, kHOM=\E[1;2H, kIC=\E[2;2~, kLFT=\E[1;2D,
        kNXT=\E[6;2~, kPRV=\E[5;2~, kRIT=\E[1;2C, kb2=\EOE, kbs=^?,
        kcbt=\E[Z, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA,
        kdch1=\E[3~, kend=\EOF, kent=\EOM, kf1=\EOP, kf10=\E[21~,
        kf11=\E[23~, kf12=\E[24~, kf13=\E[1;2P, kf14=\E[1;2Q,
        kf15=\E[1;2R, kf16=\E[1;2S, kf17=\E[15;2~, kf18=\E[17;2~,
        kf19=\E[18;2~, kf2=\EOQ, kf20=\E[19;2~, kf21=\E[20;2~,
        kf22=\E[21;2~, kf23=\E[23;2~, kf24=\E[24;2~,
        kf25=\E[1;5P, kf26=\E[1;5Q, kf27=\E[1;5R, kf28=\E[1;5S,
        kf29=\E[15;5~, kf3=\EOR, kf30=\E[17;5~, kf31=\E[18;5~,
        kf32=\E[19;5~, kf33=\E[20;5~, kf34=\E[21;5~,
        kf35=\E[23;5~, kf36=\E[24;5~, kf37=\E[1;6P, kf38=\E[1;6Q,
        kf39=\E[1;6R, kf4=\EOS, kf40=\E[1;6S, kf41=\E[15;6~,
        kf42=\E[17;6~, kf43=\E[18;6~, kf44=\E[19;6~,
        kf45=\E[20;6~, kf46=\E[21;6~, kf47=\E[23;6~,
        kf48=\E[24;6~, kf49=\E[1;3P, kf5=\E[15~, kf50=\E[1;3Q,
        kf51=\E[1;3R, kf52=\E[1;3S, kf53=\E[15;3~, kf54=\E[17;3~,
        kf55=\E[18;3~, kf56=\E[19;3~, kf57=\E[20;3~,
        kf58=\E[21;3~, kf59=\E[23;3~, kf6=\E[17~, kf60=\E[24;3~,
        kf61=\E[1;4P, kf62=\E[1;4Q, kf63=\E[1;4R, kf7=\E[18~,
        kf8=\E[19~, kf9=\E[20~, khome=\EOH, kich1=\E[2~,
        kind=\E[1;2B, kmous=\E[M, knp=\E[6~, kpp=\E[5~,
        kri=\E[1;2A, mc0=\E[i, mc4=\E[4i, mc5=\E[5i, meml=\El,
        memu=\Em, op=\E[39;49m, rc=\E8, rev=\E[7m, ri=\EM,
rin=\E[%p1%dT, ritm=\E[23m, rmacs=\E(B, rmam=\E[?7l,
        rmcup=\E[?1049l\E[23;0;0t, rmir=\E[4l, rmkx=\E[?1l\E>,
        rmm=\E[?1034l, rmso=\E[27m, rmul=\E[24m, rs1=\Ec,
        rs2=\E[!p\E[?3;4l\E[4l\E>, sc=\E7, setab=\E[4%p1%dm,
        setaf=\E[3%p1%dm,
        setb=\E[4%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m,
        setf=\E[3%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m,
        sgr=%?%p9%t\E(0%e\E(B%;\E[0%?%p6%t;1%;%?%p5%t;2%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?%p7%t;8%;m,
        sgr0=\E(B\E[m, sitm=\E[3m, smacs=\E(0, smam=\E[?7h,
        smcup=\E[?1049h\E[22;0;0t, smir=\E[4h, smkx=\E[?1h\E=,
        smm=\E[?1034h, smso=\E[7m, smul=\E[4m, tbc=\E[3g,
        u6=\E[%i%d;%dR, u7=\E[6n, u8=\E[?%[;0123456789]c,
        u9=\E[c, vpa=\E[%i%p1%dd, Cr=\E]112\007,
        Cs=\E]12;%p1%s\007, E3=\E[3J, Ms=\E]52;%p1%s;%p2%s\007,
        Se=\E[2 q, Ss=\E[%p1%d q, kDC3=\E[3;3~, kDC4=\E[3;4~,
        kDC5=\E[3;5~, kDC6=\E[3;6~, kDC7=\E[3;7~, kDN=\E[1;2B,
        kDN3=\E[1;3B, kDN4=\E[1;4B, kDN5=\E[1;5B, kDN6=\E[1;6B,
        kDN7=\E[1;7B, kEND3=\E[1;3F, kEND4=\E[1;4F,
        kEND5=\E[1;5F, kEND6=\E[1;6F, kEND7=\E[1;7F,
        kHOM3=\E[1;3H, kHOM4=\E[1;4H, kHOM5=\E[1;5H,
        kHOM6=\E[1;6H, kHOM7=\E[1;7H, kIC3=\E[2;3~, kIC4=\E[2;4~,
        kIC5=\E[2;5~, kIC6=\E[2;6~, kIC7=\E[2;7~, kLFT3=\E[1;3D,
        kLFT4=\E[1;4D, kLFT5=\E[1;5D, kLFT6=\E[1;6D,
        kLFT7=\E[1;7D, kNXT3=\E[6;3~, kNXT4=\E[6;4~,
        kNXT5=\E[6;5~, kNXT6=\E[6;6~, kNXT7=\E[6;7~,
        kPRV3=\E[5;3~, kPRV4=\E[5;4~, kPRV5=\E[5;5~,
        kPRV6=\E[5;6~, kPRV7=\E[5;7~, kRIT3=\E[1;3C,
        kRIT4=\E[1;4C, kRIT5=\E[1;5C, kRIT6=\E[1;6C,
        kRIT7=\E[1;7C, kUP=\E[1;2A, kUP3=\E[1;3A, kUP4=\E[1;4A,
        kUP5=\E[1;5A, kUP6=\E[1;6A, kUP7=\E[1;7A, rmxx=\E[29m,
        smxx=\E[9m,
root@h2951296:~/projects/finalcut#
gansm commented 2 years ago

I think we should focus more on the data source. Could you please include the following debug lines in FKeyboard::getTermcapKey()?

inline FKey FKeyboard::getTermcapKey()
{
  // Looking for termcap key strings in the buffer

  static_assert ( FIFO_BUF_SIZE > 0 , "FIFO buffer too small" );

  if ( key_cap_ptr.use_count() == 0 )
    return NOT_SET;

  const auto buf_len = fifo_buf.getSize();

//------ DEBUG OUTPUT ------
  std::cerr << "buf_len = " << buf_len << "\n";
  std::cerr << "array size = " << key_cap_ptr->size() << "\n";
  std::cerr << "difference1 = " << (key_cap_ptr->cend() - key_cap_ptr->cbegin()) << "\n";
  std::cerr << "difference2 = " << (key_cap_end - key_cap_ptr->cbegin()) << "\n";
  //for (const auto& cap_key : *key_cap_ptr)
  //  std::cerr << "{ '" << (cap_key.string ? "1" : "0") << "', " << cap_key.length << " }\n";
//------ DEBUG OUTPUT ------

  const auto& found_key = std::find_if
  (
    key_cap_ptr->cbegin(),
    key_cap_end,
    [this, &buf_len] (const auto& cap_key)
    ...

Your output should then look like these lines:

FKeyboardTest::mouseTest
^[[M Z2buf_len = 1
array size = 188
difference1 = 188
difference2 = 188
buf_len = 2
array size = 188
difference1 = 188
difference2 = 188
buf_len = 3
array size = 188
difference1 = 188
difference2 = 188
buf_len = 4
array size = 188
difference1 = 188
difference2 = 188
buf_len = 5
array size = 188
difference1 = 188
difference2 = 188
 - Key: xterm mouse
 : OK
OK (1)
Barchfeld commented 2 years ago

I've changed the lines: grafik

Output:

# ./test/fkeyboard_test
FKeyboardTest::classNameTest : OK
FKeyboardTest::noArgumentTest : OK
FKeyboardTest::KeyLengthTest : OK
FKeyboardTest::escapeKeyTest
^[O[buf_len = 1
array size = 188
difference1 = 188
difference2 = 2118
Segmentation fault

If I uncomment the for - loop:

# ./test/fkeyboard_test
FKeyboardTest::classNameTest : OK
FKeyboardTest::noArgumentTest : OK
FKeyboardTest::KeyLengthTest : OK
FKeyboardTest::escapeKeyTest
^[O[buf_len = 1
array size = 188
difference1 = 188
difference2 = 2118
{ '1', 1 }
{ '0', 0 }
{ '0', 0 }
{ '1', 4 }
{ '0', 0 }
{ '0', 0 }
{ '1', 3 }
{ '0', 0 }
{ '0', 0 }
{ '0', 0 }
{ '0', 0 }
{ '1', 3 }
{ '1', 3 }
{ '1', 3 }
{ '1', 3 }
{ '1', 5 }
{ '1', 5 }
{ '1', 5 }
{ '1', 5 }
{ '1', 5 }
{ '1', 5 }
{ '1', 3 }
{ '1', 4 }
{ '0', 0 }
{ '1', 3 }
{ '0', 0 }
{ '1', 4 }
{ '1', 4 }
{ '1', 3 }
{ '1', 6 }
{ '1', 6 }
{ '0', 0 }
{ '1', 3 }
{ '0', 0 }
{ '0', 0 }
{ '1', 3 }
{ '0', 0 }
{ '0', 0 }
{ '1', 3 }
{ '0', 0 }
{ '0', 0 }
{ '0', 0 }
{ '0', 0 }
{ '0', 0 }
{ '0', 0 }
{ '1', 3 }
{ '0', 0 }
{ '0', 0 }
{ '1', 4 }
{ '0', 0 }
{ '0', 0 }
{ '0', 0 }
{ '0', 0 }
{ '0', 0 }
{ '0', 0 }
{ '0', 0 }
{ '0', 0 }
{ '0', 0 }
{ '0', 0 }
{ '0', 0 }
{ '0', 0 }
{ '0', 0 }
{ '0', 0 }
{ '0', 0 }
{ '0', 0 }
{ '0', 0 }
{ '0', 0 }
{ '0', 0 }
{ '0', 0 }
{ '0', 0 }
{ '0', 0 }
{ '0', 0 }
{ '1', 6 }
{ '0', 0 }
{ '1', 4 }
{ '1', 6 }
{ '0', 0 }
{ '0', 0 }
{ '0', 0 }
{ '0', 0 }
{ '1', 6 }
{ '1', 6 }
{ '1', 6 }
{ '0', 0 }
{ '0', 0 }
{ '1', 6 }
{ '0', 0 }
{ '1', 6 }
{ '0', 0 }
{ '0', 0 }
{ '0', 0 }
{ '1', 6 }
{ '0', 0 }
{ '0', 0 }
{ '0', 0 }
{ '0', 0 }
{ '1', 5 }
{ '1', 5 }
{ '1', 6 }
{ '1', 6 }
{ '1', 6 }
{ '1', 6 }
{ '1', 7 }
{ '1', 7 }
{ '1', 7 }
{ '1', 7 }
{ '1', 7 }
{ '1', 7 }
{ '1', 7 }
{ '1', 7 }
{ '1', 6 }
{ '1', 6 }
{ '1', 6 }
{ '1', 6 }
{ '1', 7 }
{ '1', 7 }
{ '1', 7 }
{ '1', 7 }
{ '1', 7 }
{ '1', 7 }
{ '1', 7 }
{ '1', 7 }
{ '1', 6 }
{ '1', 6 }
{ '1', 6 }
{ '1', 6 }
{ '1', 7 }
{ '1', 7 }
{ '1', 7 }
{ '1', 7 }
{ '1', 7 }
{ '1', 7 }
{ '1', 7 }
{ '1', 7 }
{ '1', 6 }
{ '1', 6 }
{ '1', 6 }
{ '1', 6 }
{ '1', 7 }
{ '1', 7 }
{ '1', 7 }
{ '1', 7 }
{ '1', 7 }
{ '1', 7 }
{ '1', 7 }
{ '1', 7 }
{ '1', 6 }
{ '1', 6 }
{ '1', 6 }
{ '0', 0 }
{ '1', 3 }
{ '1', 3 }
{ '1', 3 }
{ '1', 3 }
{ '1', 3 }
{ '1', 3 }
{ '1', 3 }
{ '1', 3 }
{ '1', 3 }
{ '1', 3 }
{ '1', 3 }
{ '1', 3 }
{ '1', 3 }
{ '1', 4 }
{ '1', 4 }
{ '1', 5 }
{ '1', 5 }
{ '1', 5 }
{ '1', 5 }
{ '1', 3 }
{ '1', 3 }
{ '1', 3 }
{ '1', 3 }
{ '1', 3 }
{ '1', 3 }
{ '1', 3 }
{ '1', 3 }
{ '1', 3 }
{ '1', 3 }
{ '1', 3 }
{ '1', 3 }
{ '1', 3 }
{ '1', 3 }
{ '1', 3 }
{ '1', 3 }
{ '1', 3 }
{ '1', 3 }
{ '1', 3 }
Segmentation fault
gansm commented 2 years ago

Great, there we have the problem! The pointer to the end of the std::array points beyond the end.

The question now is - Why do you get a wrong end-iterator from the std::array?

Perhaps the reinterpret_cast confused the compiler on your system. I have now modified my code a bit (5619f6c). Could you run again with these modifications, please?

Barchfeld commented 2 years ago
git reset --hard
git clean -fd
git pull https://github.com/gansm/finalcut.git

now, with g++-9, it works:

=========================================
   finalcut 0.8.1: test/test-suite.log
=========================================

# TOTAL: 28
# PASS:  28
# SKIP:  0
# XFAIL: 0
# FAIL:  0
# XPASS: 0
# ERROR: 0

.. contents:: :depth: 2

with g++-12.1 nothing changed. I get the same error again.

gansm commented 2 years ago

I made a few more changes (92c501f) and hope that the unit test with g++ 12.1 runs error-free for you.

Could you test this on your system to verify if this is the case?

alavaelian commented 1 year ago

man this thing is like chinesse for me

gansm commented 1 year ago

@alavaelian is right! I would need some clarity here if the (segmentation fault) crashes with g++-12.1 are still an issue.

@Barchfeld: Could you please test again if the current code fixes this problem? I require your support here. Unfortunately, I can't check it myself because I can't reproduce this error.