mpogue2 / SquareDesk

Fully-featured music player and sequence designer, designed for square dance callers
10 stars 4 forks source link

Bug: Crash on playlist load at app start time #1087

Open mpogue2 opened 6 months ago

mpogue2 commented 6 months ago
Thread 0 Crashed:: CrBrowserMain Dispatch queue: com.apple.main-thread
0   QtCore                                 0x108aa2938 int std::__1::__cxx_atomic_fetch_add<int>(std::__1::__cxx_atomic_base_impl<int>*, int, std::__1::memory_order) + 0 (atomic:1061) [inlined]
1   QtCore                                 0x108aa2938 std::__1::__atomic_base<int, true>::fetch_add(int, std::__1::memory_order) + 0 (atomic:1748) [inlined]
2   QtCore                                 0x108aa2938 bool QAtomicOps<int>::ref<int>(std::__1::atomic<int>&) + 0 (qatomic_cxx11.h:258) [inlined]
3   QtCore                                 0x108aa2938 QBasicAtomicInteger<int>::ref() + 0 (qbasicatomic.h:49) [inlined]
4   QtCore                                 0x108aa2938 QArrayData::ref() + 0 (qarraydata.h:52) [inlined]
5   QtCore                                 0x108aa2938 QArrayDataPointer<char16_t>::ref() + 8 (qarraydatapointer.h:412) [inlined]
6   QtCore                                 0x108aa2938 QArrayDataPointer<char16_t>::QArrayDataPointer(QArrayDataPointer<char16_t> const&) + 24 (qarraydatapointer.h:40) [inlined]
7   QtCore                                 0x108aa2938 QArrayDataPointer<char16_t>::QArrayDataPointer(QArrayDataPointer<char16_t> const&) + 24 (qarraydatapointer.h:39) [inlined]
8   QtCore                                 0x108aa2938 QString::QString(QString const&) + 24 (qstring.h:1107) [inlined]
9   QtCore                                 0x108aa2938 QString::QString(QString const&) + 24 (qstring.h:1108) [inlined]
10  QtCore                                 0x108aa2938 QVariant::Private::Private<QString>(std::__1::piecewise_construct_t, QString const&) + 40 (qvariant_p.h:98) [inlined]
11  QtCore                                 0x108aa2938 QVariant::Private::Private<QString>(std::__1::piecewise_construct_t, QString const&) + 40 (qvariant_p.h:85) [inlined]
12  QtCore                                 0x108aa2938 QVariant::QVariant(QString const&) + 40 (qvariant.cpp:946) [inlined]
13  QtCore                                 0x108aa2938 QVariant::QVariant(QString const&) + 40 (qvariant.cpp:946)
14  QtWidgets                              0x1068c5794 QTableWidgetItem::QTableWidgetItem(QString const&, int) + 76 (qtablewidget.cpp:1331) [inlined]
15  QtWidgets                              0x1068c5794 QTableWidgetItem::QTableWidgetItem(QString const&, int) + 112 (qtablewidget.cpp:1330)
16  SquareDesk                             0x104fa3f2c MainWindow::loadPlaylistFromFileToPaletteSlot(QString, int, int&) + 6480
17  SquareDesk                             0x104f1778c MainWindow::MainWindow(QSplashScreen*, bool, QWidget*) + 45336
18  SquareDesk                             0x104eedae0 main + 2268
19  dyld                                   0x18977a0e0 start + 2360
mpogue2 commented 6 months ago

Details:

And, sure enough, this like contains an extra double quote. I bet that's what caused the crash.

mpogue2 commented 6 months ago

Renaming THAT file, and SquareDesk now starts up normally. So, it does appear to be inside that file. File attached, and we know it's that line, and we know that the line contains an extra double quote character.

File: ECR_2024.02.28b.csv

I bet the problem is that parseCSV is returning garbage, because of the extra double quote. Yeah, if parseCSV doesn't return the right number of items, it should ignore that line.

OK, I edited ECR_2024.02.28.csv to eliminate all the large number of extra lines. Loads into palette slot #2 correctly now.

mpogue2 commented 5 months ago

Double quotes in a pathname need to be written as doubleQuote doubleQuote to be valid CSV, because the entire pathname is written out surrounded by doubleQuotes.

NOTE: If our simple CSV parser encounters a naked double quote in a CSV file, yes the CSV file is malformed, but squareDesk will crash. In this case the only thing you can do is to delete the offending line from the CSV file. This might be hard to figure out, because the error message is obscure.

Commit: e50cedbf6c22c1a9a509649d7e51cc9cccd46585