I have not tested audio-related functions, so I'm sorry if my fix is not
 correct. I just knew that one parameter was missing and the code did 
not compile, so I thought buf would be the correct value to pass.<br><br>I
 can elaborate about the second fix however. I noticed the problem, when
 I encountered segfaults when calling ph_dct_image_hashes with four 
input files and asking for four threads. After some digging in, it 
turned out that the code does not correctly slice the passed files for 
the threads. A simple test can show this. Suppose that we pass an array 
of four files and ask the function to use four threads. Just before 
entering the loop we have:<br>
<br>rem = 0<br>start = 0<br>off =0<br><br>after the first iteration:<br><br>off
 = 1<br>start = 1<br>rem = -1<br><br>in the subsequent iterations, off's
 value will not change (because rem is less than zero) so while the 
first thread calculates the cash for file 1, the other three will all 
work on file 2 and the third and four files will not be processed, hence
 the segfault when trying to retrieve the hashes. I think it's apparent 
that start needs to change for the function to slice its input 
correctly.<br>
<br>I hope this clears things up. I should add that after changing 
"start = off" to "start += off" things started to work correctly.<br><br>Cheers,<br>Mostafa<br><br>P.S.: I first sent this reply using my other mail account, and then I noticed my mistake and sent it again. Sorry about that. I think it would have been better if I had subscribed using this account since the other one is forwarded to this, and there's always the chance that I forget to change the sender.<br>
<br><br><div class="gmail_quote">On Fri, Jun 11, 2010 at 11:46 PM, Evan Klinger <span dir="ltr"><<a href="mailto:eklinger@phash.org">eklinger@phash.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Mostafa,<br>
<br>
Thank you for submitting your patch. However, I believe the correct<br>
fix in the multithreaded audio function is to pass NULL as the buf and<br>
the readaudio() function will create the buffer for you and return it.<br>
Can you explain your fix in the multithreaded image hash function? The<br>
off variable is really the absolute starting position for the<br>
subsequent thread and not an offset that should be added to start.<br>
Please provide a test case where the function fails to set start<br>
correctly.<br>
<br>
Thank you<br>
Evan<br>
<div><div></div><div class="h5"><br>
On Fri, Jun 11, 2010 at 11:53 AM, Mostafa Razavi <<a href="mailto:hom.sepanta@gmail.com">hom.sepanta@gmail.com</a>> wrote:<br>
> Hi. I'm a new user of pHash and I just encountered two bugs in threading<br>
> related codes. I think the patch is self-explanatory (only two lines have<br>
> been changed). I made the patch against current source tarball (0.9.0).<br>
><br>
> Cheers,<br>
> Mostafa Razavi<br>
><br>
><br>
</div></div>> _______________________________________________<br>
> pHash-support mailing list<br>
> <a href="mailto:pHash-support@lists.phash.org">pHash-support@lists.phash.org</a><br>
> <a href="http://lists.phash.org/listinfo.cgi/phash-support-phash.org" target="_blank">http://lists.phash.org/listinfo.cgi/phash-support-phash.org</a><br>
><br>
><br>
</blockquote></div><br>