Bug 247431 - sysutils/bsdisks: coredumps on postponed registration processing due to wrong iteration
Summary: sysutils/bsdisks: coredumps on postponed registration processing due to wrong...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Gleb Popov
URL:
Keywords: crash, needs-qa
Depends on:
Blocks:
 
Reported: 2020-06-19 20:01 UTC by Oleg Sidorkin
Modified: 2020-07-06 09:31 UTC (History)
1 user (show)

See Also:
arrowd: maintainer-feedback+
koobs: merge-quarterly?


Attachments
Fix iteration over postponed registrations set (813 bytes, patch)
2020-06-19 20:01 UTC, Oleg Sidorkin
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Oleg Sidorkin 2020-06-19 20:01:22 UTC
Created attachment 215797 [details]
Fix iteration over postponed registrations set

When entry is removed whth QSet<>::erase() the iterator is invalidated so it should not be used anymore. Iterator returned by QSet<>::erase() call should be used instead and not incremented on the given loop iteration (https://doc.qt.io/qt-5/qset-iterator.html)

The attached patch fixes looping (and my coredump).
bsdisks log is the following:
.....
"Registering /org/freedesktop/UDisks2/block_devices/nvd0p1"
Pop  "nvd0p1"  from m_postponedRegistrations
Ошибка адресации на шине(core dumped)
Comment 1 Lewis Cook freebsd_triage 2020-06-19 20:25:10 UTC
Hi Oleg, thanks for your submission. Just one minor thing:

When submitting a patch pertaining to a port, it's recommended that you generate it via `make makepatch`. So for instance in this case:

$ portsnap auto # If you haven't got the ports tree in /usr/ports already 
$ cd /usr/ports/sysutils/bsdisks
$ make fetch extract
$ cd work/bsdisks-*
$ cp objectmanager.cpp objectmanager.orig
$ # make the according changes to objectmanager.cpp
$ cd ../../
$ make makepatch

You'll then notice a new 'files/' directory was created that contains the patch 'patch-objectmanager.cpp'. From there you can generate a diff containing that change via svn. Again, for this instance:

$ cd /usr/ports # good idea to be at the root of the ports tree
$ svn diff sysutils/bsdisk > patch.diff

Then attach `patch.diff`. Whilst this isn't _needed_ it does make the life of a committer easier, as this saves the extra time of doing it themselves. For further reading see here: https://www.freebsd.org/doc/en_US.ISO8859-1/books/porters-handbook/port-upgrading.html#svn-diff.

Cheers!

^Lewis
Comment 2 Lewis Cook freebsd_triage 2020-06-19 20:31:56 UTC
(In reply to Lewis Cook from comment #1)
(Oops) More importantly... it's a _good_ idea to actually include the new files:

$ svn add files/patch-objectmanager.cpp
$ # then actually generate the diff

;)

^Lewis
Comment 3 Oleg Sidorkin 2020-06-19 22:38:06 UTC
(In reply to Lewis Cook from comment #1)
Thanks for feedback. 

I think this patch should not be commited as a ports patch. I suppose it will be upstreamed, and we will get new release of bsdisks (since bsdisks is freebsd-only software and port maintainer is the primary developer of bsdisks also). This happend in all bsdisks-related tickets I know.

So this was intentional. :)
I'll submit a proper svn diff patch in case of maintainer timeout.
Comment 4 Lewis Cook freebsd_triage 2020-06-19 22:43:32 UTC
(In reply to Oleg Sidorkin from comment #3)
No worries. Just wanted to mention an ever so slight typo in comment#1. When using `portsnap auto` this doesn't fetch the relevant svn repository meta-data, subsequently you'll be unable to `svn diff` so rather you can simply _just_ use (for example) `diff -u foo foo.orig > patch.diff`.

Another thing; when attaching a patch which is against the ports tree you need to request maintainer approval (if you're the maintainer, instead set [+]), so by changing the attachment flag: 

Attachment -> Details -> maintainer-approval [?]

Thanks for your time on this!

^Lewis
Comment 5 commit-hook freebsd_committer 2020-06-20 06:30:40 UTC
A commit references this bug:

Author: arrowd
Date: Sat Jun 20 06:30:07 UTC 2020
New revision: 539696
URL: https://svnweb.freebsd.org/changeset/ports/539696

Log:
  sysutils/bsdisks: Update WWW.

  PR:		247431

Changes:
  head/sysutils/bsdisks/pkg-descr
Comment 6 Gleb Popov freebsd_committer 2020-06-20 06:32:04 UTC
(In reply to Oleg Sidorkin from comment #3)
> I think this patch should not be commited as a ports patch. I suppose it will be upstreamed, and we will get new release of bsdisks

This is correct and it is my fault for not putting correct upstream link in the port's pkg-descr.

Thanks for the patch, I'll deal with the problem shortly.
Comment 7 Gleb Popov freebsd_committer 2020-06-20 07:26:29 UTC
Oleg, can you please try out my patch instead of yours? Does it also make the crash go away?


diff -r 9c76205b86ef objectmanager.cpp
--- a/objectmanager.cpp Sat May 23 20:59:10 2020 +0400
+++ b/objectmanager.cpp Sat Jun 20 11:25:34 2020 +0400
@@ -235,6 +235,7 @@
             {
                 qDebug() << "Pop " << *it << " from m_postponedRegistrations";
                 m_postponedRegistrations.erase(it);
+                break;
             }
         }
     } while(postponedSize > m_postponedRegistrations.size());
Comment 8 Oleg Sidorkin 2020-06-20 09:36:02 UTC
(In reply to Gleb Popov from comment #7)
Yes, this patch also helps.
Comment 9 commit-hook freebsd_committer 2020-06-20 10:05:20 UTC
A commit references this bug:

Author: arrowd
Date: Sat Jun 20 10:05:15 UTC 2020
New revision: 539725
URL: https://svnweb.freebsd.org/changeset/ports/539725

Log:
  sysutils/bsdisks: Update to 0.16

  PR:		247431
  Submitted by:	Oleg Sidorkin <osidorkin@gmail.com>

Changes:
  head/sysutils/bsdisks/Makefile
  head/sysutils/bsdisks/distinfo
Comment 10 Gleb Popov freebsd_committer 2020-06-20 10:08:29 UTC
Committed, thanks for your bug report.

I'll leave this open until someone do the MFH.