src/http/modules/ngx_http_upstream_random_module.c:381: error: Integer Overflow L2
  ([0, +oo] - 1):unsigned64 by call to `ngx_rwlock_unlock`.

src/http/modules/ngx_http_upstream_random_module.c:335:13: Call
333.     for ( ;; ) {
334. 
335.         i = ngx_http_upstream_peek_random_peer(peers, rp);
                 ^
336. 
337.         peer = rp->conf->ranges[i].peer;

src/http/modules/ngx_http_upstream_random_module.c:412:9: Unknown value from: random
  410.     ngx_uint_t  i, j, k, x;
  411. 
  412.     x = ngx_random() % peers->total_weight;
               ^
  413. 
  414.     i = 0;

src/http/modules/ngx_http_upstream_random_module.c:412:5: Assignment
  410.     ngx_uint_t  i, j, k, x;
  411. 
  412.     x = ngx_random() % peers->total_weight;
           ^
  413. 
  414.     i = 0;

src/http/modules/ngx_http_upstream_random_module.c:381:13: Call
379. 
380.         if (++rp->tries > 20) {
381.             ngx_http_upstream_rr_peers_unlock(peers);
                 ^
382.             return ngx_http_upstream_get_round_robin_peer(pc, rrp);
383.         }

src/core/ngx_rwlock.c:89:1: <LHS trace>
87. 
88. 
89. void
    ^
90. ngx_rwlock_unlock(ngx_atomic_t *lock)
91. {

src/core/ngx_rwlock.c:89:1: Parameter `*lock`
  87. 
  88. 
  89. void
      ^
  90. ngx_rwlock_unlock(ngx_atomic_t *lock)
  91. {

src/core/ngx_rwlock.c:94:5: Assignment
  92.     ngx_atomic_uint_t  readers;
  93. 
  94.     readers = *lock;
          ^
  95. 
  96.     if (readers == NGX_RWLOCK_WLOCK) {

src/core/ngx_rwlock.c:103:13: Binary operation: ([0, +oo] - 1):unsigned64 by call to `ngx_rwlock_unlock` 
  101.     for ( ;; ) {
  102. 
  103.         if (ngx_atomic_cmp_set(lock, readers, readers - 1)) {
                   ^
  104.             return;
  105.         }

void
ngx_rwlock_unlock(ngx_atomic_t *lock)
{
    ngx_atomic_uint_t  readers;
    readers = *lock;
    if (readers == NGX_RWLOCK_WLOCK) {
        (void) ngx_atomic_cmp_set(lock, NGX_RWLOCK_WLOCK, 0);
        return;
    }
    for ( ;; ) {
        if (ngx_atomic_cmp_set(lock, readers, readers - 1)) {
            return;
        }
        readers = *lock;
    }
}
['static ngx_int_t\nngx_http_upstream_get_random2_peer(ngx_peer_connection_t *pc, void *data)\n{\n    ngx_http_upstream_random_peer_data_t  *rp = data;\n    time_t                             now;\n    uintptr_t                          m;\n    ngx_uint_t                         i, n, p;\n    ngx_http_upstream_rr_peer_t       *peer, *prev;\n    ngx_http_upstream_rr_peers_t      *peers;\n    ngx_http_upstream_rr_peer_data_t  *rrp;\n    ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0,\n                   "get random2 peer, try: %ui", pc->tries);\n    rrp = &rp->rrp;\n    peers = rrp->peers;\n    ngx_http_upstream_rr_peers_wlock(peers);\n    if (rp->tries > 20 || peers->single) {\n        ngx_http_upstream_rr_peers_unlock(peers);\n        return ngx_http_upstream_get_round_robin_peer(pc, rrp);\n    }\n    pc->cached = 0;\n    pc->connection = NULL;\n    now = ngx_time();\n    prev = NULL;\n#if (NGX_SUPPRESS_WARN)\n    p = 0;\n#endif\n    for ( ;; ) {\n        i = ngx_http_upstream_peek_random_peer(peers, rp);\n        peer = rp->conf->ranges[i].peer;\n        if (peer == prev) {\n            goto next;\n        }\n        n = i / (8 * sizeof(uintptr_t));\n        m = (uintptr_t) 1 << i % (8 * sizeof(uintptr_t));\n        if (rrp->tried[n] & m) {\n            goto next;\n        }\n        if (peer->down) {\n            goto next;\n        }\n        if (peer->max_fails\n            && peer->fails >= peer->max_fails\n            && now - peer->checked <= peer->fail_timeout)\n        {\n            goto next;\n        }\n        if (peer->max_conns && peer->conns >= peer->max_conns) {\n            goto next;\n        }\n        if (prev) {\n            if (peer->conns * prev->weight > prev->conns * peer->weight) {\n                peer = prev;\n                n = p / (8 * sizeof(uintptr_t));\n                m = (uintptr_t) 1 << p % (8 * sizeof(uintptr_t));\n            }\n            break;\n        }\n        prev = peer;\n        p = i;\n    next:\n        if (++rp->tries > 20) {\n            ngx_http_upstream_rr_peers_unlock(peers);\n            return ngx_http_upstream_get_round_robin_peer(pc, rrp);\n        }\n    }\n    rrp->current = peer;\n    if (now - peer->checked > peer->fail_timeout) {\n        peer->checked = now;\n    }\n    pc->sockaddr = peer->sockaddr;\n    pc->socklen = peer->socklen;\n    pc->name = &peer->name;\n    peer->conns++;\n    ngx_http_upstream_rr_peers_unlock(peers);\n    rrp->tried[n] |= m;\n    return NGX_OK;\n}', 'static ngx_uint_t\nngx_http_upstream_peek_random_peer(ngx_http_upstream_rr_peers_t *peers,\n    ngx_http_upstream_random_peer_data_t *rp)\n{\n    ngx_uint_t  i, j, k, x;\n    x = ngx_random() % peers->total_weight;\n    i = 0;\n    j = peers->number;\n    while (j - i > 1) {\n        k = (i + j) / 2;\n        if (x < rp->conf->ranges[k].range) {\n            j = k;\n        } else {\n            i = k;\n        }\n    }\n    return i;\n}', 'void\nngx_rwlock_unlock(ngx_atomic_t *lock)\n{\n    ngx_atomic_uint_t  readers;\n    readers = *lock;\n    if (readers == NGX_RWLOCK_WLOCK) {\n        (void) ngx_atomic_cmp_set(lock, NGX_RWLOCK_WLOCK, 0);\n        return;\n    }\n    for ( ;; ) {\n        if (ngx_atomic_cmp_set(lock, readers, readers - 1)) {\n            return;\n        }\n        readers = *lock;\n    }\n}']