Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove TrackFile class #3761

Merged
merged 9 commits into from
Apr 27, 2021
Merged

Remove TrackFile class #3761

merged 9 commits into from
Apr 27, 2021

Conversation

uklotzde
Copy link
Contributor

@uklotzde uklotzde commented Apr 2, 2021

### TODO

  • [ ] Check if the sandboxing commit could be split into smaller chunks. Although I don't expect that it is worth the effort.

DONE

  • Replaced the special case TrackFile with mixxx::FileInfo and mixxx::FileAccess. The latter includes a sandboxing token.
  • Sandbox: Create a sandboxing token from either mixxx::FileInfo or QDir. I preferred not to remove the existing QDir member functions in favor of mixxx::FileInfo (that could represent both, i.e. files and directories).

@uklotzde uklotzde changed the title [WiP] Remove trackfile Remove trackfile Apr 3, 2021
@uklotzde uklotzde marked this pull request as ready for review April 3, 2021 08:36
@uklotzde uklotzde changed the title Remove trackfile Remove TrackFile class Apr 3, 2021
@Be-ing
Copy link
Contributor

Be-ing commented Apr 5, 2021

Please push a branch to the upstream repo so signed macOS builds can be tested for regressions with sandboxing.

@uklotzde
Copy link
Contributor Author

uklotzde commented Apr 5, 2021

Please push a branch to the upstream repo so signed macOS builds can be tested for regressions with sandboxing.

Good idea. This should be the corresponding build actions: https://github.com/mixxxdj/mixxx/actions/runs/718884524

@uklotzde uklotzde added this to the 2.4.0 milestone Apr 5, 2021
@uklotzde uklotzde removed the ui label Apr 5, 2021
@github-actions github-actions bot added the ui label Apr 16, 2021
@Holzhaus
Copy link
Member

I encountered this DEBUG_ASSERT when using the Browse library feature:

DEBUG ASSERT: "hasLocation(fileInfo)" in function static QString mixxx::FileInfo::location(const QFileInfo&) at /home/jan/Projects/mixxx/src/util/fileinfo.h:115

@uklotzde
Copy link
Contributor Author

uklotzde commented Apr 17, 2021

I encountered this DEBUG_ASSERT when using the Browse library feature:

DEBUG ASSERT: "hasLocation(fileInfo)" in function static QString mixxx::FileInfo::location(const QFileInfo&) at /home/jan/Projects/mixxx/src/util/fileinfo.h:115

I am not able to reproduce this, neither with library tracks nor with external files.

A stack trace would be helpful to analyze the circumstances.

@Holzhaus
Copy link
Member

I uncollapsed the "Computer" library item, then clicked on "Quick Links", then this happens:

─── Output/messages ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────
warning [Main] ControlDoublePrivate::getControl returning NULL for ( "[Master]" , "skin_settings" )
warning [0x7fff54007980] QThread::setPriority: Cannot determine scheduler priority range
 qt.qpa.xcb:warning [Main] QXcbConnection: XCB error: 8 (BadMatch), sequence: 7926, resource id: 48234512, major code: 130 (Unknown), minor code: 3
 qt.qpa.xcb:warning [Main] QXcbConnection: XCB error: 8 (BadMatch), sequence: 7939, resource id: 48234512, major code: 130 (Unknown), minor code: 3
 qt.qpa.xcb:warning [Main] QXcbConnection: XCB error: 8 (BadMatch), sequence: 7942, resource id: 48234512, major code: 130 (Unknown), minor code: 3
 qt.qpa.xcb:warning [Main] QXcbConnection: XCB error: 8 (BadMatch), sequence: 9296, resource id: 48234512, major code: 130 (Unknown), minor code: 3
 qt.qpa.xcb:warning [Main] QXcbConnection: XCB error: 8 (BadMatch), sequence: 9309, resource id: 48234512, major code: 130 (Unknown), minor code: 3
 qt.qpa.xcb:warning [Main] QXcbConnection: XCB error: 8 (BadMatch), sequence: 9312, resource id: 48234512, major code: 130 (Unknown), minor code: 3
DEBUG ASSERT: "hasLocation(fileInfo)" in function static QString mixxx::FileInfo::location(const QFileInfo&) at /home/jan/Projects/mixxx/src/util/fileinfo.h:115

Thread 54 "BrowseThread" received signal SIGABRT, Aborted.
[Switching to Thread 0x7fff391b5640 (LWP 56572)]
0x00007ffff3244ef5 in raise () from /usr/lib/libc.so.6
─── Assembly ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
0x00007ffff3244ee9 raise-1726391 mov    $0x2,%edi
0x00007ffff3244eee raise-1726386 mov    $0xe,%eax
0x00007ffff3244ef3 raise-1726381 syscall
0x00007ffff3244ef5 raise-1726379 mov    0x108(%rsp),%rax
0x00007ffff3244efd raise-1726371 sub    %fs:0x28,%rax
0x00007ffff3244f06 raise-1726362 jne    0x7ffff3244f2c <raise+380>
0x00007ffff3244f08 raise-1726360 mov    %r8d,%eax
─── Expressions ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
─── History ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
─── Memory ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
─── Registers ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   rax 0x0000000000000000     rbx 0x00007fff391b5640     rcx 0x00007ffff3244ef5     rdx 0x0000000000000000     rsi 0x00007fff391b40a0
   rdi 0x0000000000000002     rbp 0x00007fff391b42f8     rsp 0x00007fff391b40a0      r8 0x0000000000000000      r9 0x00007fff391b40a0
   r10 0x0000000000000008     r11 0x0000000000000246     r12 0x00007fff391b44b8     r13 0x00007fff391b45c0     r14 0x00007fff391b4860
   r15 0x0000555558b15368     rip 0x00007ffff3244ef5  eflags [ PF ZF IF ]            cs 0x00000033              ss 0x0000002b
    ds 0x00000000              es 0x00000000              fs 0x00000000              gs 0x00000000
─── Source ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
─── Stack ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
[0] from 0x00007ffff3244ef5 in raise+-1726379
(no arguments)
[1] from 0x00007ffff322e862 in abort+278
(no arguments)
[+]
─── Threads ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
[88] id 56618 name mixxx:gdrv0 from 0x00007ffff33ec9ba in __futex_abstimed_wait_common64+202
[87] id 56617 name mixxx:gdrv0 from 0x00007ffff33ec9ba in __futex_abstimed_wait_common64+202
[86] id 56616 name mixxx:gdrv0 from 0x00007ffff33ec9ba in __futex_abstimed_wait_common64+202
[85] id 56615 name mixxx:gdrv0 from 0x00007ffff33ec9ba in __futex_abstimed_wait_common64+202
[84] id 56614 name libusb_event from 0x00007ffff32fc37f in poll+79
[83] id 56613 name Thread (pooled) from 0x00007ffff33ec9ba in __futex_abstimed_wait_common64+202
[82] id 56612 name Thread (pooled) from 0x00007ffff33ec9ba in __futex_abstimed_wait_common64+202
[81] id 56611 name Thread (pooled) from 0x00007ffff33ec9ba in __futex_abstimed_wait_common64+202
[80] id 56610 name Thread (pooled) from 0x00007ffff33ec9ba in __futex_abstimed_wait_common64+202
[79] id 56609 name Thread (pooled) from 0x00007ffff33ec9ba in __futex_abstimed_wait_common64+202
[78] id 56608 name Thread (pooled) from 0x00007ffff33ec9ba in __futex_abstimed_wait_common64+202
[77] id 56607 name VSync from 0x00007ffff3301a9d in syscall+29
[76] id 56606 name mixxx:gdrv0 from 0x00007ffff33ec9ba in __futex_abstimed_wait_common64+202
[75] id 56605 name CachingReaderWo from 0x00007ffff3301a9d in syscall+29
[74] id 56604 name CachingReaderWo from 0x00007ffff3301a9d in syscall+29
[73] id 56603 name CachingReaderWo from 0x00007ffff3301a9d in syscall+29
[72] id 56602 name CachingReaderWo from 0x00007ffff3301a9d in syscall+29
[71] id 56601 name CachingReaderWo from 0x00007ffff3301a9d in syscall+29
[70] id 56600 name CachingReaderWo from 0x00007ffff3301a9d in syscall+29
[69] id 56599 name CachingReaderWo from 0x00007ffff3301a9d in syscall+29
[68] id 56598 name CachingReaderWo from 0x00007ffff3301a9d in syscall+29
[67] id 56597 name CachingReaderWo from 0x00007ffff3301a9d in syscall+29
[66] id 56596 name CachingReaderWo from 0x00007ffff3301a9d in syscall+29
[65] id 56595 name CachingReaderWo from 0x00007ffff3301a9d in syscall+29
[64] id 56594 name CachingReaderWo from 0x00007ffff3301a9d in syscall+29
[63] id 56593 name Controller from 0x00007ffff32fc37f in poll+79
[62] id 56580 name AnalyzerThread from 0x00007ffff33ec9ba in __futex_abstimed_wait_common64+202
[61] id 56579 name AnalyzerThread from 0x00007ffff33ec9ba in __futex_abstimed_wait_common64+202
[60] id 56578 name AnalyzerThread from 0x00007ffff33ec9ba in __futex_abstimed_wait_common64+202
[59] id 56577 name AnalyzerThread from 0x00007ffff33ec9ba in __futex_abstimed_wait_common64+202
[58] id 56576 name AnalyzerThread from 0x00007ffff33ec9ba in __futex_abstimed_wait_common64+202
[57] id 56575 name AnalyzerThread from 0x00007ffff33ec9ba in __futex_abstimed_wait_common64+202
[56] id 56574 name AnalyzerThread from 0x00007ffff33ec9ba in __futex_abstimed_wait_common64+202
[55] id 56573 name AnalyzerThread from 0x00007ffff33ec9ba in __futex_abstimed_wait_common64+202
[54] id 56572 name BrowseThread from 0x00007ffff3244ef5 in raise+-1726379
[53] id 56571 name LibraryScanner  from 0x00007ffff32fc37f in poll+79
[52] id 56570 name CachingReaderWo from 0x00007ffff3301a9d in syscall+29
[51] id 56569 name CachingReaderWo from 0x00007ffff3301a9d in syscall+29
[50] id 56568 name CachingReaderWo from 0x00007ffff3301a9d in syscall+29
[49] id 56567 name CachingReaderWo from 0x00007ffff3301a9d in syscall+29
[48] id 56566 name CachingReaderWo from 0x00007ffff3301a9d in syscall+29
[47] id 56565 name CachingReaderWo from 0x00007ffff3301a9d in syscall+29
[46] id 56564 name CachingReaderWo from 0x00007ffff3301a9d in syscall+29
[45] id 56563 name VinylControlPro from 0x00007ffff33ec9ba in __futex_abstimed_wait_common64+202
[44] id 56562 name Mixxx from 0x00007ffff330739e in epoll_wait+94
[43] id 56561 name mixxx from 0x00007ffff330739e in epoll_wait+94
[30] id 56543 name EngineSideChain from 0x00007ffff33ec9ba in __futex_abstimed_wait_common64+202
[29] id 56541 name EngineWorkerSch from 0x00007ffff33ec9ba in __futex_abstimed_wait_common64+202
[28] id 56540 name mixxx:shlo4 from 0x00007ffff33ec9ba in __futex_abstimed_wait_common64+202
[27] id 56539 name mixxx:shlo3 from 0x00007ffff33ec9ba in __futex_abstimed_wait_common64+202
[26] id 56538 name mixxx:shlo2 from 0x00007ffff33ec9ba in __futex_abstimed_wait_common64+202
[25] id 56537 name mixxx:shlo1 from 0x00007ffff33ec9ba in __futex_abstimed_wait_common64+202
[24] id 56536 name mixxx:shlo0 from 0x00007ffff33ec9ba in __futex_abstimed_wait_common64+202
[23] id 56535 name mixxx:sh11 from 0x00007ffff33ec9ba in __futex_abstimed_wait_common64+202
[22] id 56534 name mixxx:sh10 from 0x00007ffff33ec9ba in __futex_abstimed_wait_common64+202
[21] id 56533 name mixxx:sh9 from 0x00007ffff33ec9ba in __futex_abstimed_wait_common64+202
[20] id 56532 name mixxx:sh8 from 0x00007ffff33ec9ba in __futex_abstimed_wait_common64+202
[19] id 56531 name mixxx:sh7 from 0x00007ffff33ec9ba in __futex_abstimed_wait_common64+202
[18] id 56530 name mixxx:sh6 from 0x00007ffff33ec9ba in __futex_abstimed_wait_common64+202
[17] id 56529 name mixxx:sh5 from 0x00007ffff33ec9ba in __futex_abstimed_wait_common64+202
[16] id 56528 name mixxx:sh4 from 0x00007ffff33ec9ba in __futex_abstimed_wait_common64+202
[15] id 56527 name mixxx:sh3 from 0x00007ffff33ec9ba in __futex_abstimed_wait_common64+202
[14] id 56526 name mixxx:sh2 from 0x00007ffff33ec9ba in __futex_abstimed_wait_common64+202
[13] id 56525 name mixxx:sh1 from 0x00007ffff33ec9ba in __futex_abstimed_wait_common64+202
[12] id 56524 name mixxx:sh0 from 0x00007ffff33ec9ba in __futex_abstimed_wait_common64+202
[11] id 56523 name mixxx:disk$3 from 0x00007ffff33ec9ba in __futex_abstimed_wait_common64+202
[10] id 56522 name mixxx:disk$2 from 0x00007ffff33ec9ba in __futex_abstimed_wait_common64+202
[9] id 56521 name mixxx:disk$1 from 0x00007ffff33ec9ba in __futex_abstimed_wait_common64+202
[8] id 56520 name mixxx:disk$0 from 0x00007ffff33ec9ba in __futex_abstimed_wait_common64+202
[7] id 56519 name mixxx:cs0 from 0x00007ffff33ec9ba in __futex_abstimed_wait_common64+202
[6] id 56518 name QDBusConnection from 0x00007ffff32fc37f in poll+79
[5] id 56517 name gdbus from 0x00007ffff32fc37f in poll+79
[4] id 56516 name dconf worker from 0x00007ffff32fc37f in poll+79
[3] id 56515 name gmain from 0x00007ffff32fc37f in poll+79
[2] id 56514 name QXcbEventQueue from 0x00007ffff32fc37f in poll+79
[1] id 56510 name mixxx from 0x00007ffff32fedab in fdatasync+59
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
>>> bt
#0  0x00007ffff3244ef5 in raise () at /usr/lib/libc.so.6
#1  0x00007ffff322e862 in abort () at /usr/lib/libc.so.6
#2  0x00007ffff383b9ac in  () at /usr/lib/libQt5Core.so.5
#3  0x00005555556669e6 in mixxx::(anonymous namespace)::handleMessage(QtMsgType, QMessageLogContext const&, QString const&) (type=QtCriticalMsg, context=..., input=...) at /home/jan/Projects/mixxx/src/util/logging.cpp:321
#4  0x00007ffff3870a28 in  () at /usr/lib/libQt5Core.so.5
#5  0x00007ffff3870b4a in  () at /usr/lib/libQt5Core.so.5
#6  0x00007ffff383b5d4 in QMessageLogger::critical(char const*, ...) const () at /usr/lib/libQt5Core.so.5
#7  0x000055555564ff45 in mixxx_debug_assert(char const*, char const*, int, char const*) (assertion=assertion@entry=0x5555561418a7 "hasLocation(fileInfo)", file=file@entry=0x555556141680 "/home/jan/Projects/mixxx/src/util/fileinfo.h", line=line@entry=115, function=function@entry=0x5555561416b0 "static QString mixxx::FileInfo::location(const QFileInfo&)") at /home/jan/Projects/mixxx/src/util/assert.h:11
#8  0x00005555556edd24 in mixxx::FileInfo::location(QFileInfo const&) (fileInfo=...) at /home/jan/Projects/mixxx/src/util/fileinfo.h:115
#9  mixxx::FileInfo::location() const (this=0x7fff391b4710) at /home/jan/Projects/mixxx/src/util/fileinfo.h:119
#10 BrowseThread::populateModel() (this=0x555558b15350) at /home/jan/Projects/mixxx/src/library/browse/browsethread.cpp:122
#11 0x0000555555e481cb in BrowseThread::run() (this=0x555558b15350) at /home/jan/Projects/mixxx/src/library/browse/browsethread.cpp:86
#12 0x00007ffff387907f in  () at /usr/lib/libQt5Core.so.5
#13 0x00007ffff33e0299 in start_thread () at /usr/lib/libpthread.so.0
#14 0x00007ffff3307053 in clone () at /usr/lib/libc.so.6

@uklotzde
Copy link
Contributor Author

Please check the particular file system item that causes this debug assertion (file/dir/symlink? permission issue?). I still cannot reproduce this.

@Holzhaus
Copy link
Member

FYI I didn't even click on a directory, just the "Quick Links" parent item.

@uklotzde
Copy link
Contributor Author

Sure. But the browse thread seems to pick something up that is not accessible by its absolute path and returns an empty string instead.

@uklotzde
Copy link
Contributor Author

Not sure if the last commit fixes the issues. Those issues were always there, just not handled correctly.

@Holzhaus
Copy link
Member

Not sure if the last commit fixes the issues. Those issues were always there, just not handled correctly.

It does. No DEBUG_ASSERT anymore. When clicking on "Quick Links", I see this warning on the terminal:

warning [BrowseThread] Skipping QFileInfo()

Clicking on a subitem of "Quick Links" does not cause a warning btw.

@uklotzde
Copy link
Contributor Author

Passing an empty FileInfo to BrowseThread is nonsense and should be avoided. Unrelated, I will not fix this.

@Holzhaus
Copy link
Member

Does someone else want to test this or should I merge?

@Holzhaus Holzhaus merged commit c9f52dc into mixxxdj:main Apr 27, 2021
@uklotzde uklotzde deleted the remove-trackfile branch April 27, 2021 21:58
@fwcd
Copy link
Member

fwcd commented Dec 22, 2023

Does someone else want to test this or should I merge?

We really need more macOS testers (or more frequent releases) to prevent QA issues with sandboxing from piling up and going unnoticed, especially for sweeping changes to the sandbox logic that almost exclusively affect macOS (regardless of whether this did or did not introduce #12137)

@uklotzde
Copy link
Contributor Author

A sustainable solution needs to isolate and hide the sandbox handling. Otherwise this remains a moving target. The optional sandbox argument is scattered everywhere. Manual testing is not enough.

I wonder why Qt doesn't provide this out-of-the-box and everyone has to reinvent the wheel when writing platform independent code.

@fwcd
Copy link
Member

fwcd commented Dec 22, 2023

Whew, this took a lot of digging. I think I found the issue.

The new implementation of Sandbox::canAccess is (very subtly) incorrect:

5111af7#diff-5afc6764d555de2d3fd3d5baae821a187ece9cf2d5c2526797cd7f0c7a8cc12aR71-R77

bool Sandbox::canAccess(mixxx::FileInfo* pFileInfo) {
    VERIFY_OR_DEBUG_ASSERT(pFileInfo) {
        return false;
    }
    openSecurityToken(pFileInfo, true);
    return pFileInfo->isReadable();
}

The problem is that if we don't assign the token to a local variable, the token will be deinitialized (and presumably invalidated) before we invoke isReadable, which in turn causes the method to always (falsely) claim that we cannot read the file.

@fwcd
Copy link
Member

fwcd commented Dec 22, 2023

I'll open a PR. We should probably place a [[nodiscard]] on openSecurityToken too...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants