Thread issues happened whenever I tried to touch specific functions on my phone - swift

My app does not crash on iOS 8.
But after updating it to 10 version on my phone, my app crashes when I try to use specific functions in the app.
But on simulator, it works well.
Whenever I installed the app on my phone, Thread # issues happened. And the number on # part always changes like below and I don't know why.
libsystem_kernel.dylib`__abort_with_payload:
0x1c5eb440 <+0>: mov r12, sp
0x1c5eb444 <+4>: push {r4, r5, r6, r8}
0x1c5eb448 <+8>: ldm r12, {r4, r5, r6}
0x1c5eb44c <+12>: mov r12, #512
0x1c5eb450 <+16>: orr r12, r12, #9
0x1c5eb454 <+20>: svc #0x80
-> 0x1c5eb458 <+24>: pop {r4, r5, r6, r8}
0x1c5eb45c <+28>: blo 0x1c5eb474 ; <+52>
0x1c5eb460 <+32>: ldr r12, [pc, #0x4] ; <+44>
0x1c5eb464 <+36>: ldr r12, [pc, r12]
0x1c5eb468 <+40>: b 0x1c5eb470 ; <+48>
0x1c5eb46c <+44>: bne 0x1cea6364 ; CFStringROMTableHashData + 14212
0x1c5eb470 <+48>: bx r12
0x1c5eb474 <+52>: bx lr
what does the below error mean?
0x1c5eb458 <+24>: pop {r4, 45, r6, r8} = Thread #: signal SIGABRT
And some comments mentioned that I can solve this issues if I deleted "search path" on info.plist. So I tried to delete "Search Path" on info following them but it didn't work at all.

This issue is solved.
The reason is microphone provisioning on info.plist.
Therefore, I added "privacy-microphone" menu on it.
And it's solved.

Related

How can I find the node6

I found that I needed to input 6 integers, and that the integers consist of 1 to 6.
And I found the node1 ~ node5. But, this phase needs 6 nodes.
So I looked for more, but instead of node 6, I found'host_table'.
(gdb) x/3x 0x555555559230
0x555555559230 <node1>: 0x00000303 0x00000001 0x55559240
(gdb) x/3x 0x555555559240
0x555555559240 <node2>: 0x000001dc 0x00000002 0x55559250
(gdb) x/3x 0x555555559250
0x555555559250 <node3>: 0x00000332 0x00000003 0x55559260
(gdb) x/3x 0x555555559260
0x555555559260 <node4>: 0x000003c6 0x00000004 0x55559270
(gdb) x/3x 0x555555559270
0x555555559270 <node5>: 0x000002d9 0x00000005 0x55559110
(gdb) x/3x 0x555555559280
0x555555559280 <host_table>: 0x5555745f 0x00005555 0x55557468
What is the 'host_table'? I thought 'host_table' was node6. But it wasn't.
This is the code of this phase.
0x00005555555558ab <+0>: endbr64
0x00005555555558af <+4>: push %r14
0x00005555555558b1 <+6>: push %r13
0x00005555555558b3 <+8>: push %r12
0x00005555555558b5 <+10>: push %rbp
0x00005555555558b6 <+11>: push %rbx
0x00005555555558b7 <+12>: sub $0x60,%rsp
0x00005555555558bb <+16>: mov %fs:0x28,%rax
0x00005555555558c4 <+25>: mov %rax,0x58(%rsp)
0x00005555555558c9 <+30>: xor %eax,%eax
0x00005555555558cb <+32>: mov %rsp,%r13
0x00005555555558ce <+35>: mov %r13,%rsi
0x00005555555558d1 <+38>: callq 0x555555555e53 <read_six_numbers>
0x00005555555558d6 <+43>: mov $0x1,%r14d
0x00005555555558dc <+49>: mov %rsp,%r12
0x00005555555558df <+52>: jmp 0x555555555909 <phase_6+94>
0x00005555555558e1 <+54>: callq 0x555555555e11 <explode_bomb>
0x00005555555558e6 <+59>: jmp 0x555555555918 <phase_6+109>
0x00005555555558e8 <+61>: add $0x1,%rbx
0x00005555555558ec <+65>: cmp $0x5,%ebx
0x00005555555558ef <+68>: jg 0x555555555901 <phase_6+86>
0x00005555555558f1 <+70>: mov (%r12,%rbx,4),%eax
0x00005555555558f5 <+74>: cmp %eax,0x0(%rbp)
0x00005555555558f8 <+77>: jne 0x5555555558e8 <phase_6+61>
0x00005555555558fa <+79>: callq 0x555555555e11 <explode_bomb>
0x00005555555558ff <+84>: jmp 0x5555555558e8 <phase_6+61>
0x0000555555555901 <+86>: add $0x1,%r14
0x0000555555555905 <+90>: add $0x4,%r13
0x0000555555555909 <+94>: mov %r13,%rbp
0x000055555555590c <+97>: mov 0x0(%r13),%eax
0x0000555555555910 <+101>: sub $0x1,%eax
0x0000555555555913 <+104>: cmp $0x5,%eax
0x0000555555555916 <+107>: ja 0x5555555558e1 <phase_6+54>
0x0000555555555918 <+109>: cmp $0x5,%r14d
0x000055555555591c <+113>: jg 0x555555555923 <phase_6+120>
0x000055555555591e <+115>: mov %r14,%rbx
0x0000555555555921 <+118>: jmp 0x5555555558f1 <phase_6+70>
0x0000555555555923 <+120>: mov $0x0,%esi
0x0000555555555928 <+125>: mov (%rsp,%rsi,4),%ecx
0x000055555555592b <+128>: mov $0x1,%eax
0x0000555555555930 <+133>: lea 0x38f9(%rip),%rdx # 0x555555559230 <node1>
0x0000555555555937 <+140>: cmp $0x1,%ecx
0x000055555555593a <+143>: jle 0x555555555947 <phase_6+156>
0x000055555555593c <+145>: mov 0x8(%rdx),%rdx
0x0000555555555940 <+149>: add $0x1,%eax
0x0000555555555943 <+152>: cmp %ecx,%eax
0x0000555555555945 <+154>: jne 0x55555555593c <phase_6+145>
0x0000555555555947 <+156>: mov %rdx,0x20(%rsp,%rsi,8)
0x000055555555594c <+161>: add $0x1,%rsi
0x0000555555555950 <+165>: cmp $0x6,%rsi
0x0000555555555954 <+169>: jne 0x555555555928 <phase_6+125>
0x0000555555555956 <+171>: mov 0x20(%rsp),%rbx
0x000055555555595b <+176>: mov 0x28(%rsp),%rax
0x0000555555555960 <+181>: mov %rax,0x8(%rbx)
0x0000555555555964 <+185>: mov 0x30(%rsp),%rdx
0x0000555555555969 <+190>: mov %rdx,0x8(%rax)
0x000055555555596d <+194>: mov 0x38(%rsp),%rax
0x0000555555555972 <+199>: mov %rax,0x8(%rdx)
0x0000555555555976 <+203>: mov 0x40(%rsp),%rdx
0x000055555555597b <+208>: mov %rdx,0x8(%rax)
0x000055555555597f <+212>: mov 0x48(%rsp),%rax
0x0000555555555984 <+217>: mov %rax,0x8(%rdx)
0x0000555555555988 <+221>: movq $0x0,0x8(%rax)
0x0000555555555990 <+229>: mov $0x5,%ebp
0x0000555555555995 <+234>: jmp 0x5555555559a0 <phase_6+245>
0x0000555555555997 <+236>: mov 0x8(%rbx),%rbx
0x000055555555599b <+240>: sub $0x1,%ebp
0x000055555555599e <+243>: je 0x5555555559b1 <phase_6+262>
0x00005555555559a0 <+245>: mov 0x8(%rbx),%rax
0x00005555555559a4 <+249>: mov (%rax),%eax
0x00005555555559a6 <+251>: cmp %eax,(%rbx)
0x00005555555559a8 <+253>: jle 0x555555555997 <phase_6+236>
0x00005555555559aa <+255>: callq 0x555555555e11 <explode_bomb>
0x00005555555559af <+260>: jmp 0x555555555997 <phase_6+236>
0x00005555555559b1 <+262>: mov 0x58(%rsp),%rax
0x00005555555559b6 <+267>: xor %fs:0x28,%rax
0x00005555555559bf <+276>: jne 0x5555555559ce <phase_6+291>
0x00005555555559c1 <+278>: add $0x60,%rsp
0x00005555555559c5 <+282>: pop %rbx
0x00005555555559c6 <+283>: pop %rbp
0x00005555555559c7 <+284>: pop %r12
0x00005555555559c9 <+286>: pop %r13
0x00005555555559cb <+288>: pop %r14
0x00005555555559cd <+290>: retq
0x00005555555559ce <+291>: callq 0x555555555250 <__stack_chk_fail#plt>
When I saw other people's solutions, They did x/3x $esi to find out the node1.
But, when I did it, I got an error.
what should I do?

AVFoundation Mutex interlock on AVAudioPlayerNode.Stop

I am trying to write my first Swift application, and its running great!… in the simulator. The application is generating tones via AVFoundation, and it works well when I start playing the tones on the iPhone, but as soon as i try to stop the AVAudioPlayerNode, then 5 out of 10 times my iPhone application freezes up. Everything is working perfectly in the simulator.
Here are the stopping code:
#IBAction func togglePlay(_ sender: UIButton) {
if tone.isPlaying {
engine.mainMixerNode.volume = 0.0
tone.stop() // This is where is freezes up and tone is a AVAudioPlayerNode
engine.reset() // engine is a AVAudioEngine
sender.setImage(UIImage(named:"icons8-play-100")!, for: UIControl.State())
} else {
tone.preparePlaying()
tone.play()
engine.mainMixerNode.volume = 1.0
sender.setImage(UIImage(named:"icons8-stop-filled-100")!, for: UIControl.State())
}
If i pause the code when it freeze and look at the stack trace, then it looks like it's waiting for some sort of Mutex be be released. But I'm not experienced enough to know how to investigate further on what i'm doing wrong
Here are the stack trace:
VFAudio`-[AVAudioPlayerNode stop]:
0x187b68c34 <+0>: stp x22, x21, [sp, #-0x30]!
0x187b68c38 <+4>: stp x20, x19, [sp, #0x10]
0x187b68c3c <+8>: stp x29, x30, [sp, #0x20]
0x187b68c40 <+12>: add x29, sp, #0x20 ; =0x20
0x187b68c44 <+16>: mov x21, x0
0x187b68c48 <+20>: adrp x8, 177438
0x187b68c4c <+24>: add x8, x8, #0x700 ; =0x700
0x187b68c50 <+28>: ldr x19, [x8]
0x187b68c54 <+32>: cbz x19, 0x187b68c70 ; <+60>
0x187b68c58 <+36>: ldr x8, [x19]
0x187b68c5c <+40>: ldr x8, [x8, #0x10]
0x187b68c60 <+44>: mov x0, x19
0x187b68c64 <+48>: blr x8
0x187b68c68 <+52>: mov x20, x0
0x187b68c6c <+56>: b 0x187b68c74 ; <+64>
0x187b68c70 <+60>: mov w20, #0x0
0x187b68c74 <+64>: adrp x8, 177435
0x187b68c78 <+68>: add x8, x8, #0x9dc ; =0x9dc
0x187b68c7c <+72>: ldrsw x8, [x8]
0x187b68c80 <+76>: ldr x21, [x21, x8]
0x187b68c84 <+80>: ldr x8, [x21]
0x187b68c88 <+84>: ldr x8, [x8, #0x198]
0x187b68c8c <+88>: mov x0, x21
0x187b68c90 <+92>: blr x8
0x187b68c94 <+96>: ldr x0, [x21, #0x8] <— This is where it breaks
libsystem_kernel.dylib`__psynch_mutexwait:
0x181c15134 <+0>: mov x16, #0x12d
0x181c15138 <+4>: svc #0x80
-> 0x181c1513c <+8>: b.lo 0x181c15154 ; <+32>
What would be next step in debugging?
Pay attention to threading in your audio engine setup.
Had the same issue when saved audio frames from the injected equalizer unit:
equalizer.installTap(onBus: 0, ... ) { buffer, _ in
...
status = ExtAudioFileWrite(file, numberOfFrames, audioBufferList)
...
}
Mutex interlock was fixed by forwarding ExtAudioFileWrite call to the main thread

Why does my app run in the simulator but crash trying to launch on my iPhone?

I'm writing an app in Swift 3 using Xcode 8.3.2. My app runs fine in the Simulator but I get an ugly error message when I try to run it on my iPhone (iOS 10.3.1):
libswiftCore.dylib`function signature specialization <preserving fragile attribute, Arg[2] = Dead, Arg[3] = Dead> of Swift._fatalErrorMessage (Swift.StaticString, Swift.StaticString, file : Swift.StaticString, line : Swift.UInt, flags : Swift.UInt32) -> Swift.Never:
0x1005203d0 <+0>: stp x26, x25, [sp, #-0x50]!
0x1005203d4 <+4>: stp x24, x23, [sp, #0x10]
0x1005203d8 <+8>: stp x22, x21, [sp, #0x20]
0x1005203dc <+12>: stp x20, x19, [sp, #0x30]
0x1005203e0 <+16>: stp x29, x30, [sp, #0x40]
0x1005203e4 <+20>: add x29, sp, #0x40 ; =0x40
0x1005203e8 <+24>: mov x19, x6
0x1005203ec <+28>: mov x20, x5
0x1005203f0 <+32>: mov x21, x4
0x1005203f4 <+36>: mov x22, x3
0x1005203f8 <+40>: mov x23, x2
0x1005203fc <+44>: mov x24, x1
0x100520400 <+48>: mov x25, x0
0x100520404 <+52>: adr x8, #0xf11fc ; protocol descriptor for Swift._DefaultCustomPlaygroundQuickLookable + 136
0x100520408 <+56>: nop
0x10052040c <+60>: add x0, x8, #0x10 ; =0x10
0x100520410 <+64>: mov w1, #0x28
0x100520414 <+68>: orr w2, wzr, #0x7
0x100520418 <+72>: bl 0x100520750 ; swift_rt_swift_allocObject
0x10052041c <+76>: mov x8, x0
0x100520420 <+80>: stp x22, x21, [x8, #0x10]
0x100520424 <+84>: strb w20, [x8, #0x20]
0x100520428 <+88>: str w19, [x8, #0x24]
0x10052042c <+92>: adr x3, #0x40440 ; partial apply forwarder for Swift.(_fatalErrorMessage (Swift.StaticString, Swift.StaticString, file : Swift.StaticString, line : Swift.UInt, flags : Swift.UInt32) -> Swift.Never).(closure #2)
0x100520430 <+96>: nop
0x100520434 <+100>: mov x0, x25
0x100520438 <+104>: mov x1, x24
0x10052043c <+108>: mov x2, x23
0x100520440 <+112>: mov x4, x8
0x100520444 <+116>: bl 0x1004014dc ; function signature specialization <preserving fragile attribute, Arg[1] = [Closure Propagated : reabstraction thunk helper from #callee_owned (#unowned Swift.UnsafeBufferPointer<Swift.UInt8>) -> () to #callee_owned (#unowned Swift.UnsafeBufferPointer<Swift.UInt8>) -> (#out ()), Argument Types : [#callee_owned (#unowned Swift.UnsafeBufferPointer<Swift.UInt8>) -> ()]> of generic specialization <preserving fragile attribute, ()> of Swift.StaticString.withUTF8Buffer <A> ((Swift.UnsafeBufferPointer<Swift.UInt8>) -> A) -> A
-> 0x100520448 <+120>: brk #0x1
I set an exception breakpoint that led me to this bit of code:
if let defaultFormula = dataManager.fetchDefaultFormula(moc) {
self.formula = defaultFormula.first! <<< Unexpectedly found nil...
}
and here is the function it's calling:
func fetchDefaultFormula(_ moc: NSManagedObjectContext) -> [Formula]? {
let defaultFormulaID = UserDefaults.formula()
let fetchRequest = NSFetchRequest<NSFetchRequestResult>(entityName: "Formula")
let filterPredicate = NSPredicate(format: "uuid = [c] %#", defaultFormulaID)
fetchRequest.predicate = filterPredicate
do {
return try moc.fetch(fetchRequest) as? [Formula]
} catch {
fatalError("There was an error fetching the lifts")
}
return nil
}
The fetch request is returning 0 values so it's clear why I get the exception when I force unwrap it. However, the object property 'formula' must have a value. The first thing the app does is check to see if the default data (like the available formulas) exists in the persistent store and if it doesn't, it adds it. I've reset the Simulator and it dutifully adds them but it seems that this isn't happening on the iPhone. If there's a way for me to determine whether or not the records are being added to the store when running it on the iPhone, please enlighten me.
I've found a few SO threads in which others have experienced this cryptic error (the big, ugly one, not the unexpected nil) and I've tried all of the remedies suggested:
cleaned the project unplugged the iPhone, plugged it back in
restarted all devices
changed the Team to None and back to me
turned off Automatically manage signing and turned it back on
downloaded my current certificates
turned some flags from No to Yes in Build Settings
etc
I don't know where to go from here having exhausted all of the suggestions I've been able to find.
Any suggestions are greatly appreciated.
Well, I guess there was one thing I didn't try - uninstalling the app from my phone first, then build and run it on the phone.
So I don't really know what the root cause was, but at least this resolved the problem.

*.s files cannot be correctly assembled in visualGDB

I am new to visualGDB. Recently I new a stm32 stand-alone project, any .cpp and .c files could be compiled correctly, but when i migrated µC/OS-II into the project, I found os_cpu_a.s file couldn't be assembled correctly.
Error logs are shown as follows:
And my Makefile flags setting is:
Please give me some suggestions! Any help will be appreciated!
os_cpu_a.s files content is shown below:
;/*********************** (C) COPYRIGHT 2010 Libraworks *************************
;* File Name : os_cpu_a.asm
;* Author : Librae
;* Version : V1.0
;* Date : 06/10/2010
;* Description : μCOS-II asm port for STM32
;*******************************************************************************/
IMPORT OSRunning ; External references
IMPORT OSPrioCur
IMPORT OSPrioHighRdy
IMPORT OSTCBCur
IMPORT OSTCBHighRdy
IMPORT OSIntNesting
IMPORT OSIntExit
IMPORT OSTaskSwHook
EXPORT OSStartHighRdy
EXPORT OSCtxSw
EXPORT OSIntCtxSw
EXPORT OS_CPU_SR_Save ; Functions declared in this file
EXPORT OS_CPU_SR_Restore
EXPORT PendSV_Handler
NVIC_INT_CTRL EQU 0xE000ED04
NVIC_SYSPRI2 EQU 0xE000ED20
NVIC_PENDSV_PRI EQU 0xFFFF0000
NVIC_PENDSVSET EQU 0x10000000
PRESERVE8
AREA |.text|, CODE, READONLY
THUMB
;********************************************************************************************************
; CRITICAL SECTION METHOD 3 FUNCTIONS
;
; Description: Disable/Enable interrupts by preserving the state of interrupts. Generally speaking you
; would store the state of the interrupt disable flag in the local variable 'cpu_sr' and then
; disable interrupts. 'cpu_sr' is allocated in all of uC/OS-II's functions that need to
; disable interrupts. You would restore the interrupt disable state by copying back 'cpu_sr'
; into the CPU's status register.
;
; Prototypes : OS_CPU_SR OS_CPU_SR_Save(void);
; void OS_CPU_SR_Restore(OS_CPU_SR cpu_sr);
;
;
; Note(s) : 1) These functions are used in general like this:
;
; void Task (void *p_arg)
; {
; #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
; OS_CPU_SR cpu_sr;
; #endif
;
; :
; :
; OS_ENTER_CRITICAL(); /* cpu_sr = OS_CPU_SaveSR(); */
; :
; :
; OS_EXIT_CRITICAL(); /* OS_CPU_RestoreSR(cpu_sr); */
; :
; :
; }
;********************************************************************************************************
OS_CPU_SR_Save
MRS R0, PRIMASK
CPSID I
BX LR
OS_CPU_SR_Restore
MSR PRIMASK, R0
BX LR
OSStartHighRdy
LDR R4, =NVIC_SYSPRI2 ; set the PendSV exception priority
LDR R5, =NVIC_PENDSV_PRI
STR R5, [R4]
MOV R4, #0 ; set the PSP to 0 for initial context switch call
MSR PSP, R4
LDR R4, =OSRunning ; OSRunning = TRUE
MOV R5, #1
STRB R5, [R4]
LDR R4, =NVIC_INT_CTRL ;rigger the PendSV exception (causes context switch)
LDR R5, =NVIC_PENDSVSET
STR R5, [R4]
CPSIE I ;enable interrupts at processor level
OSStartHang
B OSStartHang ;should never get here
OSCtxSw
PUSH {R4, R5}
LDR R4, =NVIC_INT_CTRL
LDR R5, =NVIC_PENDSVSET
STR R5, [R4]
POP {R4, R5}
BX LR
OSIntCtxSw
PUSH {R4, R5}
LDR R4, =NVIC_INT_CTRL
LDR R5, =NVIC_PENDSVSET
STR R5, [R4]
POP {R4, R5}
BX LR
NOP
PendSV_Handler
CPSID I ; Prevent interruption during context switch
MRS R0, PSP
CBZ R0, PendSV_Handler_Nosave ; Skip register save the first time
SUBS R0, R0, #0x20 ; Save remaining regs r4-11 on process stack
STM R0, {R4-R11}
LDR R1, =OSTCBCur ; OSTCBCur->OSTCBStkPtr = SP;
LDR R1, [R1]
STR R0, [R1] ; R0 is SP of process being switched out
; At this point, entire context of process has been saved
PendSV_Handler_Nosave
PUSH {R14} ; Save LR exc_return value
LDR R0, =OSTaskSwHook ; OSTaskSwHook();
BLX R0
POP {R14}
LDR R0, =OSPrioCur ; OSPrioCur = OSPrioHighRdy;
LDR R1, =OSPrioHighRdy
LDRB R2, [R1]
STRB R2, [R0]
LDR R0, =OSTCBCur ; OSTCBCur = OSTCBHighRdy;
LDR R1, =OSTCBHighRdy
LDR R2, [R1]
STR R2, [R0]
LDR R0, [R2] ; R0 is new process SP; SP = OSTCBHighRdy->OSTCBStkPtr;
LDM R0, {R4-R11} ; Restore r4-11 from new process stack
ADDS R0, R0, #0x20
MSR PSP, R0 ; Load PSP with new process SP
ORR LR, LR, #0x04 ; Ensure exception return uses process stack
CPSIE I
BX LR ; Exception return will restore remaining context
end
By the way, it seems that any chinese character in edition will be treated as spam as a spam prevention method?So i have to delete all chinese comment in my code.

Automatic Reverse Segues

My app make a telephone call from my collection view controller. After the call app shows home page. Call is not returned to called controller.
I put break points and checked execution flow. Then I could realise that call returned to called controller. But after that some internal codes are running and automatically segue to home page view controller (initial view controller). I don't know anything about internal execution like
UIKit-[UIControl sendAction:to:forEvent:]:
0x1891f93b4 <+0>: stp x22, x21, [sp, #-48]!
0x1891f93b8 <+4>: stp x20, x19, [sp, #16]
0x1891f93bc <+8>: stp x29, x30, [sp, #32]
0x1891f93c0 <+12>: add x29, sp, #32
0x1891f93c4 <+16>: mov x19, x4
0x1891f93c8 <+20>: mov x20, x2
0x1891f93cc <+24>: mov x21, x0
0x1891f93d0 <+28>: mov x0, x3
0x1891f93d4 <+32>: bl
Finally I could track my problem..For some other reason I put a line of code inside the following App delegate method like:-
func applicationWillResignActive(application: UIApplication) {
window?.rootViewController?.dismissViewControllerAnimated(false, completion: nil)
}
I commented the line of code and everything work fine...Thank God!!!!!