contour-terminal / contour

Modern C++ Terminal Emulator
http://contour-terminal.org/
Apache License 2.0
2.38k stars 102 forks source link

SEGFAULT on font resize #1309

Closed cqexbesd closed 10 months ago

cqexbesd commented 10 months ago

Contour Terminal version

0.4.0-master-b88045a2

Installer source

Github: source code cloned

Operating System

Arch Linux as of a few days ago

Architecture

x86-64

Other Software

No response

Steps to reproduce

Hold down ctrl and play with the mouse wheel to resize the font. Go up and down for about 10s.

Expected Behavior

No response

Actual Behavior

Info: libpng warning: iCCP: known incorrect sRGB profile ((null):0, (null))
[error] OpenGL error 1281 for call: glPixelStorei(GL_UNPACK_ALIGNMENT, param.rowAlignment)
[error] OpenGL error 1281 for call: glPixelStorei(GL_UNPACK_ALIGNMENT, param.rowAlignment)
[error] OpenGL error 1281 for call: glPixelStorei(GL_UNPACK_ALIGNMENT, param.rowAlignment)
[error] OpenGL error 1281 for call: glPixelStorei(GL_UNPACK_ALIGNMENT, param.rowAlignment)
[error] OpenGL error 1281 for call: glPixelStorei(GL_UNPACK_ALIGNMENT, param.rowAlignment)
[error] OpenGL error 1281 for call: glPixelStorei(GL_UNPACK_ALIGNMENT, param.rowAlignment)
[error] OpenGL error 1281 for call: glPixelStorei(GL_UNPACK_ALIGNMENT, param.rowAlignment)
[error] OpenGL error 1281 for call: glPixelStorei(GL_UNPACK_ALIGNMENT, param.rowAlignment)
[error] OpenGL error 1281 for call: glPixelStorei(GL_UNPACK_ALIGNMENT, param.rowAlignment)
[error] OpenGL error 1281 for call: glPixelStorei(GL_UNPACK_ALIGNMENT, param.rowAlignment)
[error] OpenGL error 1281 for call: glPixelStorei(GL_UNPACK_ALIGNMENT, param.rowAlignment)
Segmentation fault (core dumped)

Additional notes

No response

Yaraslaut commented 10 months ago

I can get SIGSEGV, but only if text goes beyond viewport

christianparpart commented 10 months ago

I can get SIGSEGV, but only if text goes beyond viewport

well that is something. I doubt that this is something new though, because usually one rarely font-resizes that often in a short time, but it certainly needs fixing. :)

cqexbesd commented 10 months ago

I can sometimes reproduce by resizing slow up for about 5s. Then I don't get the OpenGL errors, just the SEGV. Attempting to open the core file for a back trace but it's not a debug build. gdb is currently downloading many many symbols of shared libraries.

cqexbesd commented 10 months ago

Reversing scrolling direction seems to trigger it 75% of the time. gdb still churning away trying to print a back trace but it has managed the first line:

#0  contour::display::OpenGLRenderer::executeUploadTile (this=this@entry=0x7fa8b00faca0, param=...)
    at /home/andrew/projects/contour/src/contour/display/OpenGLRenderer.cpp:773
773                     *t++ = *s++; // green
cqexbesd commented 10 months ago

OK full back trace (but as this is a non-debug build I guess it could be wrong):

#0  contour::display::OpenGLRenderer::executeUploadTile(vtrasterizer::atlas::UploadTile const&)
    (this=this@entry=0x7fa8b00faca0, param=...)
    at /home/andrew/projects/contour/src/contour/display/OpenGLRenderer.cpp:773
#1  0x000055861915f81b in contour::display::OpenGLRenderer::execute(std::chrono::time_point<std::chrono::_V2::steady_clock, std::chrono::duration<long, std::ratio<1l, 1000000000l> > >) (this=0x7fa8b00faca0, now=Python Exception <class 'gdb.error'>: value has beenoptimized out
)
    at /home/andrew/projects/contour/src/contour/display/OpenGLRenderer.cpp:598
#2  0x000055861916d67a in contour::display::TerminalWidget::paint() (this=0x55861a5d9150)
    at /home/andrew/projects/contour/src/contour/display/TerminalWidget.cpp:684
#3  0x000055861916d45f in contour::display::TerminalWidget::onAfterRendering() (this=0x7fa8b00dc178)
    at /home/andrew/projects/contour/src/contour/display/TerminalWidget.cpp:711
#4  0x00007fa90b1b9a59 in QtPrivate::QSlotObjectBase::call(QObject*, void**)
    (a=0x7fa8bdbfda38, r=0x55861a5d9150, this=0x7fa8b00f7620, this=<optimized out>, r=<optimized out>, a=<optimized out>)
    at /usr/src/debug/qt6-base/qtbase-everywhere-src-6.6.0/src/corelib/kernel/qobjectdefs_impl.h:433
#5  doActivate<false>(QObject*, int, void**) (sender=0x55861a3feef0, signal_index=28, argv=0x7fa8bdbfda38)
    at /usr/src/debug/qt6-base/qtbase-everywhere-src-6.6.0/src/corelib/kernel/qobject.cpp:4021
#6  0x00007fa90c8767fe in QQuickWindow::afterRendering() (this=0x55861a3feef0)
    at /usr/src/debug/qt6-declarative/build/src/quick/Quick_autogen/include/moc_qquickwindow.cpp:865
#7  QQuickWindowPrivate::renderSceneGraph() (this=0x55861a3feff0)
    at /usr/src/debug/qt6-declarative/qtdeclarative-everywhere-src-6.6.0/src/quick/items/qquickwindow.cpp:656
#8  0x00007fa90ca0785c in QSGRenderThread::syncAndRender() (this=<optimized out>)
    at /usr/src/debug/qt6-declarative/qtdeclarative-everywhere-src-6.6.0/src/quick/scenegraph/qsgthreadedrenderloop.cpp:734
#9  QSGRenderThread::run() (this=0x55861a2e3d10)
    at /usr/src/debug/qt6-declarative/qtdeclarative-everywhere-src-6.6.0/src/quick/scenegraph/qsgthreadedrenderloop.cpp:946
#10 0x00007fa90b2c97b3 in operator() (__closure=<optimized out>)
    at /usr/src/debug/qt6-base/qtbase-everywhere-src-6.6.0/src/corelib/thread/qthread_unix.cpp:324
#11 (anonymous namespace)::terminate_on_exception<QThreadPrivate::start(void*)::<lambda()> > (t=<optimized out>)
    at /usr/src/debug/qt6-base/qtbase-everywhere-src-6.6.0/src/corelib/thread/qthread_unix.cpp:260
#12 QThreadPrivate::start(void*) (arg=0x55861a2e3d10)
    at /usr/src/debug/qt6-base/qtbase-everywhere-src-6.6.0/src/corelib/thread/qthread_unix.cpp:283
#13 0x00007fa90aaaa9eb in start_thread (arg=<optimized out>) at pthread_create.c:444
#14 0x00007fa90ab2e7cc in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
Yaraslaut commented 10 months ago

I see similar back trace

Process 513069 stopped
* thread #8, name = 'QSGRenderThread', stop reason = signal SIGSEGV: invalid permissions for mapped object (fault address: 0x7fffa033f000)
    frame #0: 0x000055555586b8d0 contour`contour::display::OpenGLRenderer::executeConfigureAtlas(this=0x00007fffa43b0a40, param=0x00007fffa43b0a68) at OpenGLRenderer.cpp:710:22
   707          case atlas::Format::RGBA:
   708              for (auto i = 0u; i < param.size.area(); ++i)
   709              {
-> 710                  *t++ = 0x00;
   711                  *t++ = 0xA0;
   712                  *t++ = 0x00;
   713                  *t++ = 0xC0;
(lldb) bt
* thread #8, name = 'QSGRenderThread', stop reason = signal SIGSEGV: invalid permissions for mapped object (fault address: 0x7fffa033f000)
  * frame #0: 0x000055555586b8d0 contour`contour::display::OpenGLRenderer::executeConfigureAtlas(this=0x00007fffa43b0a40, param=0x00007fffa43b0a68) at OpenGLRenderer.cpp:710:22
    frame #1: 0x000055555586b419 contour`contour::display::OpenGLRenderer::execute(this=0x00007fffa43b0a40, now=<unavailable>) at OpenGLRenderer.cpp:590:9
    frame #2: 0x00005555558764c6 contour`contour::display::TerminalWidget::paint(this=0x0000555555d744d0) at TerminalWidget.cpp:684:20
    frame #3: 0x000055555587628f contour`contour::display::TerminalWidget::onAfterRendering(this=<unavailable>) at TerminalWidget.cpp:711:5
    frame #4: 0x00007ffff57b9a59 libQt6Core.so.6`___lldb_unnamed_symbol12083 + 633
    frame #5: 0x00007ffff6e767fe libQt6Quick.so.6`QQuickWindowPrivate::renderSceneGraph() + 926
    frame #6: 0x00007ffff700785c libQt6Quick.so.6`___lldb_unnamed_symbol17760 + 2428
    frame #7: 0x00007ffff58c97b3 libQt6Core.so.6`___lldb_unnamed_symbol13146 + 339
    frame #8: 0x00007ffff50aa9eb libc.so.6`___lldb_unnamed_symbol3598 + 731
    frame #9: 0x00007ffff512e7cc libc.so.6`___lldb_unnamed_symbol4045 + 7
christianparpart commented 10 months ago

maybe configureAtlas is doing too much on a font resize. maybe that's not all needed. There's no ned to fully reconstruct the GL texture atlas, we just need to make sure that we can properly address all tiles.

cqexbesd commented 10 months ago

I can reproduce on 8d16a58f9860187b3152fc578274fe34e4736789 as well so @christianparpart is correct that it's not a new bug.