Что вызывает SIGSEGV на _updateNumSections в UITableView? - PullRequest
0 голосов
/ 01 октября 2011

Время от времени мы получаем следующее. Мы не можем воссоздать эту ошибку.

Кто-нибудь знает, что конкретно вызывает это? Кажется, что UITableView находится в каком-то странном состоянии. Я запустил инструменты для поиска чрезмерного высвобождения памяти и т. Д., Но я не вижу много.

Thread 0 Crashed:
    libobjc.A.dylib                     0x3068f06b _objc_terminate + 103
    libstdc++.6.dylib                   0x30502e3d __cxxabiv1::__terminate(void (*)()) + 53
    libstdc++.6.dylib                   0x30502e91 std::terminate() + 17
    libstdc++.6.dylib                   0x30502f61 __cxa_throw + 85
    libobjc.A.dylib                     0x3068dc8b objc_exception_throw + 71
    CoreFoundation                      0x335141bf -[NSObject(NSObject) doesNotRecognizeSelector:] + 103
    CoreFoundation                      0x33513649 ___forwarding___ + 509
    CoreFoundation                      0x3348a180 _CF_forwarding_prep_0 + 48
    UIKit                               0x31bb2ff3 -[UITableViewRowData(UITableViewRowDataPrivate) _updateNumSections] + 67
    UIKit                               0x31bb2f53 -[UITableViewRowData invalidateAllSections] + 51
    UIKit                               0x31bb2d09 -[UITableView(_UITableViewPrivate) _updateRowData] + 65
    UIKit                               0x31bafab7 -[UITableView _rectChangedWithNewSize:oldSize:] + 111
    UIKit                               0x31bae833 -[UITableView setFrame:] + 159
    UIKit                               0x31bb5e0f -[UIView(Geometry) resizeWithOldSuperviewSize:] + 275
    UIKit                               0x31b820bd -[UIView(Geometry) resizeSubviewsWithOldSize:] + 121
    UIKit                               0x31b674e9 -[UIView(Geometry) setFrame:] + 337
    UIKit                               0x31bb5e0f -[UIView(Geometry) resizeWithOldSuperviewSize:] + 275
    UIKit                               0x31b820bd -[UIView(Geometry) resizeSubviewsWithOldSize:] + 121
    UIKit                               0x31b674e9 -[UIView(Geometry) setFrame:] + 337
    UIKit                               0x31bae9fd -[UIScrollView setFrame:] + 421
    UIKit                               0x31bb5e0f -[UIView(Geometry) resizeWithOldSuperviewSize:] + 275
    UIKit                               0x31b820bd -[UIView(Geometry) resizeSubviewsWithOldSize:] + 121
    UIKit                               0x31b674e9 -[UIView(Geometry) setFrame:] + 337
    UIKit                               0x31bb5e0f -[UIView(Geometry) resizeWithOldSuperviewSize:] + 275
    UIKit                               0x31b820bd -[UIView(Geometry) resizeSubviewsWithOldSize:] + 121
    UIKit                               0x31b674e9 -[UIView(Geometry) setFrame:] + 337
    UIKit                               0x31bb9193 -[UIViewControllerWrapperView setFrame:] + 63
    UIKit                               0x31bb5e0f -[UIView(Geometry) resizeWithOldSuperviewSize:] + 275
    UIKit                               0x31b820bd -[UIView(Geometry) resizeSubviewsWithOldSize:] + 121
    UIKit                               0x31b674e9 -[UIView(Geometry) setFrame:] + 337
    UIKit                               0x31bb5e0f -[UIView(Geometry) resizeWithOldSuperviewSize:] + 275
    UIKit                               0x31b820bd -[UIView(Geometry) resizeSubviewsWithOldSize:] + 121
    UIKit                               0x31b674e9 -[UIView(Geometry) setFrame:] + 337
    UIKit                               0x31b9922f -[UILayoutContainerView setFrame:] + 55
    UIKit                               0x31bb90a9 +[UIViewControllerWrapperView wrapperViewForView:frame:] + 225
    UIKit                               0x31bd6201 -[UITabBarController transitionFromViewController:toViewController:transition:shouldSetSelected:] + 105
    UIKit                               0x31bd618d -[UITabBarController transitionFromViewController:toViewController:] + 33
    UIKit                               0x31bd5a33 -[UITabBarController _setSelectedViewController:] + 187
    UIKit                               0x31c5aceb -[UITabBarController setSelectedViewController:] + 15
    UIKit                               0x31c5abe7 -[UITabBarController _tabBarItemClicked:] + 227
    CoreFoundation                      0x33480571 -[NSObject(NSObject) performSelector:withObject:withObject:] + 25
    UIKit                               0x31b7eec9 -[UIApplication sendAction:to:from:forEvent:] + 85
    UIKit                               0x31b7ee69 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 33
    UIKit                               0x31c5aa8b -[UITabBar _sendAction:withEvent:] + 271
    CoreFoundation                      0x33480571 -[NSObject(NSObject) performSelector:withObject:withObject:] + 25
    UIKit                               0x31b7eec9 -[UIApplication sendAction:to:from:forEvent:] + 85
    UIKit                               0x31b7ee69 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 33
    UIKit                               0x31b7ee3b -[UIControl sendAction:to:forEvent:] + 39
    UIKit                               0x31b7eb8d -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 357
    UIKit                               0x31bb8bd9 -[UIControl sendActionsForControlEvents:] + 17
    UIKit                               0x31c5a815 -[UITabBar(Static) _buttonUp:] + 81
    CoreFoundation                      0x33480571 -[NSObject(NSObject) performSelector:withObject:withObject:] + 25
    UIKit                               0x31b7eec9 -[UIApplication sendAction:to:from:forEvent:] + 85
    UIKit                               0x31b7ee69 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 33
    UIKit                               0x31b7ee3b -[UIControl sendAction:to:forEvent:] + 39
    UIKit                               0x31b7eb8d -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 357
    UIKit                               0x31b7f423 -[UIControl touchesEnded:withEvent:] + 343
    UIKit                               0x31b7dbf5 -[UIWindow _sendTouchesForEvent:] + 369
    UIKit                               0x31b7d56f -[UIWindow sendEvent:] + 263
    UIKit                               0x31b66313 -[UIApplication sendEvent:] + 299
    UIKit                               0x31b65c53 _UIApplicationHandleEvent + 5091
    GraphicsServices                    0x311a5e77 PurpleEventCallback + 667
    CoreFoundation                      0x334e7a97 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 27
    CoreFoundation                      0x334e983f __CFRunLoopDoSource1 + 167
    CoreFoundation                      0x334ea60d __CFRunLoopRun + 521
    CoreFoundation                      0x3347aec3 CFRunLoopRunSpecific + 231
    CoreFoundation                      0x3347adcb CFRunLoopRunInMode + 59
    GraphicsServices                    0x311a541f GSEventRunModal + 115
    GraphicsServices                    0x311a54cb GSEventRun + 63
    UIKit                               0x31b90d69 -[UIApplication _run] + 405
    UIKit                               0x31b8e807 UIApplicationMain + 671
    MyApp                              0x0009a188 main (main.m:5)

Ответы [ 3 ]

3 голосов
/ 01 октября 2011

Начните с просмотра журнала консоли. Там будет сообщение с указанием, какой класс был отправлен updateNumSections.

Убедитесь, что вы не обращаетесь к этому табличному представлению в фоновом потоке. Это может вызвать такие сумасшедшие сбои.

Убедитесь, что источник данных табличного представления не освобожден перед табличным представлением.

Подозрение здесь может быть чрезмерным выпуском (как вы предлагаете), поэтому запустите Статический анализ, чтобы просто найти материал с костью. Также убедитесь, что вы используете аксессоры, а не напрямую ivars (причина номер 1 переизбытка).

0 голосов
/ 11 мая 2016

Я почти уверен, что не обновляю табличное представление в фоновом потоке.

Спасибо @ Pierre-Francoys, я добавляю опцию Zombies, и она сообщает мне селектор numberOfSectionsInTableView:, отправленный на освобожденный объект.Поэтому я очищаю dataSource и делегата tableView в моем viewController.И это работает очень хорошо.

- (void)dealloc {
    _tableView.dataSource = nil; 
    _tableView.delegate = nil;
}
0 голосов
/ 12 сентября 2014

У меня была та же проблема, и, как вы предложили в своем комментарии к ответу Роба Напира, она должна быть реализована в tabBarController вместо viewDidDisappear.

Запуск Zombies в инструментах покажет вам, что вызов updateNumSectionsделается для освобожденного объекта.

Для тех, кто ищет эту проблему, вот код, который вы должны использовать в вашем tabViewController, учитывая навигацию NavViewController, которая вызывается на вкладке, которая больше не отображается.

- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController {
    //Always go to the root controller when accessing a tab.
    //If any navigation controller that must remember its last state, change this for viewController == or !=
    if ([viewController isKindOfClass:[UINavigationController class]]) {
        [(UINavigationController*)viewController popToRootViewControllerAnimated:YES]; //Do not use code on disappear, instead popToRoot on tab selection
    }
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...