Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 365770 - Race condition in IOConsolePartitioner causes console output to be lost
Summary: Race condition in IOConsolePartitioner causes console output to be lost
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Debug (show other bugs)
Version: 3.7   Edit
Hardware: All All
: P3 normal with 1 vote (vote)
Target Milestone: 4.15 M3   Edit
Assignee: Paul Pazderski CLA
QA Contact:
URL:
Whiteboard: 4.15 M2
Keywords:
: 323816 (view as bug list)
Depends on:
Blocks: 553348
  Show dependency tree
 
Reported: 2011-12-06 12:04 EST by Petar Petrov CLA
Modified: 2020-01-17 15:24 EST (History)
4 users (show)

See Also:


Attachments
Plugin to test race condition (8.16 KB, application/x-zip-compressed)
2020-01-13 16:34 EST, Paul Pazderski CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Petar Petrov CLA 2011-12-06 12:04:05 EST
Build Identifier: 20110615-0604

In IOConsolePartitioner there are two jobs - QueueProcessingJob and TrimJob. Although they cannot run simultaneously, there is no guarantee about the order in which they'll run. 
This may cause corrupted console output for clients of MessageConsole in the case where in same thread first there is a call to MessageConsole.clearConsole() and immediately after that several calls to println() on the message stream acquired from the console. In this case there the job for clearing the console may run after the job for processing the message stream, thus loosing lines.

Reproducible: Always
Comment 1 Paul Pazderski CLA 2019-08-30 17:26:51 EDT
This is still an issue. I have an idea how to fix it but first want to merge my other pending console changes or I conflict with myself.
Comment 2 Sarika Sinha CLA 2020-01-06 00:06:06 EST
Moved to M3, please change if you have some other plans.
Comment 3 Paul Pazderski CLA 2020-01-09 16:10:09 EST
*** Bug 323816 has been marked as a duplicate of this bug. ***
Comment 4 Eclipse Genie CLA 2020-01-11 17:38:37 EST
New Gerrit change created: https://git.eclipse.org/r/155654
Comment 5 Paul Pazderski CLA 2020-01-11 17:39:03 EST
Apart from the reported situation with print after clear and the later printed content is falsely cleared the reversed situation is also possible. It is just less useful but also possible that a print immediately followed by clear still shows the printed content in console.

If a user does the following in a single thread:
  outStream.print("First");
  console.clearConsole();
  outStream.print("Second");
he can expect to see only "Second" in console and after this change it should be the case.
Comment 6 Paul Pazderski CLA 2020-01-13 16:34:07 EST
Created attachment 281477 [details]
Plugin to test race condition

I made a small plugin for verification. It adds a test console (ClearConsole) and a test button/icon in Console view (eclipse icon). In fact the button is added and usable on each MessageConsole.

The button execute similar code as in my example above.
Print "must be cleared"
Clear
Print "must be shown"

Before fix with race condition described in comment 0 the actual result is an empty console. In the other race condition I added it shows both strings. In fixed console only the second string is visible.
Comment 8 Paul Pazderski CLA 2020-01-17 15:24:32 EST
(In reply to Paul Pazderski from comment #1)
> This is still an issue. I have an idea how to fix it but first want to merge
> my other pending console changes or I conflict with myself.

Old implementation set next trim offset to -1 and the trim job removes all if offset is -1. The idea and fix is to use the current document length when clear is called as trim offset. This way content added after clear but before trim is not cleared anymore.