* Cygwin debugger crashes every time on following a unique_ptr @ 2019-05-25 16:04 Raj Kumar 2019-05-25 21:31 ` Mark Geisert 0 siblings, 1 reply; 5+ messages in thread From: Raj Kumar @ 2019-05-25 16:04 UTC (permalink / raw) To: cygwin [-- 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 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Cygwin debugger crashes every time on following a unique_ptr 2019-05-25 16:04 Cygwin debugger crashes every time on following a unique_ptr Raj Kumar @ 2019-05-25 21:31 ` Mark Geisert 2019-05-26 7:52 ` Mark Geisert 2019-05-26 16:40 ` Jon Turney 0 siblings, 2 replies; 5+ messages in thread From: Mark Geisert @ 2019-05-25 21:31 UTC (permalink / raw) To: cygwin Raj Kumar wrote: [...] > 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. I can confirm this issue. The fault is reported by Cygwin's memcpy(). I'm having a heck of a time trying to get a gdb backtrace to show what in gdb itself is likely calling memcpy() with a bad arg. To reproduce with OP's supplied source files in an otherwise clean directory: g++ -g -o raj *.cpp gdb raj [...] (gdb) b main (gdb) run (gdb) n (gdb) n At this point you'll be on line 14. Issue the OP's triggering command: (gdb) p myCar.get()->currentPassengers Segmentation fault (core dumped) ..mark -- 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 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Cygwin debugger crashes every time on following a unique_ptr 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 1 sibling, 1 reply; 5+ messages in thread From: Mark Geisert @ 2019-05-26 7:52 UTC (permalink / raw) To: cygwin Mark Geisert wrote: > I can confirm this issue. The fault is reported by Cygwin's memcpy(). I'm > having a heck of a time trying to get a gdb backtrace to show what in gdb itself > is likely calling memcpy() with a bad arg. This seems to be a regression in gdb 8.1.1. If you downgrade to gdb 8.0.1 on Cygwin the fault does not occur. Obviously just a workaround. I'm curious which version of gdb the OP was using within CLion. In any case this issue should be pointed out upstream (to the gdb developers). It doesn't seem to be a Cygwin issue after all. ..mark -- 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 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Cygwin debugger crashes every time on following a unique_ptr 2019-05-26 7:52 ` Mark Geisert @ 2019-05-26 16:05 ` Brian Inglis 0 siblings, 0 replies; 5+ messages in thread From: Brian Inglis @ 2019-05-26 16:05 UTC (permalink / raw) To: cygwin On 2019-05-26 01:51, Mark Geisert wrote: > Mark Geisert wrote: >> I can confirm this issue. The fault is reported by Cygwin's memcpy(). I'm >> having a heck of a time trying to get a gdb backtrace to show what in gdb itself >> is likely calling memcpy() with a bad arg. > This seems to be a regression in gdb 8.1.1. If you downgrade to gdb 8.0.1 on > Cygwin the fault does not occur. Obviously just a workaround. > I'm curious which version of gdb the OP was using within CLion. In any case > this issue should be pointed out upstream (to the gdb developers). It doesn't > seem to be a Cygwin issue after all. You should follow JetBrains debugger problem reporting guidelines (as you should Cygwin's) if that is relevant to your use: https://intellij-support.jetbrains.com/hc/en-us/articles/206560589-Debugger-doesn-t-stop-on-a-breakpoint-Debugger-shows-Command-timed-out-What-to-do- You should push this back to JetBrains for proper reproduction and diagnosis (if Cygwin volunteers can do it in hours, JetBrains should have some employees capable to do so) and have them report it to their upstream, which may be https://sourceware.org/gdb/ also hosted on SourceWare like Cygwin. CLion 2019.1 may now support gdb 8.1: https://intellij-support.jetbrains.com/hc/en-us/articles/206556469-What-compiler-debugger-can-I-use-within-CLion- and fixes are available in upgrades: https://sourceware.org/gdb/news/ but below reports CLion 2018.1.6 uses gdb 8.0.1 - you should not use newer gdb capabilities than supported by the installed release: https://confluence.jetbrains.com/display/CLION/Third-Party+Software+Used+by+CLion and that info should be available for each release and up to date for the current release. -- Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada This email may be disturbing to some readers as it contains too much technical detail. Reader discretion is advised. -- 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 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Cygwin debugger crashes every time on following a unique_ptr 2019-05-25 21:31 ` Mark Geisert 2019-05-26 7:52 ` Mark Geisert @ 2019-05-26 16:40 ` Jon Turney 1 sibling, 0 replies; 5+ messages in thread From: Jon Turney @ 2019-05-26 16:40 UTC (permalink / raw) To: The Cygwin Mailing List, Raj Kumar On 25/05/2019 22:31, Mark Geisert wrote: > Raj Kumar wrote: > [...] >> 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. > > I can confirm this issue. The fault is reported by Cygwin's memcpy(). > I'm having a heck of a time trying to get a gdb backtrace to show what > in gdb itself is likely calling memcpy() with a bad arg. When debugging gdb with itself here, you'll need to use 'set cygwin-exceptions on' to allow it to stop on exceptions inside the cygwin DLL. See https://cygwin.com/faq.html#faq.programming.debugging-cygwin (This would be a lot more usable if gdb ignored exceptions inside the specific functions where it makes sense to do that (e.g. verifyable_object_isvalid, etc.), rather than anywhere in the cygwin DLL, if someone wants to fix that...) > To reproduce with OP's supplied source files in an otherwise clean > directory: > g++ -g -o raj *.cpp > gdb raj > [...] > (gdb) b main > (gdb) run > (gdb) n > (gdb) n > > At this point you'll be on line 14. Issue the OP's triggering command: > (gdb) p myCar.get()->currentPassengers > Segmentation fault (core dumped) Thanks for the reproduction instructions. This seems to be the issue discussed in [1], fixed by [2]. This fix is contained in the 8.2.1-1 Cygwin test release of gdb. [1] https://sourceware.org/ml/gdb-patches/2018-06/msg00584.html [2] https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commitdiff;h=de52b9607d2623f18b7a7dbee3e1123d8d63f5da -- 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 ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-05-26 16:40 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2019-05-25 16:04 Cygwin debugger crashes every time on following a unique_ptr Raj Kumar 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
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).