Jump to page: 1 2 3
Thread overview
[Issue 13727] std.stdio.File not thread-safe
Nov 13, 2014
Vladimir Panteleev
Nov 13, 2014
Vladimir Panteleev
Nov 13, 2014
Vladimir Panteleev
Nov 14, 2014
Vladimir Panteleev
Nov 14, 2014
Vladimir Panteleev
Oct 08, 2015
Vladimir Panteleev
May 09, 2016
Walter Bright
Jun 23, 2016
Jack Stouffer
Jun 30, 2016
ZombineDev
Jul 18, 2016
det
Dec 10, 2017
Walter Bright
Mar 12, 2018
Walter Bright
Mar 13, 2018
Walter Bright
Apr 02, 2018
Seb
May 28, 2019
Jonathan Marler
May 28, 2019
Dlang Bot
May 28, 2019
Dlang Bot
May 29, 2019
Dlang Bot
May 29, 2019
Dlang Bot
Jan 23, 2021
Dlang Bot
Dec 17, 2022
Iain Buclaw
November 13, 2014
https://issues.dlang.org/show_bug.cgi?id=13727

Vladimir Panteleev <thecybershadow@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://issues.dlang.org/sh
                   |                            |ow_bug.cgi?id=11862

--
November 13, 2014
https://issues.dlang.org/show_bug.cgi?id=13727

--- Comment #1 from Vladimir Panteleev <thecybershadow@gmail.com> ---
Note that even though the above example has all threads reading from the same file, this doesn't matter, as the problem occurs even when accessing distinct files.

--
November 13, 2014
https://issues.dlang.org/show_bug.cgi?id=13727

Steven Schveighoffer <schveiguy@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |schveiguy@yahoo.com

--- Comment #2 from Steven Schveighoffer <schveiguy@yahoo.com> ---
I'm going to throw a shot in the dark out here, and say it's an issue with DMC runtime. Which means it's really a problem with DMC, not DMD or phobos.

I'll note that the DMC runtime has a limit of 64 file descriptors, including the standard handles.

--
November 13, 2014
https://issues.dlang.org/show_bug.cgi?id=13727

--- Comment #3 from Vladimir Panteleev <thecybershadow@gmail.com> ---
(In reply to Steven Schveighoffer from comment #2)
> I'm going to throw a shot in the dark out here, and say it's an issue with DMC runtime. Which means it's really a problem with DMC, not DMD or phobos.

I agree. However, we might be able to work around thread safety issues in the DMC runtime using global locks.

> I'll note that the DMC runtime has a limit of 64 file descriptors, including the standard handles.

This shouldn't be relevant except when running the test program on systems with 64 or more processors/cores.

--
November 13, 2014
https://issues.dlang.org/show_bug.cgi?id=13727

--- Comment #4 from Steven Schveighoffer <schveiguy@yahoo.com> ---
(In reply to Vladimir Panteleev from comment #3)
> (In reply to Steven Schveighoffer from comment #2)
> > I'm going to throw a shot in the dark out here, and say it's an issue with DMC runtime. Which means it's really a problem with DMC, not DMD or phobos.
> 
> I agree. However, we might be able to work around thread safety issues in the DMC runtime using global locks.

Oh god! More locks :)

I strongly believe we should fix the issue in DMC. Can we create a C++ program that will exhibit the same issue?

> 
> > I'll note that the DMC runtime has a limit of 64 file descriptors, including the standard handles.
> 
> This shouldn't be relevant except when running the test program on systems with 64 or more processors/cores.

Oh, I didn't realize how the parallel foreach worked.

--
November 14, 2014
https://issues.dlang.org/show_bug.cgi?id=13727

--- Comment #5 from Vladimir Panteleev <thecybershadow@gmail.com> ---
(In reply to Steven Schveighoffer from comment #4)
> Oh god! More locks :)

Assuming we don't need to lock for the actual I/O operations (read/write), I
think the impact for locking on some O(1)-ish operations shouldn't be too bad
compared to the cost of the actual I/O.

> I strongly believe we should fix the issue in DMC. Can we create a C++ program that will exhibit the same issue?

Yes:

///////////////////////////// test.c ////////////////////////////
#include <windows.h>
#include <stdio.h>

DWORD WINAPI ThreadProc(LPVOID lpParameter)
{
    for (int i=0; i<100; i++)
    {
        int res;
        FILE* f = fopen("test.c", "rb");
        if (!f) { printf("fopen failed\n"); return 1; }
        res = fclose(f);
        if (res) { printf("fclose failed\n"); return 1; }
    }
    return 0;
}

void main()
{
    for (int i=0; i<10; i++)
    {
        DWORD dwThreadId;
        CreateThread(NULL, 0, &ThreadProc, NULL, 0, &dwThreadId);
    }
}
/////////////////////////////////////////////////////////////////

--
November 14, 2014
https://issues.dlang.org/show_bug.cgi?id=13727

--- Comment #6 from Vladimir Panteleev <thecybershadow@gmail.com> ---
> I strongly believe we should fix the issue in DMC.

BTW, I agree in principle, but I don't know how realistic this is, considering it's closed-source and I don't know how hard or quick it is to get a patch in.

--
November 14, 2014
https://issues.dlang.org/show_bug.cgi?id=13727

Steven Schveighoffer <schveiguy@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@digitalmars.com

--- Comment #7 from Steven Schveighoffer <schveiguy@yahoo.com> ---
(In reply to Vladimir Panteleev from comment #6)
> > I strongly believe we should fix the issue in DMC.
> 
> BTW, I agree in principle, but I don't know how realistic this is, considering it's closed-source and I don't know how hard or quick it is to get a patch in.

It's on github, but private. Ask Walter for access.

I fixed an issue once with pipes that was holding up std.process, so I still have access.

I will warn you, though, you can't build it unless you have some obscure assembler :)

At the very least, your sample code should be filed as a DMC bug, but I'm not sure where that goes.

CC'ing Walter on this.

--
October 08, 2015
https://issues.dlang.org/show_bug.cgi?id=13727

Vladimir Panteleev <thecybershadow@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #8 from Vladimir Panteleev <thecybershadow@gmail.com> ---
https://github.com/DigitalMars/dmc/pull/2 (access required)

--
May 09, 2016
https://issues.dlang.org/show_bug.cgi?id=13727

--- Comment #9 from Walter Bright <bugzilla@digitalmars.com> ---
Adding test case:

https://github.com/dlang/dmd/pull/5747

--
« First   ‹ Prev
1 2 3