va_list crash on 64-bits simulator

64-bit, exc-bad-access, ios, ios-simulator, nsstring

Solution

Somehow A-Live comment gave me an idea and I found out how to avoid the crash.

I was using argList twice in the same va_start/va_end block

[[NSString alloc] initWithFormat: format arguments: argList];

and

NSLogv(format, argList);

It seems that iOS 64-bits simulator don't like it. Don't know why it works just find in any other plateforme (and real devices too). So I fixed it by making two deferent bock like that

va_list argList;

va_start(argList, format);
NSString* string = [[NSString alloc] initWithFormat: format arguments: argList];
va_end(argList);

va_start(argList, format);
NSLogv(format, argList);
va_end(argList);

Hope it will help someone. If someone knows why, I am still curious to heard about it.

Problem

When using 64bits iOS simulator the init function below crashes with EXC_BAD_ACCESS (code=1) error. Would anyone know why ? And how to fix it properly. For information: 'format' is not nil, and it works just fine on 32bits simulator and any 32/64 bits iPhone/iPad devices. ``` void Log (NSString * format, ...) { va_list argList; va_start(argList, format); NSLogv(format, argList); NSString* string = [[NSString alloc] initWithFormat: format arguments: argList]; va_end(argList); ... } ``` called first thing in AppDelegate ``` - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { Log(@"app options %@", launchOptions); ... } ```

Original source

Related problems