sdl_java_suite icon indicating copy to clipboard operation
sdl_java_suite copied to clipboard

Race condition causing NPE in SdlSession

Open jthrun opened this issue 7 years ago • 0 comments

Bug Report

I have seen a case where code in SdlSession checks for a null SdlConnection object and if not null then sends a message but still results in NullPointerException. This seems like a race condition between the session sending a packet and the session being closed because the line right before the exception is a null check on the variable being used. In my case, video was streaming when the session was being closed.

NPE location

04-13 16:05:46.490 32228   716 E AndroidRuntime: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.smartdevicelink.SdlConnection.SdlConnection.sendMessage(com.smartdevicelink.protocol.ProtocolMessage)' on a null object reference
04-13 16:05:46.490 32228   716 E AndroidRuntime:        at com.smartdevicelink.SdlConnection.SdlSession.sendMessage(SdlSession.java:496)
04-13 16:05:46.490 32228   716 E AndroidRuntime:        at com.smartdevicelink.SdlConnection.SdlSession.sendStreamPacket(SdlSession.java:388)
04-13 16:05:46.490 32228   716 E AndroidRuntime:        at com.smartdevicelink.streaming.video.RTPH264Packetizer.run(RTPH264Packetizer.java:244)
04-13 16:05:46.490 32228   716 E AndroidRuntime:        at java.lang.Thread.run(Thread.java:818)
Reproduction Steps

Random

  • Cause SdlSession to close while it is on the verge of sending and RPC message
  • Timing is important
  • Terminate SDLCore/HMI at the correct time or block the BT (or other) connections between HU and HS
Expected Behavior

SdlProxyService should not crash

Observed Behavior

SdlProxyService crashes with NPE

OS & Version Information
  • Android Version: 5.0.1
  • SDL Android Version: 4.5 (develop branch)
  • Testing Against: in-house HU emulator with internal SDLCore build based on develop branch
Test Case, Sample Code, and / or Example App

jthrun avatar Apr 13 '18 23:04 jthrun