-
Notifications
You must be signed in to change notification settings - Fork 165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Broken IO in multithreaded apps #791
Comments
Visual studio C compiler and Watcom/Open Watcom compilers report some problem with memory. |
I checked again my example and it looks what maximum number of concurrently using descriptors is 64. I updated my gist, now it should work in VC (it even work in MINGW with vc6 runtime). And it works under OW... sometimes. It means OW have same restriction to simultaneously 64 opened files somethere. I have 16 threaded cpu, if I set number of threads to 20, sometimes (50/50) I got error:
Semaphore unlocked by wrong owner |
your new sample code doesn't exhibit any problem.
no problem with any thread. I don't know how you compile it. I am using following command for Windows. |
I think the source of problem is incorrect use of WaitForMultipleObjects(THREADS_NUM, threads, TRUE, INFINITE); It supposes some synchronization setup for threads. |
No, there is nothing wrong with WaitForMultipleObjects. I created simpliest example. It just reopen files in infinite loop. https://gist.github.com/plzombie/9af6f2aaa8ec7a8b12dbc86e8296fd33 |
I did a some testing and it looks like some mistake in CRTL, because I get a run-time message "Semaphore unlocked by wrong owner". |
Please, could you recheck with latest version of OW V2. |
Hello. "Thread has no thread-specific data" is gone (although I can reproduce it in my first example). But I still get "Semaphore unlocked by wrong owner" error. |
Thanks for check. |
Windows 10 x64 21H2, 8core cpu. I will try it on my old system later, maybe I can reproduce |
I will try to check it on Windows 10, because OW can use some old construct (from Windows NT 3/4 era) which has problem with Windows 10 WoW64. |
I do more tests. I used my first and last example. |
Tested on WinXP SP3 (p3) - can reproduce 2nd example |
I will do more investigation. |
Hello. I found what if I call IO functions in separate threads (and more than one thread use IO functions at the same time), this thread crashed. Sometimes it prints error "Semaphore unlocked by wrong owner" or "Thread has no thread-specific data" before crashing.
I created test program what make many threads and each thread write data in separate file. Program was compiled with -bm flag. In very rare cases everything works fine, but usually threads crashed and some of them printed "Thread has no thread-specific data". Here is a link to test program
The text was updated successfully, but these errors were encountered: