openpilot icon indicating copy to clipboard operation
openpilot copied to clipboard

Reapply "Switch from json11 to nlohmann/json (#31093)"

Open adeebshihadeh opened this issue 1 year ago • 5 comments

adeebshihadeh avatar Jan 23 '24 06:01 adeebshihadeh

Hey, I saw you reverted the commit, is there anything wrong with it? May I help?

mtribiere avatar Jan 24 '24 17:01 mtribiere

Hey, I saw you reverted the commit, is there anything wrong with it? May I help?

there is something wrong with the thneed part, it crashes on device. If you have a device you can probably test it there. If not I'm planning to look into it today.

modeld crashes with: pytest selfdrive/test/test_onroad.py -s

jnewb1 avatar Jan 24 '24 18:01 jnewb1

I sadly do not possess hardware, that's why I chose this bounty PR initially. If there is something else I can help, without hardware let me know.

mtribiere avatar Jan 24 '24 19:01 mtribiere

I sadly do not possess hardware, that's why I chose this bounty PR initially. If there is something else I can help, without hardware let me know.

@mtribiere you can repro this by running this in selfdrive/modeld/: scons -u -j8 --pc-thneed && USE_THNEED=1 ./modeld

batman:modeld$ scons -u -j8 --pc-thneed && USE_THNEED=1 ./modeld
scons: Entering directory `/home/batman/fivepilot'
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
scons: `selfdrive/modeld' is up to date.
scons: done building targets.
Thneed::clinit done
Thneed::load: loading from /home/batman/fivepilot/selfdrive/modeld/models/supercombo.thneed
terminate called after throwing an instance of 'nlohmann::json_abi_v3_11_3::detail::parse_error'
  what():  [json.exception.parse_error.101] parse error at line 1, column 19981: syntax error while parsing value - invalid string: ill-formed UTF-8 byte; last read: '"'
Aborted (core dumped)

adeebshihadeh avatar Jan 27 '24 18:01 adeebshihadeh

Seems like this library only support UTF-8 encoded string, that's probably why the parse function fails.

Only UTF-8 encoded input is supported which is the default encoding for JSON according to RFC 8259.

mtribiere avatar Jan 28 '24 16:01 mtribiere

Seems like this library only support UTF-8 encoded string, that's probably why the parse function fails.

Only UTF-8 encoded input is supported which is the default encoding for JSON according to RFC 8259.

I see. Any way around it? Or we'll have to go with another library?

adeebshihadeh avatar Jan 30 '24 04:01 adeebshihadeh

A way around it, probably not as it's how the library is built. The only solution I see right now is to modify how this JSON is produced in the first place. Is that a viable option for you? Might require some additional work though

mtribiere avatar Jan 30 '24 10:01 mtribiere

Yes, that should be fine.

adeebshihadeh avatar Jan 31 '24 19:01 adeebshihadeh