I am writing a multi-threads encryption application. The idea of the code is to create a number of threads to encrypt files. I have a thread pool say the maximum threads is 10. If the number of tasks (number of files waiting to be encrypted) is larger than the thread pool size, I first create 10 new threads to execute the encryption function. Then I wait for any of the threads to be signaled in the thread pool using WaitForMultipleObjects with WaitAll bit set to false. Then I close the handle to that thread and create a new thread on the slot. After all tasks are done, I call WaitForMultipleObjects with WaitAll bit to TRUE and wait all threads to terminate.
The error, access violation reading location 0x00000000 occurs in the last step. Trying to debug it, the memcpy.asm code pops up and terminates at the last line: rep movsd
Expand|Select|Wrap|Line Numbers
- Dword_align:
- test edi,11b ;U - destination dword aligned?
- jnz short CopyLeadUp ;V - if we are not dword aligned already, align
- shr ecx,2 ;U - shift down to dword count
- and edx,11b ;V - trailing byte count
- cmp ecx,8 ;U - test if small enough for unwind copy
- jb short CopyUnwindUp ;V - if so, then jump
- rep movsd ;N - move all of our dwords
Thanks