CID 308517 (#1 of 1): Missing unlock (LOCK)

Ranier Vf ranier.vf at gmail.com
Wed Jun 12 01:11:42 UTC 2019


Hi,
You are right.
But with this warning I think Coverity is correct (not false positive).
file: ngx_unit.c
line: 3161 nxt_unit_process_use(ctx, process, -1);

If all conditions take true nxt_unit_process_use, free var process (line
2306).
And in line 3183, nxt_unit_process_use is called again, now with var
process freed.

static void
nxt_unit_process_use(nxt_unit_ctx_t *ctx, nxt_unit_process_t *process, int
i)
{
    long c;

    c = nxt_atomic_fetch_add(&process->use_count, i);
    if (i < 0 && c == -i) {
        nxt_unit_debug(ctx, "destroy process #%d", (int) process->pid);
        nxt_unit_mmaps_destroy(&process->incoming);
        nxt_unit_mmaps_destroy(&process->outgoing);
        free(process);
    }
}

Best regards,
Ranier Vilela

Em ter, 11 de jun de 2019 às 20:16, Valentin V. Bartenev <vbart at nginx.com>
escreveu:

> On Wednesday, 12 June 2019 01:59:37 MSK Ranier Vf wrote:
> > description: CID 308517 (#1 of 1): Missing unlock (LOCK)
> > unit: nxt_unit.c
> >
> > According Coverity Scan, missing_unlock: Returning without unlocking
> > lib->mutex.
>
> We use Coverity on a daily basis.  While sometimes it catches
> something interesting, but most of the time it has lots of false
> positives.
>
> >
> > --- c:\web\nginx\unit\a\src\nxt_unit.c    Mon Jun 10 12:47:35 2019
> > +++ nxt_unit.c    Tue Jun 11 19:50:59 2019
> > @@ -3140,6 +3140,7 @@
> >      }
> >
> >      nxt_unit_remove_process(ctx, process);
> > +    pthread_mutex_unlock(&lib->mutex);
> >  }
> >
>
> The nxt_unit_remove_process() function always unlocks this mutex.
>
>   wbr, Valentin V. Bartenev
>
>
>
>
> _______________________________________________
> unit mailing list
> unit at nginx.org
> https://mailman.nginx.org/mailman/listinfo/unit
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/unit/attachments/20190611/4bb670bd/attachment.html>


More information about the unit mailing list