Skip to content
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

bug(developer): starting multiple instances of TIKE simultaneously causes EFOpenError #11584

Open
sentry-io bot opened this issue May 28, 2024 · 2 comments · Fixed by #13341
Open

bug(developer): starting multiple instances of TIKE simultaneously causes EFOpenError #11584

sentry-io bot opened this issue May 28, 2024 · 2 comments · Fixed by #13341
Assignees
Milestone

Comments

@sentry-io
Copy link

sentry-io bot commented May 28, 2024

Sentry Issue: KEYMAN-DEVELOPER-1PR

OS Version: Windows 10.0.19045 (4291)
Report Version: 104


Application Specific Information:
Exception EFOpenError in module tike.exe at 000797B7.
Cannot open file "C:\Users\AHSN LAPTOP\Documents\Keyman Developer\Projects\kuswa_s_keyboard\kuswa_s_keyboard.kpj". The process cannot access the file because it is being used by another process.


Thread 0
0   tike.exe                        0x4797b7            System.Classes.TFileStream.Create (System.Classes.pas:9208)
1   tike.exe                        0x47966c            System.Classes.TFileStream.Create (System.Classes.pas:9178)
2   tike.exe                        0x73845f            Keyman.Developer.System.Project.ProjectFile.TProject.Load (Keyman.Developer.System.Project.ProjectFile.pas:844)
3   tike.exe                        0xe99321            Keyman.Developer.UI.Project.ProjectFileUI.TProjectUI.Load (Keyman.Developer.UI.Project.ProjectFileUI.pas:164)
4   tike.exe                        0x7380bd            Keyman.Developer.System.Project.ProjectFile.TProject.Create (Keyman.Developer.System.Project.ProjectFile.pas:782)
5   tike.exe                        0xe9914d            Keyman.Developer.UI.Project.ProjectFileUI.TProjectUI.Create (Keyman.Developer.UI.Project.ProjectFileUI.pas:137)
6   tike.exe                        0x8fef95            Keyman.Developer.UI.Project.ProjectUI.LoadGlobalProjectUI (Keyman.Developer.UI.Project.ProjectUI.pas:96)
7   tike.exe                        0xe9264f            UfrmMain.TfrmKeymanDeveloper.FormCreate (UfrmMain.pas:597)
8   tike.exe                        0x7c326f            JvDockControlForm.TJvDockBaseControl.DoFormOnCreate (JvDockControlForm.pas:2378)
9   tike.exe                        0x679ace            Vcl.Forms.TCustomForm.AfterConstruction (Vcl.Forms.pas:3722)
10  tike.exe                        0x679a7f            Vcl.Forms.TCustomForm.Create (Vcl.Forms.pas:3712)
11  tike.exe                        0x685110            Vcl.Forms.TApplication.CreateForm (Vcl.Forms.pas:10866)
12  tike.exe                        0xe9ca69            Keyman.Developer.System.Main.RunWithExceptionsHandled (Keyman.Developer.System.Main.pas:73)
13  tike.exe                        0xe9c8f2            Keyman.Developer.System.Main.RunKeymanDeveloper (Keyman.Developer.System.Main.pas:43)
14  tike.exe                        0xeb5388            tike.tike
15  KERNEL32.DLL                    0x7755fcc8          BaseThreadInitThunk
16  ntdll.dll                       0x77d07c5d          _RtlUserThreadStart
17  ntdll.dll                       0x77d07c2d          _RtlUserThreadStart

17.0.325

@mcdurdin
Copy link
Member

I was able to replicate this by running tike && tike at the command line -- indicating a race when two instances both try to load the project at the same time

@mcdurdin mcdurdin added this to the A18S3 milestone May 28, 2024
@mcdurdin mcdurdin self-assigned this May 28, 2024
@mcdurdin
Copy link
Member

This may require some rearchitecture of the TMultiProcessCoordinator to remove its dependency on window enumeration, because we enumerate the running processes before we create the main window, which means two processes may each independently do the window enumeration, find no windows, and both end up becoming the 'first' process, attempting to load the last open project.

Or we could always create the window before calling the enumeration? (This may have other side-effects to consider.)

Or as a stop-gap, we could fall back to a null-project scenario in the case of file lock, which would reduce the incidence of this.

@mcdurdin mcdurdin modified the milestones: A18S3, A18S4 Jun 7, 2024
@darcywong00 darcywong00 modified the milestones: A18S4, A18S5 Jun 21, 2024
@mcdurdin mcdurdin modified the milestones: A18S5, A18S7 Jul 5, 2024
@darcywong00 darcywong00 modified the milestones: A18S7, A18S8 Aug 2, 2024
@darcywong00 darcywong00 modified the milestones: A18S8, A18S9 Aug 17, 2024
@darcywong00 darcywong00 modified the milestones: A18S9, A18S10 Aug 31, 2024
@mcdurdin mcdurdin modified the milestones: A18S10, A18S20 Sep 2, 2024
@mcdurdin mcdurdin modified the milestones: A18S20, 19.0 Nov 25, 2024
@mcdurdin mcdurdin modified the milestones: 19.0, B18S2 Feb 17, 2025
@mcdurdin mcdurdin moved this to Todo in Keyman Feb 17, 2025
mcdurdin added a commit that referenced this issue Feb 24, 2025
…wo processes

There is a race condition where two processes may both attempt to open
the same project file. This appears to happen, for example, if an author
double-clicks on a single-click shortcut, launching Keyman Developer
twice in quick succession.

This fix adds a .lock file which is deleted automatically on close of
the project or on normal or abnormal process termination. If a second
process encounters the .lock file, it will simply open the welcome view
instead of attempting to open the project.

Fixes: #11584
Fixes: KEYMAN-DEVELOPER-1PR
mcdurdin added a commit that referenced this issue Feb 25, 2025
For the project lock files, instead of using a filename in the same path
as the project file, with a .lock extension, use a hash of the project
filename in the Keyman Developer appdata folder, to avoid confusion and
conflict in project folders.

Fixes: #11584
@mcdurdin mcdurdin moved this from Todo to In Progress in Keyman Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: In Progress
Development

Successfully merging a pull request may close this issue.

2 participants