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 116683 - Function in watch is not evaluated
Summary: Function in watch is not evaluated
Status: VERIFIED FIXED
Alias: None
Product: cnd
Classification: Unclassified
Component: Debugger (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: _ gordonp
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-09-25 14:28 UTC by Alexander Pepin
Modified: 2009-06-25 10:59 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
gdb log (30.62 KB, application/octet-stream)
2007-10-11 16:04 UTC, Alexander Pepin
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Pepin 2007-09-25 14:28:30 UTC
See also issue #115464
Steps to reproduce:
- create Quote sample project
- do step into project
- do steps over until "discount" is calculated (in line 113) for name "John"
- add a new watch for "getDiscountFor(customerName)", keep in mind that customerName
is defined and  a real "discount" is obtained
Result: The value of the expression becomes:
>The program being debugged was signaled while in a function called from GDB.\nGDB has restored the context to what it
was before the call.\nTo change this behavior use "set unwindonsignal off"\nEvaluation of the expression containing the
function ((anonymous namespace)::getDiscountFor(std::string)) will be abandoned<
Comment 1 _ gordonp 2007-09-25 15:10:37 UTC
For some reason gdb is saying customerName isn't in scope, even though it is.

I tried this on Solaris with gdb 6.6 and duplicated the problem. The same test
works on Solaris from the command line. I'll try on Windows but I just started
a complete clean of my netbeans sources so I can't for an hour or so...

What platform were you on when you saw this problem?
Comment 2 _ gordonp 2007-09-25 15:37:57 UTC
Actually, it did not work from the gdb command line. I evaluated "customerName" rather than
"getDiscountFor(customerName)". When I tried the function, I got the same SEGV I get in the
IDE.

While I can't fix the fact gdb is segv'ing on the function call, I will replace the gdb
message with a shorter one. I'll also see if it behaves differently on Windows and on Solaris
with older versions of gdb.
Comment 3 _ gordonp 2007-10-03 00:20:53 UTC
Fixed
Comment 4 Alexander Pepin 2007-10-05 13:09:32 UTC
In build 20071005
Now gdb fails when a user creates a watch for getDiscountFor(customerName).
- clean watches
- perform the scenario from the description but add a new watch by selecting the function with a parameter in code and
calling a context menu->New Watch (or Ctrl+Shift+F7). The watch appears with messages ">No symbol "customerName" in
current context<" 
- do step over
Result: The process exited with signal "SIGSEGV" on Linux and fails on Windows. When the watch was created before
starting   a debugger or just after stepping into or manually via the Watches window then function is not evaluated but
debugger does not fail. The Value shows ">Gdb aborted evaluation<"
Comment 5 _ gordonp 2007-10-05 21:35:36 UTC
There are 2 problems here:

Problem 1: Gdb fails to evaluate "getDiscountFor(customerName)". Instead, if gets a SIGSEGV.
This is not a gdb-lite problem. Its either a gdb or g++ problem. Gdb is treating customerName
as if its out-of-scope and getDiscountFor fails because its getting a random address passed
to it.

The best I can do here is to make sure the SEGV doesn't destroy the debug session, and replace
the long message with one more user friendly. Thats what I did in my original commit for this
bug. There is nothing I can do to keep gdb from getting a segv on what should be a valid watch.

The 2nd problem is the process exiting with a SEGV. This actually isn't a watch problem but a
tooltip problem. When you highlight "getDiscountFor(customerName)" it sends a tooltip request
to gdb. Its very similar to what happens when you do the watch request for the same string. But
while I unset breakpoints and tell gdb to ignore signals for watches, I didn't do that for
tooltips. Hence the SEGV.

The solution is to do for tooltip requests which make function calls exactly what I do for
watches which make function calls. I've made that change and the SEGV goes away.

By the way, the SEGV happens on both Linux and Solaris (I've got my PC booted to Linux now, so
I can't see what happens on Windows).

I'm closing this bug because I committed the tooltip fix. But the aborted watch cannot be fixed
in gdb-lite. I did notice that on Ubuntu (with g++ 4.1.1) the watch and tooltip work. Thats why
I'm inclined to think its a g++ bug and not a gdb bug. My hypothesis is that there is no debug
information for customerName inside the do-while block and thats why the call fails.
Comment 6 Alexander Pepin 2007-10-11 15:53:50 UTC
The following watch causes GDB crash on Windows in Quote sample:
getDiscountFor("John")

Gdb crashes with an error window: 
Error: Unexpected GDB Failure
The GDB Debugger has exited unexpectedly with a return code of 35584.
Comment 7 Alexander Pepin 2007-10-11 16:04:38 UTC
Created attachment 50700 [details]
gdb log
Comment 8 Maria Tishkova 2007-10-11 16:14:45 UTC
I would like to note that command line gdb will work the same way, I have tried on my laptop and Segmentation fault
(core dumped) occurred when I have tried to invoke
print getDiscountFor("Ann")

So, it looks more like gdb problem, not gdb-lite,and I think we should close it as INVALID

Alexander, if you have case where gdb-lite (not gdb) will crash please reopen this IZ
Comment 9 Jesse Grodnik 2007-10-11 16:24:04 UTC
We need to advocate for a fix in gdb. Have we explored this issue with the gdb community?
Comment 10 Alexander Pepin 2007-10-11 16:28:52 UTC
Indeed it's a GDB bug, somehow i missed it. The similar situation is with evaluating of expression so I mark the issue
as verified.
Comment 11 _ gordonp 2007-10-11 20:42:45 UTC
Filed gdb bug report:

> Thank you very much for your problem report.
> It has the internal identification `c++/2333'.
> The individual assigned to look at your
> report is: unassigned. 
> 
> > >Category:       c++
> > >Responsible:    unassigned
> > >Synopsis:       gdb gets segv evaluating valid function call
> > >Arrival-Date:   Thu Oct 11 19:38:01 UTC 2007
Comment 12 Jesse Grodnik 2007-10-11 22:03:21 UTC
The crash does not happen with GDB 6.6 only with GDB 6.5 (checked on Windows and Solaris) so it looks like this bug in
GDB has been fixed. But function is not evaluated in any GDB and it's a bug that has to be fixed in GDB.
Comment 13 Jesse Grodnik 2007-10-11 22:08:40 UTC
While this is a gdb (version 6.6) defect, from a user perspective it is seen as a gdb-lite defect. We can consider
various workarounds, such as alerting the user that the watch for a function "is not available", or (better) we can work
with the gdb community to fix the defect. That said, I think we need to keep the defect open and to waive it for
NetBeans 6.0.
Comment 14 Alexander Pepin 2008-02-05 13:39:35 UTC
It's rather gdb than gdb-lite bug so I downgrade the priority to P3.
Comment 15 _ gordonp 2008-03-11 15:31:03 UTC
Fixed in gdb. gdb-lite handles gdb failures. Nothing else to do.
Comment 16 Alexander Pepin 2008-03-24 15:09:04 UTC
verified in build 20080321