Skip to content
This repository has been archived by the owner on Nov 25, 2019. It is now read-only.

Crash on x64 architecture #69

Open
dumoko opened this issue Jan 2, 2014 · 8 comments
Open

Crash on x64 architecture #69

dumoko opened this issue Jan 2, 2014 · 8 comments

Comments

@dumoko
Copy link

dumoko commented Jan 2, 2014

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!

@nicorsm
Copy link

nicorsm commented Mar 31, 2014

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

@tevch
Copy link

tevch commented Nov 15, 2014

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

@joshuatam
Copy link

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]];
}

@tevch
Copy link

tevch commented Nov 19, 2014

Nice joshuatam, thank you, helped

@mgod
Copy link
Contributor

mgod commented Nov 21, 2014

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);
    }

@paulocoutinhox
Copy link
Contributor

Thanks.
Can anyone make a pull request for it?

@paulocoutinhox
Copy link
Contributor

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

@paulocoutinhox
Copy link
Contributor

Can you merge pls:
#91

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

No branches or pull requests

6 participants