public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Raj Kumar <gaurav@iastate.edu>
To: cygwin@cygwin.com
Subject: Cygwin debugger crashes every time on following a unique_ptr
Date: Sat, 25 May 2019 16:04:00 -0000	[thread overview]
Message-ID: <CAECqvgfWPBo0VmYk=EG14vQkK-L7f4zGZ==pv-jSMt31vhavZw@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1021 bytes --]

Hi,

I use CLion for code development. I initially posted this bug there
but they said that it is an issue with the Cygwin GDB, and hence I am
sending this mail.

I am using cygwin64 version 3.0.7 with Cygwin debugger version 8.1.1

Sample code to reproduce the code has been attached. In the Clion
environment, this is what is happening:

A dummy example code has been attached. In the example, on line 17 in
main.cpp, you can see that in the Variables tab, the currentPassengers
vector<>() is populated correctly. But when I right click on
currentPassengers and select "Add to Watches", the entire debugger
crashes. The same thing happens when I hover over the variable names
in the code to get the values.


Adding a watch is equivalent to when in the gdb window I try and do
this: myCar.get()->currentPassengers. This crashes the GDB every time.
So the issue occurs when I try to follow the object pointed to by a
unique_ptr and try to get its attributes/variables.


Gaurav
515-357-3480
MS-CS, Iowa State University

[-- Attachment #2: main.cpp --]
[-- Type: application/octet-stream, Size: 440 bytes --]

#include <iostream>
#include <vector>
#include <memory>
#include "Vehicle.h"

using namespace std;

int main() {

    unique_ptr<Vehicle> myCar = make_unique<Vehicle>();
    myCar->setPassengerCapacity(4);

    myCar->addPassenger("Alice");
    myCar->addPassenger("Bob");
    myCar->addPassenger("Charlie");

    for(int i = 0; i < myCar->currentPassengers.size(); i++){
        cout << myCar->currentPassengers[i];
    }


    return 0;
}

[-- Attachment #3: Vehicle.h --]
[-- Type: application/octet-stream, Size: 518 bytes --]

//
// Created by rajga on 5/24/2019.
//

#ifndef TESTBED_VEHICLE_H
#define TESTBED_VEHICLE_H

#include <iostream>
#include <string>
#include <string.h>
#include <vector>

using namespace std;


class Vehicle {

private:
    int noOfWheels;
    int passengerCapacity;

public:

    vector<string> currentPassengers;
    void getPassengerCapacity();
    void setPassengerCapacity(int k);
    void getCurrentPassengers();
    void addPassenger(string s);

};


#endif //TESTBED_VEHICLE_H

[-- Attachment #4: Vehicle.cpp --]
[-- Type: application/octet-stream, Size: 884 bytes --]

//
// Created by rajga on 5/24/2019.
//

#include "Vehicle.h"
#include <iostream>

using namespace std;

void Vehicle::getPassengerCapacity(){
    cout << "The passenger capacity is: " << this->passengerCapacity << endl;
}

void Vehicle::setPassengerCapacity(int k){

    this->passengerCapacity = k;
    cout << "The passenger capacity is changed to: " << this->passengerCapacity << endl;
}

void Vehicle::getCurrentPassengers(){

    cout << "Current passengers are: " << endl;
    for(int i = 0; i < this->currentPassengers.size(); i++){
        cout << this->currentPassengers[i] << endl;
    }
}

void Vehicle::addPassenger(string s){

    if(this->currentPassengers.size() < this->passengerCapacity){
        this->currentPassengers.push_back(s);
        getCurrentPassengers();
    }else{
        cout << "Vehicle full!!" << endl;
    }


}

[-- Attachment #5: Type: text/plain, Size: 219 bytes --]


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

             reply	other threads:[~2019-05-25 16:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-25 16:04 Raj Kumar [this message]
2019-05-25 21:31 ` Mark Geisert
2019-05-26  7:52   ` Mark Geisert
2019-05-26 16:05     ` Brian Inglis
2019-05-26 16:40   ` Jon Turney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAECqvgfWPBo0VmYk=EG14vQkK-L7f4zGZ==pv-jSMt31vhavZw@mail.gmail.com' \
    --to=gaurav@iastate.edu \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).