Bug 14373 - std::vector
Summary: std::vector
Status: RESOLVED NOTABUG
Alias: None
Product: gdb
Classification: Unclassified
Component: python (show other bugs)
Version: 7.4
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-07-19 11:32 UTC by andreasheimberger
Modified: 2022-06-05 15:04 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
vector gdb frozen (33.81 KB, image/png)
2012-07-19 11:32 UTC, andreasheimberger
Details

Note You need to log in before you can comment on or make changes to this bug.
Description andreasheimberger 2012-07-19 11:32:52 UTC
Created attachment 6537 [details]
vector gdb frozen

Having an unitialized std::vector gdb freezes and doesn't respond anyway. Especially when you call -var-list-children in the line where std::vector is still uninitialized.

Example: 
Code                              GDB
------------------------------------------------------------------------------
std::vector<int> vec;             <<  -var-create - * vec  
                                  <<  -var-list-children var1
vec.push_back(1);
-------------------------------------------------------------------------------

Within Eclipse CDT they must have some implementation that debugging is still available.
Comment 1 Tom Tromey 2012-07-20 19:45:24 UTC
First, I agree it would be good to be able to interrupt
gdb when it gets wedged like this.

However, the problem here is that the varobj has
many children -- in my test, 105312 of them (but obviously
YMMV).

Front ends are supposed to limit dynamic varobj output
using the provided controls, like -var-set-update-range
or the optional arguments to -var-list-children.
Otherwise, bad things will happen.

In this case, the vector is uninitialized, causing problems.
But the same problems can occur due to other bugs in the program
(trashing the heap), or just if the program happens to create
a really huge data structure -- not unheard-of.
Comment 2 andreasheimberger 2012-07-23 08:22:29 UTC
I agree to you that it is better to set an update range, also for the other cases you mentioned. However is there no possibility to check if the variable is unitialized, or do you know if a feature like that will be implemented in future? Eventually from gcc perspective.
Comment 3 Tom Tromey 2012-07-25 15:36:43 UTC
(In reply to comment #2)
> I agree to you that it is better to set an update range, also for the other
> cases you mentioned. However is there no possibility to check if the variable
> is unitialized, or do you know if a feature like that will be implemented in
> future? Eventually from gcc perspective.

It may be possible to do this in gcc -- there was one attempt already, see
DW_OP_GNU_uninit -- but I think it is not a good approach, for the reasons
already outlined.
Comment 4 Tom Tromey 2022-06-05 15:04:50 UTC
I'm going to mark this one as not a bug.
There isn't much gdb can or should do about uninitialized memory.
Front ends can limit the number of varobj children, and should
do so for exactly this reason.