EzDevInfo.com

crash interview questions

Top crash frequently asked interview questions

-[MyClassName copyWithZone:] unrecognized selector sent to instance

My application crashed with the reason:

-[MyClassName copyWithZone:] unrecognized selector sent to instance

I have two classes. Let's say Class1 and Class2.

Class1 looks like:

Class1.h

@interface Class1 : NSObject {
    NSString *imagemd5CheckSum;
    UIImage *image;
    NSData *fileChunkData;
}

@property (nonatomic, copy)NSString *imagemd5CheckSum;
@property (nonatomic, copy)UIImage *image;
@property (nonatomic, copy)NSData *fileChunkData;

@end

Class1.m

@implementation Class1

@synthesize image;
@synthesize fileChunkData;
@synthesize imagemd5CheckSum;

-(id) init{
    [self setImage:nil];
    [self setFileChunkData:nil];
    [self setImagemd5CheckSum:@""];

    return self;
}

-(void)dealloc{
    [imagemd5CheckSum release];
    [image release];
    [fileChunkData release];

    fileChunkData = nil;
    imagemd5CheckSum = nil;
    image = nil;

    [super dealloc];
}
@end

**

Class2 looks like

**

Class2.h


#import "Class2.h"
@interface Class2 : NSObject {
    Class1 *obj1;
    Class1 *obj2;
    Class1 *obj3;
}

@property (nonatomic, copy)Class1 *obj1;
@property (nonatomic, copy)Class1 *obj2;
@property (nonatomic, copy)Class1 *obj3;

@end

Class2.m


@implementation Class2

@synthesize obj1,obj2,obj3;

-(id) init{
    [self setObj1:nil];
    [self setObj2:nil];
    [self setObj3:nil];

    return self;
}

-(void)dealloc{
    [obj1 release];
    [obj2 release];
    [obj3 release];

    obj1 = nil;
    obj2 = nil;
    obj3 = nil;

    [super dealloc];
}
@end

Crashed Situation

Class2 *class2 = [[Class2 alloc] init];

Class1 *class1 = [[Class1 alloc] init];

[class1 setImagemd5CheckSum:@"this is md5"];
[class1 setImage:myimage];
[class1 setFileChunkData:myData];

[class2 setObj1:class1]; // This line is crashed..

...

When I called [class2 setObj1:class1];, the application crashed with reason:

-[Class1 copyWithZone:] unrecognized selector sent to instance

How can I fix this problem?


Source: (StackOverflow)

iOS crash log catch, debug info.. Catch and send via email to the Dev team

Recently we came across a situation where we wanted to see the debug info from the app which a user has on his device. So, what I am looking for is a way to find the log on the device, paste it as inline text on a mail and allow the user to send it..

Any ideas? Here are the questions again.. 1)Find a debug log on the device 2)open the file and attach the contents of the file as inline text in to the mail. 3)Allow the user to email it the next time app launches..

Thanks,


Source: (StackOverflow)

Advertisements

During export of signed app, eclipse crashes

I have an android application that I exported a signed version perfectly on March 17, 2013. Then on March 19, 2013 I updated the Facebook SDK and Android SDK Manager, then tried to export my a signed version of my app again. First mistake.

Now I've been experiencing one of the two issues ever since and I can't export a new signed version of my app to re-upload the Google Play store.

  1. Conversion to Dalvik format failed with error 1
  2. or my Android Application Crashes when I'm exporting it.

I've tried numerous solutions I've found on the web and still am experiencing no luck. I even removed and re-installed Eclipse, the ADT, and Facebook SDK. Still, I'm having issues.

Eclipse actually crashes which is really odd. Any ideas?

Update: So, I am no longer getting the "Conversion to Dalvik format failed with error 1" any more on export of signed app. Eclipse just crashes on export of signed app. Any ideas? I have all the latest software: eclipse, facebook sdk, android sdk, etc. I'm running the latest version of Mac OS X.


Source: (StackOverflow)

Android app crashes after SDK-tools update version (NoClassDefFound, tool version 22)

I have just updated my android SDK tools to the newly released version (tools version 22, platform tools version 17)

java.lang.NoClassDefFoundError

The .classpath file was modified. The update in added a line :

<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>

Before the SDK tools update, all my projects worked well !!

I corrected my problem in this way :

  • In the project properties (eclipse) -> java build path -> order and export make sure that all your jars in the libs folder are checked.
  • And "Android Tools -> Fix Project Properties"
  • And "Project -> Clean"

But I don't understand why! Would anybody have an explanation ?


Source: (StackOverflow)

C# : "A first chance exception of type 'System.InvalidOperationException'"

Working on a class assignment in C#, I came across a program crash without any error (except what's written in VS2010's debug window). Here is the typical code causing the crash :

public partial class Test : Form
{
    public Test()
    {
        InitializeComponent();
    }

    private void Test_Load(object sender, EventArgs e)
    {
        ColumnHeader header;

        header = new ColumnHeader();
        header.Text = "#";
        header.TextAlign = HorizontalAlignment.Center;
        header.Width = 30;
        listView1.Columns.Add(header);

        TimerCallback tcb = this.UpdateListView;

        System.Threading.Timer updateTimer = new System.Threading.Timer(tcb, null, 0, 1000);
    }

    public void UpdateListView(object obj)
    {
        ListViewItem item;
        listView1.Items.Clear();

        for (int i = 0; i < 10; i++)
        {
            item = new ListViewItem(i.ToString());

            listView1.Items.Add(item);
        }

    }
}

... what am I missing here?

** EDIT **

There's no error, the program just ends like if I would call System.Environment.Exit(0);

A first chance exception of type 'System.InvalidOperationException' occurred in System.Windows.Forms.dll
The program '[4644] ProgramTest.vshost.exe: Managed (v4.0.30319)' has exited with code 0 (0x0).
The program '[4644] ProgramTest.vshost.exe: Program Trace' has exited with code 0 (0x0).

Source: (StackOverflow)

What is the easiest way to make a C++ program crash?

I'm trying to make a Python program that interfaces with a different crashy process (that's out of my hands). Unfortunately the program I'm interfacing with doesn't even crash reliably! So I want to make a quick C++ program that crashes on purpose but I don't actually know the best and shortest way to do that, does anyone know what to put between my:

int main() {
    crashyCodeGoesHere();
}

to make my C++ program crash reliably


Source: (StackOverflow)

Android Studio - How to increase Allocated Heap Size

I've been using Android Studio for 3 months now and one of the apps I started on it has become fairly large. The memory usage indicated at the bottom right of the program says my allocated heap is maxed at 494M.

enter image description here

When I start to change the XML files my memory usage quickly reaches that cap and the IDE crashes with an Out Of Memory error like this.

enter image description here

I've tried to increase the heap size using this but so far there has been no effect.

I've looked at dozens of articles and other questions on how to increase the heap size but none of their answers are working. No matter what I do to the VMOPTIONS or the IDE settings the heap size never increases. I believe I am editting the correct file for the VMOPTIONS because if I purposely give it an invalid command Android Studio complains about it and doesn't start.

I'm using windows 7 - 64 bit and have 16GB RAM. Has anyone else had this problem with Android Studio? And were you able to fix it?


Source: (StackOverflow)

Google Maps Android API v2 - Sample Code crashes

I'm trying to get the sample code of Android 'Google Maps Android API v2' working. I get the project built without errors. However, when I try to run the app on my Galaxy Nexus (connected with usb to my laptop), the app crashes immediately.

  • I filled in my own Maps API Key at the AndroidManifest.xml
  • I built against Android 4.1.2

This is the logging:

Unable to resolve superclass of Lcom/example/mapdemo/BasicMapActivity; (66) 
Link of class 'Lcom/example/mapdemo/BasicMapActivity;' failed 
Could not find class 'com.example.mapdemo.BasicMapActivity', referenced from method com.example.mapdemo.MainActivity.<clinit> 
VFY: unable to resolve const-class 108 (Lcom/example/mapdemo/BasicMapActivity;) in Lcom/example/mapdemo/MainActivity; 
VFY: replacing opcode 0x1c at 0x000d 
Exception Ljava/lang/NoClassDefFoundError; thrown while initializing Lcom/example/mapdemo/MainActivity; 
Class init failed in newInstance call (Lcom/example/mapdemo/MainActivity;) 
Shutting down VM 
threadid=1: thread exiting with uncaught exception (group=0x41ac9930) 
FATAL EXCEPTION: main 
java.lang.ExceptionInInitializerError
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1319)
at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5039)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
at dalvik.system.NativeStart.main(Native Method) 
Caused by: java.lang.NoClassDefFoundError: com.example.mapdemo.BasicMapActivity
at com.example.mapdemo.MainActivity.<clinit>(MainActivity.java:97)
... 15 more

Does anybody have a hint how to solve this or what I might be doing wrong?


Source: (StackOverflow)

How do I use PDB files

I have heard using PDB files can help diagnose where a crash occurred.
My basic understanding is that you give Visual studio the source file, the pdb file and the crash information (from Dr Watson?)
Can someone please explain how it all works / what is involved? (Thank you!)


Source: (StackOverflow)

App shutdown with EXC_RESOURCE, WAKEUPS exception on iOS 8 GM

Does anyone know what this kind of exception is on iOS 8?

=== from crash report ===

Exception Type: EXC_RESOURCE
Exception Subtype: WAKEUPS
Exception Message: (Limit 150/sec) Observed 206/sec over 300 secs
Triggered by Thread: 14

Seems to only happen on iOS 8... Our app is shut down quite randomly at arbitrary intervals with this exception..

Any clues are welcome. Thanks!


Source: (StackOverflow)

In App Purchase Crashes on [[SKPaymentQueue defaultQueue] addPayment:payment]

My In-App-Purchases work. I present a ModalView with a "Buy" UIButton. You click the button and the In App Purchase goes through the process. You can even do it several times in a row.

The problem occurs if you open the Modal View, then close the Modal View (using a UITabBarButtonItem), then reopen the Modal View and tap the "Buy" button. The app crashes and I get an NSZombie that reads

* -[InAppPurchaseManager respondsToSelector:]: message sent to deallocated instance 0x1c7ad0

The NSZombie points to line 160 in the .m file. I have marked it with comments.

I got the original code from this page: http://troybrant.net/blog/2010/01/in-app-purchases-a-full-walkthrough/

I have been struggling with this for many days now... any help would be awesome.

Here is the .h

//
//  InAppPurchaseManager.h
//  Copyright 2010 __MyCompanyName__. All rights reserved.


#import <UIKit/UIKit.h>
#import <StoreKit/StoreKit.h>

#define kInAppPurchaseManagerProductsFetchedNotification @"kInAppPurchaseManagerProductsFetchedNotification"
#define kInAppPurchaseManagerTransactionFailedNotification @"kInAppPurchaseManagerTransactionFailedNotification"
#define kInAppPurchaseManagerTransactionSucceededNotification @"kInAppPurchaseManagerTransactionSucceededNotification"

#define kInAppPurchaseCreditProductId @"com.myname.app.iap"

@interface InAppPurchaseManager : UIViewController <SKProductsRequestDelegate, SKPaymentTransactionObserver>
{
    SKProduct *productID;
    SKProductsRequest *productsRequest;

 IBOutlet UIBarButtonItem *closeButton;
 IBOutlet UIButton *buyButton;
 IBOutlet UILabel *testLabel;

}

@property (retain, nonatomic) SKProduct *productID;
@property (retain, nonatomic) SKProductsRequest *productsRequest;

@property (retain, nonatomic) IBOutlet UIBarButtonItem *closeButton;
@property (retain, nonatomic) IBOutlet UIButton *buyButton;
@property (retain, nonatomic) IBOutlet UILabel *testLabel;


// public methods
-(void)loadStore;
-(BOOL)canMakePurchases;
-(void)purchaseCredit;

-(void)requestInAppPurchaseData;
-(void)buyButtonAction:(id)sender;
-(void)closeButtonAction:(id)sender;
-(void)updateButtonStatus:(NSString *)status;

@end

Here is the .m

// InAppPurchaseManager.m

#import "InAppPurchaseManager.h"

@implementation InAppPurchaseManager

@synthesize productID;
@synthesize productsRequest;

@synthesize closeButton;
@synthesize buyButton;
@synthesize testLabel;


- (void)dealloc {

 [productID release];
 //[productsRequest release];

 [closeButton release];
 [buyButton release];
 [testLabel release];

    [super dealloc];
}


- (void)viewDidLoad {
    [super viewDidLoad];

 [closeButton release];
 closeButton = [[UIBarButtonItem alloc] initWithTitle:@"Close" style:UIBarButtonItemStyleBordered target:self action:@selector(closeButtonAction:)];
 self.navigationItem.leftBarButtonItem = closeButton;

 [self loadStore];

 self.navigationItem.title = @"Credits";


}

-(void)closeButtonAction:(id)sender { 
 [self dismissModalViewControllerAnimated:YES];
}


-(void)buyButtonAction:(id)sender {

 if([self canMakePurchases]) {
  [self updateButtonStatus:@"OFF"];

  [self performSelectorOnMainThread:@selector(requestInAppPurchaseData) withObject:nil waitUntilDone:NO];

 } else {
  UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:[NSString stringWithString:@"Your account settings do not allow for In App Purchases."] delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
  [alertView show];
  [alertView release];  
 }

}


-(void)updateButtonStatus:(NSString *)status {

 if ([status isEqual:@"OFF"]) {
  closeButton.enabled = NO;
  buyButton.enabled = NO;
  buyButton.titleLabel.textColor = [UIColor grayColor];
 } else {
  closeButton.enabled = YES;
  buyButton.enabled = YES;
  buyButton.titleLabel.textColor = [UIColor blueColor];
 }

}

#pragma mark -
#pragma mark SKProductsRequestDelegate methods


//
// call this method once on startup
//
- (void)loadStore
{

    // restarts any purchases if they were interrupted last time the app was open
    [[SKPaymentQueue defaultQueue] addTransactionObserver:self];

}


- (void)requestInAppPurchaseData
{
 NSSet *productIdentifiers = [NSSet setWithObject:kInAppPurchaseCreditProductId];

    productsRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:productIdentifiers];
    productsRequest.delegate = self;
    [productsRequest start];

    // we will release the request object in the delegate callback
}



- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{

    NSArray *products = response.products;


    productID = [products count] == 1 ? [[products objectAtIndex:0] retain] : nil;
    if (productID)
    {
  /*
   NSLog(@"Product title: %@" , productID.localizedTitle);
   NSLog(@"Product description: %@" , productID.localizedDescription);
   NSLog(@"Product price: %@" , productID.price);
   NSLog(@"Product id: %@" , productID.productIdentifier);
   */

  NSUserDefaults *standardUserDefaults = [NSUserDefaults standardUserDefaults];
  NSString *currentCredits = ([standardUserDefaults objectForKey:@"currentCredits"]) ? [standardUserDefaults objectForKey:@"currentCredits"] : @"0";

  testLabel.text = [NSString stringWithFormat:@"%@", currentCredits];
    }

    for (NSString *invalidProductId in response.invalidProductIdentifiers)
    {
        //NSLog(@"Invalid product id: %@" , invalidProductId);
  testLabel.text = @"Try Again Later.";
    }

    // finally release the reqest we alloc/init’ed in requestProUpgradeProductData
    [productsRequest release];

    [[NSNotificationCenter defaultCenter] postNotificationName:kInAppPurchaseManagerProductsFetchedNotification object:self userInfo:nil];

 [self performSelectorOnMainThread:@selector(purchaseCredit) withObject:nil waitUntilDone:NO];
}


//
// call this before making a purchase
//
- (BOOL)canMakePurchases
{
    return [SKPaymentQueue canMakePayments];
}

//
// kick off the upgrade transaction
//
- (void)purchaseCredit
{

    SKPayment *payment = [SKPayment paymentWithProductIdentifier:kInAppPurchaseCreditProductId];

 // *********************************************************************************************************
 [[SKPaymentQueue defaultQueue] addPayment:payment]; // <--- This is where the NSZombie Appears *************
 // *********************************************************************************************************

}

#pragma -
#pragma Purchase helpers

//
// saves a record of the transaction by storing the receipt to disk
//
- (void)recordTransaction:(SKPaymentTransaction *)transaction
{
 if ([transaction.payment.productIdentifier isEqualToString:kInAppPurchaseCreditProductId])
    {
        // save the transaction receipt to disk
        [[NSUserDefaults standardUserDefaults] setValue:transaction.transactionReceipt forKey:@"InAppPurchaseTransactionReceipt" ];
        [[NSUserDefaults standardUserDefaults] synchronize];
    }

}

//
// enable pro features
//
- (void)provideContent:(NSString *)productId
{
 if ([productId isEqualToString:kInAppPurchaseCreditProductId])
    {        
  // Increment currentCredits
  NSUserDefaults *standardUserDefaults = [NSUserDefaults standardUserDefaults];
  NSString *currentCredits = [standardUserDefaults objectForKey:@"currentCredits"];
  int newCreditCount = [currentCredits intValue] + 1;
  [standardUserDefaults setObject:[NSString stringWithFormat:@"%d", newCreditCount] forKey:@"currentCredits"];

  testLabel.text = [NSString stringWithFormat:@"%d", newCreditCount];

    }

}

//
// removes the transaction from the queue and posts a notification with the transaction result
//
- (void)finishTransaction:(SKPaymentTransaction *)transaction wasSuccessful:(BOOL)wasSuccessful
{

    // remove the transaction from the payment queue.
    [[SKPaymentQueue defaultQueue] finishTransaction:transaction];

    NSDictionary *userInfo = [NSDictionary dictionaryWithObjectsAndKeys:transaction, @"transaction" , nil];
    if (wasSuccessful)
    {
        // send out a notification that we’ve finished the transaction
        [[NSNotificationCenter defaultCenter] postNotificationName:kInAppPurchaseManagerTransactionSucceededNotification object:self userInfo:userInfo];
    }
    else
    {
        // send out a notification for the failed transaction
        [[NSNotificationCenter defaultCenter] postNotificationName:kInAppPurchaseManagerTransactionFailedNotification object:self userInfo:userInfo];
    }


 [self updateButtonStatus:@"ON"];

}

//
// called when the transaction was successful
//
- (void)completeTransaction:(SKPaymentTransaction *)transaction
{

 [self updateButtonStatus:@"OFF"];

 [self recordTransaction:transaction];
    [self provideContent:transaction.payment.productIdentifier];
 [self finishTransaction:transaction wasSuccessful:YES];

}

//
// called when a transaction has been restored and and successfully completed
//
- (void)restoreTransaction:(SKPaymentTransaction *)transaction
{
    [self recordTransaction:transaction.originalTransaction];
    [self provideContent:transaction.originalTransaction.payment.productIdentifier];
    [self finishTransaction:transaction wasSuccessful:YES];
}

//
// called when a transaction has failed
//
- (void)failedTransaction:(SKPaymentTransaction *)transaction
{

    if (transaction.error.code != SKErrorPaymentCancelled)
    {
   // error!
        [self finishTransaction:transaction wasSuccessful:NO];
    }
    else
    {
   // this is fine, the user just cancelled, so don’t notify
        [[SKPaymentQueue defaultQueue] finishTransaction:transaction];
    }

 [self updateButtonStatus:@"ON"];

}

#pragma mark -
#pragma mark SKPaymentTransactionObserver methods

//
// called when the transaction status is updated
//
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
{

    for (SKPaymentTransaction *transaction in transactions)
    {
        switch (transaction.transactionState)
        {
            case SKPaymentTransactionStatePurchased:
                [self completeTransaction:transaction];
                break;
            case SKPaymentTransactionStateFailed:
                [self failedTransaction:transaction];
                break;
            case SKPaymentTransactionStateRestored:
                [self restoreTransaction:transaction];
                break;
            default:
                break;
        }
    }
}


@end

Source: (StackOverflow)

Eclipse continue crashing

today my Eclipse continue crashing and show me this message:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007f9d6dfd4c91, pid=5739, tid=140316573566720
#
# JRE version: 7.0_25-b30
# Java VM: OpenJDK 64-Bit Server VM (23.7-b01 mixed mode linux-amd64 )
# Problematic frame:
# C  [libsoup-2.4.so.1+0x6ac91]  soup_session_feature_detach+0x11
#
# Core dump written. Default location: /home/panthe/eclipse/core or core.5739
#
# If you would like to submit a bug report, please include
# instructions on how to reproduce the bug and visit:
#   https://bugs.launchpad.net/ubuntu/+source/openjdk-7/
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

Someone can help me?


Source: (StackOverflow)

C# 4.0 Compiler Crash

This code sample is not able to be compiled. Any work arounds out there?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    using church = Func<dynamic, dynamic, dynamic>;

    class Program
    {
        static void Main(string[] args)
        {
            church True = (a, b) => a;
            church False = (a, b) => b;

            Func<church, church, church> And = (x, y) => x(y(True, False), False);
        }
    }
}

Error 6 Internal Compiler Error (0xc0000005 at address 5476A4CC): likely culprit is 'EMITIL'. An internal error has occurred in the compiler. To work around this problem, try simplifying or changing the program near the locations listed below. Locations at the top of the list are closer to the point at which the internal error occurred. Errors such as this can be reported to Microsoft by using the /errorreport option. TestApplication


Source: (StackOverflow)

Is there any way a C/C++ program can crash before main()?

Is there any way a program can crash before main()?


Source: (StackOverflow)

Android Fatal Signal 11

In the app I'm developing on Android, I keep getting a Fatal Signal 11 error.

I think it's something to do with the way that I'm accessing the memory but I can't figure out what is causing it.

Any help will be much appreciated!

Here's the LogCat:

05-02 23:47:17.618: D/dalvikvm(590): GC_FOR_ALLOC freed 68K, 4% free 6531K/6787K, paused 101ms
05-02 23:47:17.638: I/dalvikvm-heap(590): Grow heap (frag case) to 7.619MB for 1228816-byte allocation
05-02 23:47:17.738: D/dalvikvm(590): GC_CONCURRENT freed 1K, 4% free 7730K/8007K, paused 5ms+14ms
05-02 23:47:17.878: D/dalvikvm(590): GC_FOR_ALLOC freed <1K, 4% free 7730K/8007K, paused 37ms
05-02 23:47:17.888: I/dalvikvm-heap(590): Grow heap (frag case) to 8.790MB for 1228816-byte allocation
05-02 23:47:17.998: D/dalvikvm(590): GC_CONCURRENT freed <1K, 4% free 8930K/9223K, paused 4ms+4ms
05-02 23:47:17.998: A/libc(590): Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1)

Source: (StackOverflow)