Andrew Geissler | 4b740dc | 2020-05-05 08:54:39 -0500 | [diff] [blame] | 1 | From 93c3c7f043f62e96941274e957c4ad9432032af1 Mon Sep 17 00:00:00 2001 |
| 2 | From: Alexander Kanavin <alex.kanavin@gmail.com> |
| 3 | Date: Mon, 18 Nov 2019 16:22:56 +0100 |
| 4 | Subject: [PATCH] rpmfc.c: do not run file classification in parallel |
| 5 | |
| 6 | This is causing freezes with libmagic when the file in question is compressed: |
| 7 | https://github.com/rpm-software-management/rpm/issues/756 |
| 8 | |
| 9 | Upstream-Status: Inappropriate [upstream wants a proper fix] |
| 10 | Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com> |
| 11 | --- |
| 12 | build/rpmfc.c | 8 -------- |
| 13 | 1 file changed, 8 deletions(-) |
| 14 | |
| 15 | diff --git a/build/rpmfc.c b/build/rpmfc.c |
| 16 | index 3db7a9352..17afdd57a 100644 |
| 17 | --- a/build/rpmfc.c |
| 18 | +++ b/build/rpmfc.c |
| 19 | @@ -680,7 +680,6 @@ static void rpmfcAttributes(rpmfc fc, int ix, const char *ftype, const char *ful |
| 20 | /* Add attributes on libmagic type & path pattern matches */ |
| 21 | if (matches(&(*attr)->incl, ftype, path, is_executable)) { |
| 22 | argvAddTokens(&fc->fattrs[ix], (*attr)->name); |
| 23 | - #pragma omp critical(fahash) |
| 24 | fattrHashAddEntry(fc->fahash, attr-fc->atypes, ix); |
| 25 | } |
| 26 | } |
| 27 | @@ -1105,7 +1104,6 @@ rpmRC rpmfcClassify(rpmfc fc, ARGV_t argv, rpm_mode_t * fmode) |
| 28 | /* Build (sorted) file class dictionary. */ |
| 29 | fc->cdict = rpmstrPoolCreate(); |
| 30 | |
| 31 | - #pragma omp parallel |
| 32 | { |
| 33 | /* libmagic is not thread-safe, each thread needs to a private handle */ |
| 34 | magic_t ms = magic_open(msflags); |
| 35 | @@ -1113,15 +1111,12 @@ rpmRC rpmfcClassify(rpmfc fc, ARGV_t argv, rpm_mode_t * fmode) |
| 36 | if (ms == NULL) { |
| 37 | rpmlog(RPMLOG_ERR, _("magic_open(0x%x) failed: %s\n"), |
| 38 | msflags, strerror(errno)); |
| 39 | - #pragma omp cancel parallel |
| 40 | } |
| 41 | |
| 42 | if (magic_load(ms, NULL) == -1) { |
| 43 | rpmlog(RPMLOG_ERR, _("magic_load failed: %s\n"), magic_error(ms)); |
| 44 | - #pragma omp cancel parallel |
| 45 | } |
| 46 | |
| 47 | - #pragma omp for ordered reduction(+:nerrors) |
| 48 | for (int ix = 0; ix < fc->nfiles; ix++) { |
| 49 | rpmsid ftypeId; |
| 50 | const char * ftype; |
| 51 | @@ -1185,14 +1180,11 @@ rpmRC rpmfcClassify(rpmfc fc, ARGV_t argv, rpm_mode_t * fmode) |
| 52 | fc->fcolor[ix] = fcolor; |
| 53 | |
| 54 | /* Add to file class dictionary and index array */ |
| 55 | - #pragma omp ordered |
| 56 | if (fcolor != RPMFC_WHITE && (fcolor & RPMFC_INCLUDE)) { |
| 57 | ftypeId = rpmstrPoolId(fc->cdict, ftype, 1); |
| 58 | - #pragma omp atomic |
| 59 | fc->fknown++; |
| 60 | } else { |
| 61 | ftypeId = rpmstrPoolId(fc->cdict, "", 1); |
| 62 | - #pragma omp atomic |
| 63 | fc->fwhite++; |
| 64 | } |
| 65 | /* Pool id's start from 1, for headers we want it from 0 */ |