This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 97760 - embeded javascript cause exception
Summary: embeded javascript cause exception
Status: VERIFIED FIXED
Alias: None
Product: web
Classification: Unclassified
Component: HTML Editor (show other bugs)
Version: 6.x
Hardware: All All
: P2 blocker (vote)
Assignee: Vitezslav Stejskal
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-03-13 16:23 UTC by Lukasz Grela
Modified: 2009-05-18 10:47 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
exception (3.54 KB, application/octet-stream)
2007-03-13 16:24 UTC, Lukasz Grela
Details
html document (449 bytes, application/octet-stream)
2007-03-13 16:24 UTC, Lukasz Grela
Details
The IDE output with debug exceptions (27.57 KB, application/octet-stream)
2007-03-26 12:53 UTC, Marek Fukala
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Lukasz Grela 2007-03-13 16:23:35 UTC
to reproduce paste attached html document into html editor
Comment 1 Lukasz Grela 2007-03-13 16:24:06 UTC
Created attachment 39446 [details]
exception
Comment 2 Lukasz Grela 2007-03-13 16:24:47 UTC
Created attachment 39447 [details]
html document
Comment 3 Lukasz Grela 2007-03-22 14:44:08 UTC
increasing priority to P1, it is annoying
Comment 4 Marek Fukala 2007-03-23 19:54:52 UTC
Vito, can you please take a look at the stacktrace? Looks like a highlighting
layer issue.

What came to my mind just from the simple fact that it is about a
ConcurrentModificationException is that I probably cause this somehow by
creating a dynamic embedding for javascript or css in HTML documents. If I am
supposed to be synchronized with something or run from a particullar thread pls
let me know.

BTW, to reproduce, you need to build the html/editor from 'embedding_60' branch,
I have sent an email to nb-scripting recently with a list of steps to build the
html-schliemann-embedding editor.

Thanks
Comment 5 Vitezslav Stejskal 2007-03-26 00:55:42 UTC
I'll have a look. The synchronization code in CHC is probably wrong, but even
when fixed the problem might not still be solved. CHC should only be accessed
under the documents read lock, which by itself should provide sufficient
synchronization. Anyway, I'll fix CHC and we will see if it bombs out somewhere
else.
Comment 6 Vitezslav Stejskal 2007-03-26 11:31:44 UTC
I'm struggling to reproduce this problem. There is nothing apparently wrong with
synchronization of CHC. The ConcurrentME means that while one thread is
iterating through highlights, some other thread modifies them. I tried the
example html and added html/editor from the embedding_60 branch, but without
success. No exception.

I've added some diagnostics to CHC, which should show a stacktrace of the last
thread that updated the CHC. Could you guys please try to reproduce the problem
and attach the enhanced stacktrace? You will have to run the IDE with a special
switch, eg:

ant
-Dtryme.args="-J-Dorg.netbeans.modules.editor.lib2.highlighting.CompoundHighlightsContainer.level=300"
tryme

Thanks.

Checking in CompoundHighlightsContainer.java;
/cvs/editor/lib2/src/org/netbeans/modules/editor/lib2/highlighting/CompoundHighlightsContainer.java,v
 <--  CompoundHighlightsContainer.java
new revision: 1.3; previous revision: 1.2
done
Comment 7 Marek Fukala 2007-03-26 12:52:32 UTC
I am attaching the IDE output with your switch. The debug exceptions are there.
As for the reproduction - do you have javascript and css modules installed? If
not, then the dynamic embeddings are not created and the probled doesn't show
up, I guess.
Comment 8 Marek Fukala 2007-03-26 12:53:40 UTC
Created attachment 39939 [details]
The IDE output with debug exceptions
Comment 9 Vitezslav Stejskal 2007-03-26 14:15:14 UTC
I have scripting/javascript (can see colored javascript tokens), but no css.
Anyway, thanks for the exception, it shows that there is a conflict between
EditorUpdater calling TokenSequence.createEmbedded and the component's repaint
request. Your code correctly acquires the read lock before calling
TS.createEmbedded, but this call modifies the tokens hierarchy, which is a
change that, I think, normally happens under the write lock when a document is
changed.

Marku, could you please try acquiring the write lock before calling TS.cE? If it
works we could use it as a hot fix for now and I'll discuss this with Mila.
Comment 10 Miloslav Metelka 2007-03-26 15:21:05 UTC
Yes, I support the idea to acquire the write-lock for the custom embedding
creation. Mainly because there is an issue 94365 for removal of a previously
created custom embedding and that cannot be done without the write-lock because
the token sequences already in use would suddenly fail. So using write-lock for
both creation and removal would be symmetrical and IMHO desired.
Comment 11 Lukasz Grela 2007-03-27 10:49:32 UTC
changing status whiteboard
Comment 12 Marek Fukala 2007-03-30 12:33:03 UTC
fixed by using NbEditorDocument.extWriteUn/Lock() as proposed. 

Checking in EmbeddingUpdater.java;
/cvs/html/editor/src/org/netbeans/modules/html/editor/coloring/EmbeddingUpdater.java,v
 <--  EmbeddingUpdater.java
new revision: 1.4.6.5; previous revision: 1.4.6.4
done
Comment 13 Jindrich Sedek 2007-09-24 13:25:19 UTC
verified
NetBeans IDE Dev (Build 20070923163726)