coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] sort: fix two race conditions reported by valgrind.


From: Shayan Pooya
Subject: Re: [PATCH] sort: fix two race conditions reported by valgrind.
Date: Mon, 13 Jan 2014 19:35:54 -0500

Hello,

Valgrind 3.9
The input is the output of: seq 1000 > ~/1K
The command line options: none:
$ valgrind --tool=drd ./coreutils/src/srot ~/1K -o ~/1K

There are some other race conditions reported by DRD for larger files (1M lines) that I am investigating.

P.S.
I am tracking down this issue: http://stackoverflow.com/q/21099839/830681

Regards.



On Mon, Jan 13, 2014 at 7:31 PM, Pádraig Brady <address@hidden> wrote:
On 01/14/2014 12:22 AM, Shayan Pooya wrote:
> Valgrind reported two race conditions when I ran sort on a small file.
> Both of them seem to be legitimate.
> ---
>  src/sort.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/src/sort.c b/src/sort.c
> index 3380be6..e6658e6 100644
> --- a/src/sort.c
> +++ b/src/sort.c
> @@ -3354,8 +3354,8 @@ queue_insert (struct merge_node_queue *queue, struct merge_node *node)
>    pthread_mutex_lock (&queue->mutex);
>    heap_insert (queue->priority_queue, node);
>    node->queued = true;
> -  pthread_mutex_unlock (&queue->mutex);
>    pthread_cond_signal (&queue->cond);
> +  pthread_mutex_unlock (&queue->mutex);
>  }
>
>  /* Pop the top node off the priority QUEUE, lock the node, return it.  */
> @@ -3950,7 +3950,7 @@ sort (char *const *files, size_t nfiles, char const *output_file,
>                sortlines (line, nthreads, buf.nlines, root,
>                           &queue, tfp, temp_output);
>                queue_destroy (&queue);
> -              pthread_mutex_destroy (&root->lock);
> +              pthread_mutex_destroy (&merge_tree->lock);
>                merge_tree_destroy (merge_tree);
>              }
>            else

Hi, what version of valgrind, command line options,
and sort input files did you use.

thanks,
Pádraig.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]