Skip to content

fix(developer): warn only on race when destroying TAppSourceHttpResponder#16140

Open
mcdurdin wants to merge 1 commit into
masterfrom
fix/developer/11916-warn-on-race-destroying-appsource
Open

fix(developer): warn only on race when destroying TAppSourceHttpResponder#16140
mcdurdin wants to merge 1 commit into
masterfrom
fix/developer/11916-warn-on-race-destroying-appsource

Conversation

@mcdurdin

Copy link
Copy Markdown
Member

I uncovered one race, documented in the source. Not trying to resolve that race at this time (it is not consequential). There is a second condition which is unclear -- and may have other consequences. So report a warning to Sentry when this arises, but do not crash out on the user.

Fixes: #11916
Test-bot: skip

…nder

I uncovered one race, documented in the source. Not trying to resolve
that race at this time (it is not consequential). There is a second
condition which is unclear -- and may have other consequences. So report
a warning to Sentry when this arises, but do not crash out on the user.

Fixes: #11916
Test-bot: skip
@keymanapp-test-bot

Copy link
Copy Markdown

User Test Results

Test specification and instructions

User tests are not required

Comment on lines 1150 to 1158
procedure TframeTextEditor.TntFormDestroy(Sender: TObject);
begin
inherited;
if FFileName <> '' then
modWebHttpServer.AppSource.UnregisterSource(FFileName);

FreeAndNil(FCharFont);
FreeAndNil(FCodeFont);
end;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From devin.ai:

Text editor does not guard UnregisterSource with IsSourceRegistered unlike touch layout builder

In TntFormDestroy (UframeTextEditor.pas:1153-1154), the text editor calls UnregisterSource(FFileName) directly, protected only by a FFileName <> '' check. By contrast, the touch layout builder at UframeTouchLayoutBuilder.pas:238-241 calls IsSourceRegistered before UnregisterSource. If the race condition described in the new destructor comments (lines 83-90 of the AppSource file) triggers in reverse — where the source is already unregistered before destruction — the text editor's UnregisterSource will hit the Assert(False, ...) at Keyman.Developer.System.HttpServer.AppSource.pas:366. This is a pre-existing inconsistency, not introduced by this PR, but the PR's new comments explicitly document that such races exist, making it worth noting.

Comment on lines 79 to 81
// Note: Unlike regular functions, Assert has short-circuit evaluation
// intrinsics on the first param which makes it safe to dereference T[0] in
// the second parameter.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is now outdated and should be removed or updated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

bug(developer): EAssertionFailed: Exception EAssertionFailed in module tike.exe at 008F4CDA.

2 participants