Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ Bug reports
➜ A access violation caused by race condition
A access violation caused by race condition
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Kahenraz
(75 posts) Bio
|
Date
| Wed 21 Sep 2016 03:01 AM (UTC) |
Message
| I have an external script file which I have set to automatically recompile changes "always" so that it's faster to test and debug with an external editor.
The problem I'm encountering is that sometimes MUSH will report a sharing violation:
---------------------------
MUSHclient
---------------------------
A sharing violation occurred while accessing C:\data\games\Mush\worlds\scripts\functions.lua.
---------------------------
OK
---------------------------
This is most likely due MUSH trying to read from the file while my editor is still writing to it.
A workaround for this would be to retry on a delay (sleep every 10ms or so) and if there is still an access violation after say, 3-5 seconds then report the access violation. | Top |
|
Posted by
| Fiendish
USA (2,534 posts) Bio
Global Moderator |
Date
| Reply #1 on Wed 21 Sep 2016 08:48 AM (UTC) |
Message
| Huh. This is the sort of thing I expect my OS to abstract away. |
https://github.com/fiendish/aardwolfclientpackage | Top |
|
Posted by
| Kahenraz
(75 posts) Bio
|
Date
| Reply #2 on Wed 21 Sep 2016 02:25 PM (UTC) |
Message
| You can't abstract away an IO error because it's blocking. | Top |
|
Posted by
| Fiendish
USA (2,534 posts) Bio
Global Moderator |
Date
| Reply #3 on Wed 21 Sep 2016 06:45 PM (UTC) |
Message
|
Quote: You can't abstract away an IO error because it's blocking.
Eh. None of that needs to be true with only one writer. |
https://github.com/fiendish/aardwolfclientpackage | Top |
|
Posted by
| Kahenraz
(75 posts) Bio
|
Date
| Reply #4 on Wed 21 Sep 2016 06:58 PM (UTC) Amended on Wed 21 Sep 2016 06:59 PM (UTC) by Kahenraz
|
Message
| You can't always read from a file while it's being written to. That's the race condition.
MUSH tries to detect changes in the file but doesn't handle instances where the write isn't atomic and needs to wait until the read is finished.
Just keep trying to read the file on a delay and with a reasonable timeout.
A simpler alternative is to copy the file to a unique temporary file and read it from there. I can't confirm but I'm pretty sure that the copy will block until it has a valid file handle. Just remember to delete the copy afterwards. | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #5 on Thu 22 Sep 2016 03:55 AM (UTC) |
Message
|
Quote:
A access violation caused by race condition
Do you mean a sharing violation? They aren't the same thing.
Some editors always write to a temporary file and rename at the last moment. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Kahenraz
(75 posts) Bio
|
Date
| Reply #6 on Thu 22 Sep 2016 03:58 AM (UTC) |
Message
| I'm not certain where the error is coming from exactly but it happens between the time I save the file and MUSH tries to load it.
The error is annoying because I then have to switch to MUSH and click the little box to close before I can continue. | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #7 on Thu 22 Sep 2016 09:19 PM (UTC) |
Message
| You can turn off auto-reloading and just hit Shift+Ctrl+R when you are ready. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Kahenraz
(75 posts) Bio
|
Date
| Reply #8 on Thu 22 Sep 2016 09:22 PM (UTC) |
Message
| I like the auto-reload functionality because it's easier to just reload the script every time I make a change.
All I want is for the client to make an effort to recover from this error rather than throwing up the message box outright. | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #9 on Thu 22 Sep 2016 09:56 PM (UTC) |
Message
| Well, this is the first time this was reported in over 10 years. I don't really want to build in a delay, or have the added complexity of noticing a file changes, but keeping on trying to read it.
I've changed it from a dialog box to a message in the output window. If you see the error message, then you can force a reload.
https://github.com/nickgammon/mushclient/commit/aa0cd16 |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
27,632 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top