provegard / ncdbg

A debugger for Nashorn that uses Chrome DevTools as frontend
BSD 3-Clause "New" or "Revised" License
31 stars 5 forks source link

java.lang.IllegalStateException: Property extraction can only be done in a paused state. #77

Closed benoitcerrina closed 6 years ago

benoitcerrina commented 6 years ago

When pausing then either stepping or running till the next break point I often have the following exception trace which shows up in the console. It is not happening at every step and I haven't found a good way to always reproduce it.

Message handling error for domain Runtime java.lang.IllegalStateException: Property extraction can only be done in a paused state. at com.programmaticallyspeaking.ncd.nashorn.ObjectPropertiesSupport.getObjectProperties(ObjectPropertiesSupport.scala:59) at com.programmaticallyspeaking.ncd.nashorn.ObjectPropertiesSupport.getObjectProperties$(ObjectPropertiesSupport.scala:20) at com.programmaticallyspeaking.ncd.nashorn.NashornDebuggerHost.getObjectProperties(NashornDebuggerHost.scala:172) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.programmaticallyspeaking.ncd.infra.ExecutorProxy$Handler.$anonfun$invoke$3(ExecutorProxy.scala:42) at scala.util.Try$.apply(Try.scala:209) at com.programmaticallyspeaking.ncd.infra.ExecutorProxy$Handler.$anonfun$invoke$2(ExecutorProxy.scala:42) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)

provegard commented 6 years ago

Thanks for reporting! Yes, I have seen that as well, and though it's harmless (I think) it's of course pretty annoying.

I could add logging of the object ID for which properties are requested, but that doesn't help as long as object IDs are basically just sequence numbers.

Do you have any active watches when this happens? Is the scope tree expanded?

benoitcerrina commented 6 years ago

I checked that I didn't have active watches but not the scope tree. I'll pay attention to that next time it happens. On a related question, I was wondering how to debug ncdbg itself. I have to say I have no experience with Scala but I do with a lot of other languages and think I could understand it pretty quickly but I would first want to connect a debugger. Can you tell me how it is done?

benoitcerrina commented 6 years ago

Just reproduced the exception with the scope tree collapsed and no watch

provegard commented 6 years ago

I'm not at the computer right now so I cannot post a screenshot, but here's what I do:

  1. Import the Gradle file in IDEA with Gradle and Scala plugins.
  2. Navigate to the Boot class.
  3. Click the green arrow next to the class name line.
  4. Select Debug.

There's nothing more to it, really. This assumes that the debug target uses the default port. If not you'll have to edit a run configuration manually.

benoitcerrina commented 6 years ago

thanks got the debugger running in eclipse with Scala plugins, what I was missing was that the class to start was the Boot class.

provegard commented 6 years ago

Requests from DevTools are now serialized, which means that a call to get object properties should complete before the VM is resumed. Could you please test it?

benoitcerrina commented 6 years ago

I just updated to the latest code from github. I have some tests on my project to debug with ncdbg this afternoon so I'll update you this evening on whether I still see this

provegard commented 6 years ago

Sounds great!

benoitcerrina commented 6 years ago

haven't reproduced this afternoon, I think your fix did the trick.

provegard commented 6 years ago

Excellent, thanks for testing!

benoitcerrina commented 6 years ago

your welcome. I have to say prior to finding ncdbg we were using netbeans for Nashorn debugging and it really doesn't work well. In particular we can't execute js code in the console and it doesn't work at all with scripts loaded using eval so we had to setup a special debugging mode where are scripts would be loaded differently from normal. So thanks for your work on this tool.

provegard commented 6 years ago

Yeah, I had a similar experience with IDEA. I'm glad you find ncdbg useful!