iOS Question Crash when running app in debugger

martin24

Member
Licensed User
I have a situation which fails in the debugger but runs fine in release mode.
Using B4i 4.40 with hosted builder

Here's a small code example, I hope you can reproduce:

B4X:
Sub Process_Globals
    Public App As Application
    Public NavControl As NavigationController
    Private Page1 As Page
   
    Type ttt (sss As String)
    Dim vvv As ttt = Null
End Sub

Private Sub Application_Start (Nav As NavigationController)
    NavControl = Nav
    Page1.Initialize("Page1")
    Page1.Title = "Page 1"
    Page1.RootPanel.Color = Colors.White
    NavControl.ShowPage(Page1)
   
    If vvv <> Null Then
        Log(vvv)
        Log(vvv.sss)
    Else
        Msgbox("vvv = Null", "Test")
    End If
End Sub

In Release mode, I get the message box "vvv = Null", in debug mode I get the following crash (100% reproducible):


B4X:
Application_Start
<null>
Error occurred on line: 33 (Main)
-[NSNull sss]: unrecognized selector sent to instance 0x1b42c3650
Stack Trace: (
  CoreFoundation       <redacted> + 148
  libobjc.A.dylib      objc_exception_throw + 56
  CoreFoundation       <redacted> + 0
  CoreFoundation       <redacted> + 1380
  CoreFoundation       _CF_forwarding_prep_0 + 92
  CrashTest            -[b4i_main _application_start:] + 2224
  CoreFoundation       <redacted> + 144
  CoreFoundation       <redacted> + 292
  CrashTest            +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1624
  CrashTest            -[B4IShell runMethod:] + 448
 CrashTest            -[B4IShell raiseEventImpl:method:args::] + 1784
 CrashTest            -[B4IShellBI raiseEvent:event:params:] + 1408
 CrashTest            __33-[B4I raiseUIEvent:event:params:]_block_invoke + 60
 libdispatch.dylib    <redacted> + 24
 libdispatch.dylib    <redacted> + 16
 libdispatch.dylib    <redacted> + 1016
 CoreFoundation       <redacted> + 12
 CoreFoundation       <redacted> + 2012
 CoreFoundation       CFRunLoopRunSpecific + 436
 GraphicsServices     GSEventRunModal + 100
 UIKit                UIApplicationMain + 208
 CrashTest            main + 124
 libdyld.dylib        <redacted> + 4
)
Application_Active
 

martin24

Member
Licensed User
This was just a small example how to reproduce that debugger crash.

In a big app it also happens if I have to reset the global variable to Null. After that I cannot compare that variable to Null without running into that debugger crash.

Unfortunately I'm not able to reproduce this with a small example, but I have found a simple work around that I can use to avoid that crash.
 
Upvote 0
Top