Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[self lee_theme_dealloc] EXC_BAD_ACCESS crash #27

Open
jerrywangjing opened this issue Dec 27, 2021 · 3 comments
Open

[self lee_theme_dealloc] EXC_BAD_ACCESS crash #27

jerrywangjing opened this issue Dec 27, 2021 · 3 comments

Comments

@jerrywangjing
Copy link

jerrywangjing commented Dec 27, 2021

在APP从后台切换到前台时,可能会造成app crash,通过异常断点查看,崩溃到的[self lee_theme_dealloc];这里,不太理解作者为什么在这里要多次递归调用该方法,可能引起crash的原因就是self(LEETheme)对象过度内存释放导致的,希望作者能修复该问题。谢谢。

下面是出现crash的文件,及代码片段:

文件:#import "LEETheme.h"

...

@implementation NSObject (LEEThemeConfigObject)
...

- (void)lee_theme_dealloc{
    
    if ([self isLeeTheme]) {
        
        [[NSNotificationCenter defaultCenter] removeObserver:self name:LEEThemeChangingNotificaiton object:nil];
        
        objc_removeAssociatedObjects(self);
    }
    [self lee_theme_dealloc];  // 注:crash 在这里
}
@lixiang1994
Copy link
Owner

实际上是交换了方法实现的, 并不是递归调用, [self lee_theme_dealloc]; 调用的是原来的方法实现, 崩溃到这里并不是由 LEETheme引起的.

@Sunshineyg00
Copy link

Sunshineyg00 commented Sep 2, 2024

实际上是交换了方法实现的, 并不是递归调用, [self lee_theme_dealloc]; 调用的是原来的方法实现, 崩溃到这里并不是由 LEETheme引起的.

我们的app近来也发生多次这样的crash了,貌似比较多是在iOS 17.6.1
原因是:EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x00000000ffffffff
堆栈如下:
0
libobjc.A.dylib
objc_release_x8 + 8
1
Network
__33-[NWConcrete_nw_endpoint dealloc]_block_invoke_2 + 52
2
Network
-[NWConcrete_nw_endpoint dealloc] + 544
3
Network
-[NWConcrete_nw_address_endpoint dealloc] + 76
4
Network
-[OS_nw_array dealloc] + 284
5
Network
-[NWConcrete_nw_path .cxx_destruct] + 92
6
libobjc.A.dylib
object_cxxDestructFromClass(objc_object*, objc_class*) + 116
7
libobjc.A.dylib
objc_destructInstance + 80
8
libobjc.A.dylib
_objc_rootDealloc + 80
9
myapp
LEETheme.m - 第 1985 行
-[NSObject(LEEThemeConfigObject) lee_theme_dealloc] + 1985
10
Network
-[NWConcrete_nw_path dealloc] + 100
11
Network
-[NWConcrete_nw_path_evaluator .cxx_destruct] + 68
12
libobjc.A.dylib
object_cxxDestructFromClass(objc_object*, objc_class*) + 116
13
libobjc.A.dylib
objc_destructInstance + 80
14
libobjc.A.dylib
_objc_rootDealloc + 80
15
myapp
LEETheme.m - 第 1985 行
-[NSObject(LEEThemeConfigObject) lee_theme_dealloc] + 1985
16
Network
-[NWConcrete_nw_path_evaluator dealloc] + 280
17
Network
nw_nat64_v4_address_requires_synthesis + 388
18
libsystem_info.dylib
_gai_nat64_second_pass + 280
19
libsystem_info.dylib
si_addrinfo + 1348
20
libsystem_info.dylib
getaddrinfo + 168

@lixiang1994
Copy link
Owner

任何NSObject 在dealloc发生crash, 堆栈里都会有-[NSObject(LEEThemeConfigObject) lee_theme_dealloc], 你即使把LEETheme移除, crash也不会消失.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants