iActiveRecord icon indicating copy to clipboard operation
iActiveRecord copied to clipboard

Crash on x64 architecture

Open dumoko opened this issue 11 years ago • 8 comments

Hello! When I run the projects on 64bit simulator, I get crashes.

In one project it is

//  ARLazyFetcher.m
...
- (ARLazyFetcher *)where:(NSString *)aCondition, ...{
...
NSString * result = [[NSString alloc] initWithFormat:aCondition
                                               arguments:data.mutableBytes];
...

In the other project the crash is in

//sqlite3_unicode.c file
...
/*
** <sqlite3_unicode>
** The following function is the default entry point of an SQlite extension built as a
** dynamically linked library. On calling sqlite3_load_extension() sqlite3 will call
** this function to initialise unicode functionality.
*/
#ifndef SQLITE_CORE
SQLITE_EXPORT int sqlite3_extension_init(
  sqlite3 *db, 
  char **pzErrMsg,
  const sqlite3_api_routines *pApi
){
  SQLITE_EXTENSION_INIT2(pApi)
  return sqlite3_unicode_init(db); // crashes here
}
#endif

Please let me know if any of them do reproduce on your station as well. Thank you in advance!

dumoko avatar Jan 02 '14 12:01 dumoko

Also found this issue with iActiveRecord under 64-bit. Removing the architecture from Build Settings temporarily solved the problem.

nicorsm avatar Mar 31 '14 08:03 nicorsm

did you manage to overcome this? looks like there is no support for 64-bit at all ?

tevch avatar Nov 15 '14 20:11 tevch

Possibly dirty fix:

NSString* result = aCondition;

for (int i = 0; i < sqlArguments.count; i++) {
    NSRange range = [result rangeOfString:@"%@"];
    result = [result stringByReplacingCharactersInRange:range withString:[sqlArguments objectAtIndex:i]];
}

joshuatam avatar Nov 19 '14 09:11 joshuatam

Nice joshuatam, thank you, helped

tevch avatar Nov 19 '14 13:11 tevch

Thanks @joshuatam! I think this is a slightly less dirty version of the fix:

    NSString* result = aCondition;
    NSRange testRange = NSMakeRange(0, result.length);

    for (int i = 0; i < sqlArguments.count; i++) {
        NSRange range = [result rangeOfString:@"%@" options:NSLiteralSearch range:testRange];
        result = [result stringByReplacingCharactersInRange:range withString:[sqlArguments objectAtIndex:i]];

        //move the test range up to the last character of the replacement to prevent hitting
        //literal %@ in the args
        NSUInteger prefix = range.location + [[sqlArguments objectAtIndex:i] length];
        testRange = NSMakeRange(prefix, result.length - prefix);
    }

mgod avatar Nov 21 '14 19:11 mgod

Thanks. Can anyone make a pull request for it?

paulocoutinhox avatar Feb 09 '15 21:02 paulocoutinhox

I have created a pull request to fix it based on "mgod" version. It is working now.

paulocoutinhox avatar Feb 09 '15 21:02 paulocoutinhox

Can you merge pls: https://github.com/AlexDenisov/iActiveRecord/pull/91

paulocoutinhox avatar May 21 '15 18:05 paulocoutinhox