On Wed, Jan 20, 2021 at 11:18:16AM +0100, Florian Weimer wrote:
So it's a null pointer dereference.
745 * (largest first) to help achieve an optimal load distribution.
746 */
747 rpmRC packageBinaries(rpmSpec spec, const char *cookie, int cheating)
748 {
749 rpmRC rc = RPMRC_OK;
750 Package pkg;
751 Package *tasks;
752 int npkgs = 0;
753
754 for (pkg = spec->packages; pkg != NULL; pkg = pkg->next)
755 npkgs++;
756 tasks = xcalloc(npkgs, sizeof(Package));
757
758 pkg = spec->packages;
759 for (int i = 0; i < npkgs; i++) {
760 tasks[i] = pkg;
761 pkg = pkg->next;
762 }
763 qsort(tasks, npkgs, sizeof(Package), compareBinaries);
764
765 #pragma omp parallel
766 #pragma omp single
767 for (int i = 0; i < npkgs; i++) {
768 Package pkg = tasks[i];
769 #pragma omp task untied priority(i)
770 {
771 pkg->rc = packageBinary(spec, pkg, cookie, cheating,
&pkg->filename);
772 rpmlog(RPMLOG_DEBUG,
773 _("Finished binary package job, result %d, filename
%s\n"),
774 pkg->rc, pkg->filename);
775 if (pkg->rc) {
776 #pragma omp critical
777 rc = pkg->rc;
778 }
779 } /* omp task */
780 if (rc)
781 break;
782 }
It is definitely not valid OpenMP, because it is racy (that if (rc) part
with tasks writing that var).
It would need to use atomic accesses to rc, like:
#pragma omp atomic write
rc = pkg->rc;
instead of #pragma omp critical and
rpmRC testrc;
#pragma omp atomic read
testrc = rc;
if (testrc)
break;
But, that shouldn't be the reason why it crashed.
Jakub