nomacs / nomacs

nomacs is a free image viewer for windows, linux, and mac systems.
GNU General Public License v3.0
1.84k stars 147 forks source link

Segfault when switching folders in file explorer #1083

Closed scrubbbbs closed 1 month ago

scrubbbbs commented 1 month ago

Nomacs segfaults when switching between two folders in the file explorer before allowing them to finishing thumbnailing. It doesn't always happen but only takes me a few tries.

It seems like DkThumbNail::computeIntern() is always on the stack so I guess this is a race or double-free on the const QString& fileName parameter since it tends to be passed to some function that segfaults (which varies). The problem might be the assumption that QString is thread-safe, in which case the solution could be to give each thread a copy.

I think its a known bug in hibernation since there is a comment in DkThumbNail::computeIntern() about a crash though no specific details are mentioned.

Here's a couple of stack traces; both in different places but the QString filename is involved in both places.

1  QDir::fromNativeSeparators(QString const&)                                                                                                                                  0x7795b3bdcb5d 
2  QFileInfo::QFileInfo(QString const&)                                                                                                                                        0x7795b3bf1157 
3  nmc::DkThumbNail::computeIntern                                                                                                        DkThumbs.cpp                     132 0x7795b57ec076 
4  nmc::DkThumbNailT::computeCall                                                                                                         DkThumbs.cpp                     324 0x7795b57ed610 
5  operator()                                                                                                                             DkThumbs.cpp                     316 0x7795b57ed07c 
6  QtConcurrent::StoredFunctorCall0<QImage, nmc::DkThumbNailT::fetchThumb(int, QSharedPointer<QByteArray>)::<lambda()>>::runFunctor(void) qtconcurrentstoredfunctioncall.h 60  0x7795b57edbc4 
7  QtConcurrent::RunFunctionTask<QImage>::run                                                                                             qtconcurrentrunbase.h            114 0x7795b5706c79 
8  ??                                                                                                                                                                          0x7795b3ade122 
9  ??                                                                                                                                                                          0x7795b3adaeb1 
10 start_thread                                                                                                                           pthread_create.c                 444 0x7795b3697b5a 
11 clone3                                                                                                                                 clone3.S                         78  0x7795b37285fc                                                                                                                               clone3.S                         78  0x7795b37285fc 
1  QString::operator=(QString const&)                                                                                                                                          0x74f56355f830 
2  nmc::DkMetaDataT::readMetaData                                                                                                         DkMetaData.cpp                   106 0x74f5651d9466 
3  nmc::DkThumbNail::computeIntern                                                                                                        DkThumbs.cpp                     108 0x74f56522ce33 
4  nmc::DkThumbNailT::computeCall                                                                                                         DkThumbs.cpp                     324 0x74f56522e610 
5  operator()                                                                                                                             DkThumbs.cpp                     316 0x74f56522e07c 
6  QtConcurrent::StoredFunctorCall0<QImage, nmc::DkThumbNailT::fetchThumb(int, QSharedPointer<QByteArray>)::<lambda()>>::runFunctor(void) qtconcurrentstoredfunctioncall.h 60  0x74f56522ebc4 
7  QtConcurrent::RunFunctionTask<QImage>::run                                                                                             qtconcurrentrunbase.h            114 0x74f565147c79 
8  ??                                                                                                                                                                          0x74f5634de122 
9  ??                                                                                                                                                                          0x74f5634daeb1 
10 start_thread                                                                                                                           pthread_create.c                 444 0x74f563097b5a 
11 clone3                                                                                                                                 clone3.S                         78  0x74f5631285fc 

This is Linux, git master 6dfc779. I can also confirm on 3.17.2206 Ubuntu package.

leejuyuu commented 1 month ago

Hello @scrubbbbs, thanks for reporting. Could you provide your system (windows?) and the version of nomacs?

leejuyuu commented 1 month ago

Could you specify which commit? Something like git master would be ambiguous for future readers.

leejuyuu commented 1 month ago

@scrubbbbs please add a Fixes <issue link> in the commit or PR body next time so they link to and close issues automatically when merged, thanks.

leejuyuu commented 1 month ago

Should be fixed by https://github.com/nomacs/nomacs/pull/1085.

scrubbbbs commented 1 month ago

Thanks, I did not know that was possible.