gpsd-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [gpsd-dev] Tricky bug in the json parser


From: Christian Gagneraud
Subject: Re: [gpsd-dev] Tricky bug in the json parser
Date: Mon, 04 Jun 2012 10:13:06 +0100
User-agent: Mozilla/5.0 (X11; Linux i686; rv:12.0) Gecko/20120421 Thunderbird/12.0

On 04/06/12 07:11, Christian Gagneraud wrote:
Hi all,

I just have one last bug to fix from my live test campaign. and it is a
bit tricky to understand for me as I have to dive into the hairy json.c.

I found the problem, it was in jsongen.py.in, the json parser was doing exactly what it was told, it was just told wrong!
Will push soon.

Chris


So basically, here are 2 AIS sentences which contain an array of 1 struct:
!AIVDM,1,1,,A,address@hidden,0*02
!AIVDM,1,1,,A,6h2E3N0rThqP0600J00000000000,0*51

The dumping doesn't seems to cause any trouble, but reading back the
JSON crashes gpsdecode:
echo '!AIVDM,1,1,,A,address@hidden,0*02' | gpsdecode -ju
{"class":"AIS","device":"stdin","type":6,"repeat":3,"mmsi":2442101,"scaled":false,"seqno":2,"dest_mmsi":246351000,"retransmit":false,"dac":1,"fid":32,"month":0,"day":0,"tidals":[{"lon":-16777216,"lat":0,"from_hour":0,"from_min":0,"to_hour":0,"to_min":0,"cdir":0,"cspeed":0}]}

echo '!AIVDM,1,1,,A,address@hidden,0*02' | gpsdecode -ju |
gpsdecode -jeu
Segmentation fault

I saw some other messages with arrays of 0 structures, they don't crash
the json parser.

I have activated the debug messages in json.c, but it didn't help me
that much (it seems that the parser doesn't "see" the end of struct or
end of array).
Maybe someone familiar with the json parser code could help me to fix
this nasty bug.

Chris

PS: I'm running an AIS test campaign on live data from aishub.net.
Input data is ca. 25 millions sentences (1.2GB of logs), and goes
through these steps:
- AIVDM decoding
- JSON scaled dump
- JSON validity check
- JSON unscaled dump
- JSON validity check
- JSON idempotency check

I fixed a dozen of bugs so far, this one seems to be the last one!



--
Christian Gagneraud,
Embedded systems engineer.
Techworks Marine
1 Harbour road
Dun Laoghaire
Co. Dublin
Ireland
Tel: + 353 (0) 1 236 5990
Web: http://www.techworks.ie/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]