New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crash (SIGSEGV) with Gps -> Start when TCP gpsd is set but not running #166

Open
pabs3 opened this Issue Oct 28, 2018 · 9 comments

Comments

Projects
None yet
2 participants
@pabs3

pabs3 commented Oct 28, 2018

When I run do not have gpsd running and I run Merkaartor and press Gps -> Start, I get a crash (SIGSEGV). The gpsd option is selected in the Preferences. I think instead of crashing it should create an error dialog.

QObject::connect: No such signal QGPSDDevice::updatePosition(float, float, QDateTime, float, float, float)
QObject::connect:  (receiver name: 'MainWindow')
[New Thread 0x7fffce1e2700 (LWP 4836)]
gpsmm::stream() failed:  can't connect to host/port pair 


Thread 17 "QGPSDDevice" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffce1e2700 (LWP 4836)]
gps_sock_read (gpsdata=gpsdata@entry=0x5555568cc040) at libgps_sock.c:189
189	libgps_sock.c: No such file or directory.
#0  0x00007ffff7717bb9 in gps_sock_read (gpsdata=gpsdata@entry=0x5555568cc040) at libgps_sock.c:189
#1  0x00007ffff7714aaa in gps_read (gpsdata=gpsdata@entry=0x5555568cc040) at libgps_core.c:164
#2  0x00007ffff771bcd5 in gpsmm::read() (this=0x5555568cc030) at libgpsmm.cpp:50
#3  0x000055555578b897 in QGPSDDevice::onDataAvailable() (this=0x555556473920) at GPS/qgpsdevice.cpp:1006
#4  0x000055555578ecb0 in QGPSDDevice::run() (this=0x555556473920) at GPS/qgpsdevice.cpp:992
#5  0x00007ffff1f77c97 in QThreadPrivate::start(void*) (arg=0x555556473920) at thread/qthread_unix.cpp:367
#6  0x00007ffff1e05f2a in start_thread (arg=0x7fffce1e2700) at pthread_create.c:463
#7  0x00007ffff1a07edf in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
@Krakonos

This comment has been minimized.

Member

Krakonos commented Oct 28, 2018

Hi!

Thanks for reporting, but unfortunately I can't reproduce the problem. It might be related to the library used, as the stacktrace points into the libgps. However, it might as well be a wrong pointer passed into that library.

What's interesting is that there is onDataAvailable called. This looks like Merkaartor was able to connect to something listening on that port, but failed to parse the responses it's sending. Can you take a look into preferences to check the port you're connecting to (Tools -> Preferences -> GPS; Default is localhost:2947) and if there is any service running on that port? If there is, can you provide me with more details about the service and perhaps a log of the communication so I can see what data cause the crash? But please be careful with the logging, if you capture network data, it may contain other communication with possibly private data. Definitely read up on that and make sure you don't disclose more than you'd like.

@pabs3

This comment has been minimized.

pabs3 commented Oct 28, 2018

@pabs3

This comment has been minimized.

pabs3 commented Oct 28, 2018

@Krakonos

This comment has been minimized.

Member

Krakonos commented Nov 2, 2018

Maybe. What version of gpsd do you have installed (on what distribution?). I see there have been some API changes to the gpsd, so it might be a problem there.

@pabs3

This comment has been minimized.

pabs3 commented Nov 2, 2018

@Krakonos

This comment has been minimized.

Member

Krakonos commented Nov 2, 2018

So I was digging in the GPS code and managed to reproduce the problem. The problem is somewhere in qgpsdevice.cpp, around lines 981. The libgps documentation ( http://www.catb.org/gpsd/libgpsmm.html ) states we should call open() after the constructor. However, newer versions of the library do not have an "open" method and they seem to call gps_inner_open in constructor. Calling read() the segfaults, instead of returning an error.

I currently can't access the source code, as savannah seem to be down. I will try later to see what's going on and if there is a way to get some error codes out. However, the c++ interface is pretty much undocumented.

However, I'm considering not fixing these bugs and deprecating all the current gps backends (there are some other, based on custom NMEA parser etc.) and replacing them with QtPositioning module. Thoughts?

Krakonos added a commit that referenced this issue Nov 2, 2018

Workaround for situations when GPSD is not available.
Fixes two problems:
- Crash when gpsd is not running at all (issue #166)
- 100% CPU usage when the gpsd is terminated unexpectedly (or not
available at all).
@Krakonos

This comment has been minimized.

Member

Krakonos commented Nov 2, 2018

I have created a simple workaround in PR #167. Can you test it out?

@pabs3

This comment has been minimized.

pabs3 commented Nov 2, 2018

@pabs3

This comment has been minimized.

pabs3 commented Nov 2, 2018

This was referenced Nov 10, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment