bugGPSD - Bugs: bug #50602, ppsthread.c segfault on 32bit with...

 
 

bug #50602: ppsthread.c segfault on 32bit with -D 4 debugging

Submitter:  None
Submitted:  Tue 21 Mar 2017 02:52:09 PM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  Fixed
Privacy:  Public Assigned to:  None
Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 21 Mar 2017 07:26:59 PM UTC, comment #1: 

Sorry I meant %lld ;-)

Anonymous
Tue 21 Mar 2017 02:52:09 PM UTC, original submission:  

Hi,

I found and fixed a segfault on gpsd-3.16. It happens if the software is compiled for a 32 bit platform (an i.MX6 running buildroot), a PPS source is used, and logging is active.

How to reproduce:
- Compile and run gpsd-3.16 on a 32 bit platform
- Run with: -D 4 and attach a PPS source (ktimer is sufficient)
- Here: "gpsd -n -N -D4 /dev/ttymxc1 /dev/pps1"
- The gpsd will crash with a segfault in less than one second, but only for loglevels higher or equal than 4.

Reason:
- In file ppsthread.c some local variables are of type "long long", esp "cycle" and "duration". Unfortunately, the format strings of the respective logging output specifies %d and %7d, which does not reflect a "long long" on a 32 bit ARM CPU. The correct format string is %lld. As the sizes are wrong here, the wrong amount of bytes are assumed on the stack and later string-based variables referred by the format strings are represented by wrong pointers resulting in a segmentation fault.

Fix:
- Change all %d and %7d to %ldd if "long long" variables are referred to.
- Check these lines: 776 (2x), 843 (2x), 901 (2x)

After fixing this, gpsd works well without segfaulting.

Regards,
Florian

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by esr (Updated the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2017-09-07 esr Open/ClosedOpen Closed
    2017-09-06 esr StatusNone Fixed

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code