Community
Participate
Working Groups
The following problem was reported via the automated error reporting: Message: HIDDEN org.eclipse.jface.text.BadLocationException: null at org.eclipse.jface.text.ListLineTracker.getLineNumberOfOffset(ListLineTracker.java:136) at org.eclipse.jface.text.AbstractLineTracker.getLineNumberOfOffset(AbstractLineTracker.java:151) at org.eclipse.jface.text.AbstractDocument.getLineOfOffset(AbstractDocument.java:867) at org.eclipse.ui.internal.console.ConsoleDocument.getLineOfOffset(ConsoleDocument.java:78) at org.eclipse.ui.internal.console.ConsolePatternMatcher$MatchJob.run(ConsolePatternMatcher.java:117) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55) The reporter(s) left the following comment(s): --- Anonymous wrote on 1d86: --- Paste from clipboard failed (Caps locked) It just happened nothing and the content appeared in the stack trace console instead. --- Anonymous wrote on 9cd1: --- I ran a JUnit-test and and opened a failed test. Then I clicked on "Show Stack Trace in Console View". Bundles: | org.eclipse.core.jobs | 3.7.0.v20150330-2103 | 3.10.0.v20171130-1004 | | org.eclipse.jface.text | 3.10.0.v20150603-1752 | 3.13.0.v20171130-2251 | | org.eclipse.ui.console | 3.6.100.v20150822-1912 | 3.7.100.v20171201-0724 | Operating Systems: | Linux | 2.6.32.15 | 4.15.1 | | MacOSX | 10.9.5 | 10.13.3 | | Windows | 6.1.0 | 10.0.0 | The above information is a snapshot of the collected data. Visit https://dev.eclipse.org/recommenders/committers/aeri/v2/#!/problems/5786281ae4b0b5f63da6b71f for the latest data. Thank you for your assistance. Your friendly error-reports-inbox.
I see it usually first time I open console from the error log view. Just happened again: eclipse.buildId=4.8.0.I20180316-0740 java.version=1.8.0_162 java.vendor=Oracle Corporation BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=de_DE Command-line arguments: -os win32 -ws win32 -arch x86_64 -data file:/C:/workspaces/platform/ org.eclipse.ui.console Error Fri Mar 16 23:18:08 CET 2018 Error logged from Console plug-in: org.eclipse.jface.text.BadLocationException at org.eclipse.jface.text.ListLineTracker.getLineNumberOfOffset(ListLineTracker.java:136) at org.eclipse.jface.text.AbstractLineTracker.getLineNumberOfOffset(AbstractLineTracker.java:151) at org.eclipse.jface.text.AbstractDocument.getLineOfOffset(AbstractDocument.java:868) at org.eclipse.ui.internal.console.ConsoleDocument.getLineOfOffset(ConsoleDocument.java:78) at org.eclipse.ui.internal.console.ConsolePatternMatcher$MatchJob.run(ConsolePatternMatcher.java:119) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:60)
New Gerrit change created: https://git.eclipse.org/r/119606
Gerrit change https://git.eclipse.org/r/119606 was merged to [master]. Commit: http://git.eclipse.org/c/platform/eclipse.platform.text.git/commit/?id=2845642ec596b6f74374b75e13234030803818fb
(In reply to Eclipse Genie from comment #2) > New Gerrit change created: https://git.eclipse.org/r/119606 Just adding some more context to the exception.
*** Bug 399638 has been marked as a duplicate of this bug. ***
Just got it again on 4.11 head. org.eclipse.jface.text.BadLocationException: Offset > length: 873 > 831 at org.eclipse.jface.text.ListLineTracker.getLineNumberOfOffset(ListLineTracker.java:141) at org.eclipse.jface.text.AbstractLineTracker.getLineNumberOfOffset(AbstractLineTracker.java:154) at org.eclipse.jface.text.AbstractDocument.getLineOfOffset(AbstractDocument.java:871) at org.eclipse.ui.internal.console.ConsoleDocument.getLineOfOffset(ConsoleDocument.java:81) at org.eclipse.ui.internal.console.ConsolePatternMatcher$MatchJob.run(ConsolePatternMatcher.java:117) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63) See also bug 334280 comment 2: it talks about missing synchronization in SynchronizableDocument.getLineOfOffset. We *also* have not synchronized access in ConsoleDocument.getLineOfOffset(int) (but we are not instance of SynchronizableDocument) - the only method in the class which is not synchronized!!! The synchronization was removed via bug 132398 comment 3 for performance reasons. Since ConsolePatternMatcher$MatchJob is not running in UI thread, it simply misses the updates done to the console document in UI thread. In the particular case of opening console for a given error I think we can do a small fix (without touching synchronization): in JavaStackTraceConsoleFactory.openConsole(String) we should NOT open console + init document unconditionally, but init only if there is no string to set as document. I will push a patch in a moment.
See also bug 478020 comment 2: on Windows I see an error at different exception an different code (StyledTextRenderer.textChanging) for the same action (open java console for an error in the error log view), but also there was an assumption that ConsoleDocumentAdapter.getLineAtOffset(int) doesn't work reliably. Interestingly, ConsoleDocumentAdapter.getLineAtOffset(int) does NOT use ConsoleDocument.getLineOfOffset(int) but implements its own lookup based on internal data (which is probably out-of-sync with the document).
New Gerrit change created: https://git.eclipse.org/r/136242
Gerrit change https://git.eclipse.org/r/136242 was merged to [master]. Commit: http://git.eclipse.org/c/jdt/eclipse.jdt.debug.git/commit/?id=b5e59dfae33aa090da6d5e963015e1d59cd4e8b9
New Gerrit change created: https://git.eclipse.org/r/141485
New Gerrit change created: https://git.eclipse.org/r/141487
This problem is not limited to the unsynchronized getLineOfOffset but to all document methods. The problem raise because MatchJob reads document length when it starts and than matches till its end. If document is changed meanwhile it may happen that MatchJob tries to match document parts which not exist anymore. There is some code which should handle such situations but fails in various cases. (In reply to Eclipse Genie from comment #10) > New Gerrit change created: https://git.eclipse.org/r/141485 I've created a test for this original problem with JavaStackTraceConsole initialization. It succeeds since your workaround for JavaStackTraceConsole works. (In reply to Eclipse Genie from comment #11) > New Gerrit change created: https://git.eclipse.org/r/141487 This test triggers the underlying problem with a simple TestConsole. Additional it includes a draft patch which synchronizes access to getLineOfOffset and stops MatchJob before document changes. It works quite good but since I learned more after my first work on this bug I'm quite sure it will break the console line tracker. In general it is quite hard to actual experience this bug (maybe apart from the original problem). In JavaStackTraceConsole I managed to trigger it after some tries by pasting a huge stack trace and immediately clearing the console. For IOConsole it may almost impossible to experience this bug. Typically the console document only grows which is unproblematic. The clear for IOConsole is performed by the trim job and the trim job does not run in concurrent with MatchJob due to job scheduling rules. So the only possibility to shrink the console document while MatchJob is running is user input and I think it is almost impossible a user removes enough input at the right moment to trigger an exception in MatchJob.
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie.