Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!
Bug 167536 - Hovering with the mouse over an ActiveRecord delete_all method in a debug session seems to invoke the statement
Hovering with the mouse over an ActiveRecord delete_all method in a debug ses...
Status: VERIFIED FIXED
Product: ruby
Classification: Unclassified
Component: Debugger
6.x
All Windows Vista
: P2 (vote)
: 6.x
Assigned To: Erno Mononen
issues@ruby
67patch1-verified
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2009-06-23 14:53 UTC by nuberion
Modified: 2009-07-15 12:28 UTC (History)
4 users (show)

See Also:
Issue Type: DEFECT
:


Attachments
screenshot (7.83 KB, image/png)
2009-06-23 14:55 UTC, nuberion
Details

Note You need to log in before you can comment on or make changes to this bug.
Description nuberion 2009-06-23 14:53:57 UTC
Hovering with the mouse over a delete_all method of an activerecord object in a debug session seems to invoke the statement


For example hovering once over the "delete_all" of the following statement
"Triple.delete_all(["subject_id = ? AND predicate_id = ? AND object_id IN (?)", self.resource_id, predicate_id,
delete_tag_ids])"
results in invoking a sql delete statement on the table without conditions and clears out all records in the table. The
number of all records in the table is shown in netbeans as a tooltip.

here's the mongrel log:
[4;35;1mTriple Delete all (1.0ms) [0m   [0mDELETE FROM `triples` [0m
[4;36;1mTriple Delete all (1.0ms) [0m   [0;1mDELETE FROM `triples` WHERE (subject_id = 1073687260 AND predicate_id =
111752331 AND object_id IN (842602804)) [0m
Comment 1 nuberion 2009-06-23 14:55:04 UTC
Created attachment 83938 [details]
screenshot
Comment 2 Erno Mononen 2009-06-23 15:09:29 UTC
Yay, that sounds pretty nasty. I'll take a look at this. Meanwhile you can disable tooltip evaluation to avoid this by 
using the ruby.debugger.skip.balloon.evaluation system variable, e.g. add 

-J-Druby.debugger.skip.balloon.evaluation=true 

to netbeans_default_conf in <nb_install_dir>/etc/netbeans.conf and restart the IDE.
Comment 3 Erno Mononen 2009-06-23 16:25:17 UTC
I think tooltip evaluation should not be enabled for method invocations by default as that can cause this kind of nasty 
side effects. Unfortunately the debugger isn't currently aware of the underlying AST and hence it isn't really possible 
to reliably recognize a method call from a variable. Making the debugger to use AST for this so close to FCS would be a 
bit risky, so I think we should target 6.7 patch 1. The workaround for now would be to use the system property 
described above (I'm also setting this to P2 due to the workaround) and I will start working on a proper fix for patch1 
when I'm back from my vacation next week. The issue has actually been there for as long as tooltip evaluation, so this 
isn't a regression in 6.7 and hence I'm a bit reluctant to completely disable tooltip evaluation by default (that would 
be just a question of setting the system property true by default).
Comment 4 Erno Mononen 2009-06-23 16:50:27 UTC
Just in case folks decide to fix this for 6.7 when I'm away, here are two ways to do it (I'm writing them here so that 
someone else can handle this if needed):

1. As written above, just change the default value of the 
org.netbeans.modules.ruby.debugger.ToolTipAnnotation#SKIP_BALLOON_EVAL system property to true 

2. Enable tooltip evaluation only for the selected text so that the user can't accidentally evaluate harmful methods 
(I'd prefer this solution):

diff -r 0539ec21c6dc ruby.debugger/src/org/netbeans/modules/ruby/debugger/ToolTipAnnotation.java
--- a/ruby.debugger/src/org/netbeans/modules/ruby/debugger/ToolTipAnnotation.java	Tue Jun 23 14:22:44 2009 +0200
+++ b/ruby.debugger/src/org/netbeans/modules/ruby/debugger/ToolTipAnnotation.java	Tue Jun 23 17:47:28 2009 +0200
@@ -119,6 +119,7 @@
             t = ep.getSelectedText();
         }
         if (t != null) { return t; }
+        if (t == null) { return null; }
         int line = NbDocument.findLineNumber(doc, offset);
         int col = NbDocument.findLineColumn(doc, offset);
         Element lineElem = NbDocument.findLineRootElement(doc).getElement(line);
Comment 5 Erno Mononen 2009-06-29 14:27:53 UTC
Should be fixed now in 5fd86688f814. The debugger now checks the type of the node under evaluation and proceeds to 
evaluate only if it wasn't a method call. To evaluate method calls, you need to select the method call. This should 
this kind of unfortunate side effects. Thanks once again for the report. Martin, can you please verify when you have 
the chance so that we can get the fix to patch1 -- thanks!
Comment 6 Quality Engineering 2009-06-30 05:44:36 UTC
Integrated into 'main-golden', will be available in build *200906300200* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/5fd86688f814
User: Erno Mononen <emononen@netbeans.org>
Log: #167536: Hovering with the mouse over an ActiveRecord delete_all method in a debug session seems to invoke the statement
- the tooltip annotation now checks the ast node type before evaluating and evaluates only if it should be safe to do so (based on the type)
- to evaluate method calls the user now needs to select the method call to evaluate. This prevents accidental side effects.
Comment 7 Martin Schovanek 2009-07-02 14:26:34 UTC
v.
Comment 8 pgebauer 2009-07-07 11:08:59 UTC
The fix has been ported into the release67_fixes repository.
http://hg.netbeans.org/release67_fixes/rev/5f6a1137f140


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo