locked
NULL_CLASS_PTR_READ exception in bluetooth RFCOMM

    Question

  • Hi,

    I am trying to hunt down a crash reported via the dev center. its an access violation (0xc0000005) exception, under the name of NULL_CLASS_PTR_READ, which I have no idea what is that?!

    From the call stack, it appears happen on/before/after a RFCOMM service request? I am following Microsoft's sample code on Bluetooth RFCOMM, the exact code segment of the app:

    ----------

    if (DeviceInfo == nullptr || DeviceInfo->Id == nullptr)
    		return;		
    
    	
    create_task(RfcommDeviceService::FromIdAsync(DeviceInfo->Id)).then([this](RfcommDeviceService^ service)
    {				
        if (service == nullptr )		
        {			
            ConnectionStatusStr = "Unable to connect to the selected device, permission not granted";
            OnDeviceConnected(this); //raise an event
            return task<void>();		
        }
    
    ...

    ---------- CALL STACK------------

     OBDdashFree.Windows.exe!Concurrency::details::_TaskCollectionImpl::_GetScheduler(void) Unknown
      OBDdashFree.Windows.exe!Concurrency::details::_Task_impl_base::_GetScheduler(void) Unknown
      OBDdashFree.Windows.exe!Concurrency::task<void>::_Then<class <lambda_921797497e99df0233000859014c01f4> >(class <lambda_921797497e99df0233000859014c01f4> const &,class Concurrency::details::_CancellationTokenState *,enum Concurrency::details::_TaskInliningMode) Unknown
    > OBDdashFree.Windows.exe!Concurrency::details::_Task_impl_base::_AsyncInit<unsigned char,void>(class std::shared_ptr<struct Concurrency::details::_Task_impl<unsigned char> > const &,class Concurrency::task<void> const &) Unknown
      OBDdashFree.Windows.exe!Concurrency::task<class Windows::Devices::Bluetooth::Rfcomm::RfcommDeviceService ^>::_ContinuationTaskHandle<class Windows::Devices::Bluetooth::Rfcomm::RfcommDeviceService ^,void,class <lambda_359d113d81929ab8c4f38a663a9d7fa6>,struct std::integral_constant<bool,0>,struct Concurrency::details::_TypeSelectorAsyncTask>::_Continue(struct std::integral_constant<bool,0>,struct Concurrency::details::_TypeSelectorAsyncOperationOrTask) Unknown
      OBDdashFree.Windows.exe!Concurrency::details::_PPLTaskHandle<unsigned char,struct Concurrency::task<class Windows::Devices::Bluetooth::Rfcomm::RfcommDeviceService ^>::_ContinuationTaskHandle<class Windows::Devices::Bluetooth::Rfcomm::RfcommDeviceService ^,void,class <lambda_359d113d81929ab8c4f38a663a9d7fa6>,struct std::integral_constant<bool,0>,struct Concurrency::details::_TypeSelectorAsyncTask>,struct Concurrency::details::_ContinuationTaskHandleBase>::invoke(void) Unknown
      msvcr120_app.dll!Concurrency::details::_TaskCollection::_RunAndWait(class Concurrency::details::_UnrealizedChore *) Unknown
      OBDdashFree.Windows.exe!Concurrency::details::_AsyncTaskCollection::_ScheduleWithAutoInline(class Concurrency::details::_UnrealizedChore *,enum Concurrency::details::_TaskInliningMode) Unknown
      OBDdashFree.Windows.exe!Concurrency::details::_TaskCollectionImpl::_ScheduleTask(struct Concurrency::details::_TaskProcHandle *,enum Concurrency::details::_TaskInliningMode) Unknown
      OBDdashFree.Windows.exe!Concurrency::details::_Task_impl_base::_ScheduleTask(struct Concurrency::details::_TaskProcHandle *,enum Concurrency::details::_TaskInliningMode) Unknown
      OBDdashFree.Windows.exe!Concurrency::details::_ContextCallback::_Bridge(struct tagComCallData *) Unknown
      combase.dll!CRemoteUnknown::DoCallback(tagXAptCallback * pCallbackData) Line 1661 C++
      rpcrt4.dll!Invoke() Unknown
      rpcrt4.dll!Ndr64StubWorker(void *,void *,struct _RPC_MESSAGE *,struct _MIDL_SERVER_INFO_ *,long (*const *)(void),struct _MIDL_SYNTAX_INFO *,unsigned long *) Unknown
      rpcrt4.dll!NdrStubCall3() Unknown
      combase.dll!CStdStubBuffer_Invoke(IRpcStubBuffer * This, tagRPCOLEMESSAGE * prpcmsg, IRpcChannelBuffer * pRpcChannelBuffer) Line 1586 C++
      combase.dll!SyncStubInvoke(tagRPCOLEMESSAGE * pMsg, const _GUID & riid, CIDObject * pID, void * pVtableAddress, IRpcChannelBuffer * pChnl, IRpcStubBuffer * pStub, void * pInterface, unsigned long * pdwFault) Line 1664 C++
      combase.dll!CCtxComChnl::ContextInvoke(tagRPCOLEMESSAGE * pMessage, IRpcStubBuffer * pStub, tagIPIDEntry * pIPIDEntry, unsigned long * pdwFault) Line 1377 C++
      combase.dll!DefaultInvokeInApartment(tagRPCOLEMESSAGE * pMsg, unsigned long bIsTouchedASTACall, bool pStub, IRpcStubBuffer * pChnl, IInternalChannelBuffer * pIPIDEntry, tagIPIDEntry * pdwFault, unsigned long *) Line 2718 C++
      combase.dll!AppInvoke(CMessageCall * pCall, CRpcChannelBuffer * pChannel, IRpcStubBuffer * pStub, void * pv, void * pStubBuffer, tagIPIDEntry * pIPIDEntry, WireLocalThis * pLocalb) C++
      combase.dll!ComInvokeWithLockAndIPID(CMessageCall * pCall, tagIPIDEntry * pIPIDEntry) Line 2314 C++
      combase.dll!ComInvoke(CMessageCall * pCall) Line 2030 C++
      combase.dll!ThreadDispatch(CMessageCall * pCall) Line 364 C++
      combase.dll!CComApartment::ASTAHandleMessage(IMessageParam * pParam) Line 2416 C++
      combase.dll!ASTAWaitContext::Wait(unsigned int cHandlesOuter, void * const * pHandlesOuter, unsigned long dwTimeoutOuter, ASTAWaitContext::ProcessEventsMsgWaitParams * pProcessEventsMsgWaitParams, unsigned long * pdwLastError) Line 988 C++
      combase.dll!CoMsgWaitInProcessEvents(CO_PROCESS_EVENTS_CONTEXT * pContext, unsigned long nCount, void * const * pHandles, unsigned long dwMilliseconds, unsigned long dwWakeMask, unsigned long dwFlags) Line 1935 C++
      Windows.UI.dll!Windows::UI::Core::CDispatcher::WaitAndProcessMessages(void *) Unknown
      Windows.UI.dll!Windows::UI::Core::CDispatcher::ProcessEvents(enum Windows::UI::Core::CoreProcessEventsOption) Unknown
      Windows.UI.Xaml.dll!CJupiterWindow::RunCoreWindowMessageLoop() Line 775 C++
      Windows.UI.Xaml.dll!DirectUI::DXamlCore::RunMessageLoop() Line 2798 C++
      twinapi.appcore.dll!Windows::ApplicationModel::Core::CoreApplicationView::Run(void) Unknown
      twinapi.appcore.dll!Microsoft::WRL::Details::RuntimeClass<struct Microsoft::WRL::Details::InterfaceList<struct Windows::Foundation::IEventHandler<struct IInspectable *>,struct Microsoft::WRL::Details::InterfaceList<class Microsoft::WRL::FtmBase,class Microsoft::WRL::Details::Nil> >,struct Microsoft::WRL::RuntimeClassFlags<2>,1,0,0>::QueryInterface(struct _GUID const &,void * *) Unknown
      SHCore.dll!SHWaitForThreadWithWakeMask() Unknown
      kernel32.dll!BaseThreadInitThunk() Unknown
      ntdll.dll!RtlUserThreadStart() Unknown

    Monday, February 9, 2015 12:32 PM

Answers

  • right, I think I might have solved this one.

    The problem only happen if the user refuse to grant the permission to the Bluetooth device, and when the app executed the above code, it throws and access violation exception at the point of "return task<void>();" (the above code is pretty much copied from the MS sample code). For some unknown reason, this access violation exception fell through all exception catchers later in the task chain (again, copied from the MS sample code).

    Change it to cancel_current_task() then catch the 'task_canceled&' later in the chain appears solved the problem



    • Edited by Fred Liang Thursday, February 12, 2015 1:19 PM
    • Marked as answer by Fred Liang Monday, February 16, 2015 3:38 AM
    Thursday, February 12, 2015 1:15 PM

All replies

  • Hi,

    Do you specify bluetooth capability?

    You must provide information about your device's capabilities in the declarations in the App Manifest. This allows an app to be associated with your device.

    For more information, see How to specify device capabilities for Bluetooth.

    Best Wishes!


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. <br/> Click <a href="http://support.microsoft.com/common/survey.aspx?showpage=1&scid=sw%3Ben%3B3559&theme=tech"> HERE</a> to participate the survey.

    Tuesday, February 10, 2015 10:00 AM
  • The Bluetooth is declared. The app is by and large worked despite these reported exceptions.

    <Capabilities>
        <DeviceCapability Name="location" />
        <m2:DeviceCapability Name="bluetooth.rfcomm">
          <m2:Device Id="any">
            <m2:Function Type="name:serialPort" />
          </m2:Device>
        </m2:DeviceCapability>
      </Capabilities>

    And this issue only seems to affect x64 machines. Are there any difference in Bluetooth rfcomm between x86 and x64 in terms of handling user rejects permission requests??

    • Edited by Fred Liang Wednesday, February 11, 2015 1:08 AM
    Tuesday, February 10, 2015 11:09 AM
  • right, I think I might have solved this one.

    The problem only happen if the user refuse to grant the permission to the Bluetooth device, and when the app executed the above code, it throws and access violation exception at the point of "return task<void>();" (the above code is pretty much copied from the MS sample code). For some unknown reason, this access violation exception fell through all exception catchers later in the task chain (again, copied from the MS sample code).

    Change it to cancel_current_task() then catch the 'task_canceled&' later in the chain appears solved the problem



    • Edited by Fred Liang Thursday, February 12, 2015 1:19 PM
    • Marked as answer by Fred Liang Monday, February 16, 2015 3:38 AM
    Thursday, February 12, 2015 1:15 PM