ASIHTTPRequest crashes on iOS 3.1.3

179 views
Skip to first unread message

Dimitrios

unread,
Aug 4, 2011, 4:59:24 PM8/4/11
to ASIHTTPRequest
Hello,

My app crashes as soon as I call [[ASIHTTPRequest alloc]
initWithURL:url]; on my iPod Touch 1G (iOS 3.1.3). It has no issue on
iOS 4.x.

The error I see is Error Domain=ASIHTTPRequestErrorDomain Code=10
UserInfo=0x368790 "NSRangeException"

and the backtrace I get from a crash manager system I have implemented
is

backtrace: (
"0 MayasDUp 0x0007f21b -[SWCrashManager
backtrace] + 18",
"1 MayasDUp 0x0007ece1 sighandler + 144",
"2 libSystem.B.dylib 0x3049e7eb _sigtramp + 26",
"3 MayasDUp 0x0005128b -[ASIHTTPRequest
buildPostBody] + 850"

)

Digging a bit deeper showed that the issue comes from an [NSArray
objectAtIndex:] call, where it tries to access [6] but the length is
4. I placed NSLogs before every call inside the ASIHTTPRequest class,
but there was no array accessing such an index.

The buildPostBody method executes fully (checked via breakpoints and
NSLogs), the crash happens afterwards.
In iOS 4.x the exact same code with the same url parameter causes no
issue.

After several hours, I have absolutely no clue on what might be
happening. I'd appreciate any insight!

pokeb

unread,
Aug 7, 2011, 4:21:20 AM8/7/11
to asihttp...@googlegroups.com
Hi
If you run in the debugger with break on exceptions turned on (If you're in Xcode 4, go to the breakpoints tab, add an Exception breakpoint if you haven't got one already), where does execution stop?

Best

Ben

Dimitrios

unread,
Aug 23, 2011, 1:49:47 PM8/23/11
to ASIHTTPRequest
Hi Ben,

Thank you for your reply. I was without Internet access for 2 weeks,
sorry for not replying earlier.

The app crashes at a "random" spot, inside a drewRect: function of a
game's sprite. The breakpoints
do not provide any other information, unfortunately.

In the meantime I noticed some debug calls inside the ASI classes and
I enabled the DEBUG_REQUEST_STATUS macro,
which gave the following console output:

[STATUS] Starting asynchronous request <ASIFormDataRequest: 0x81f800>
void SendDelegateMessage(NSInvocation*): delegate (--??--) failed to
return after waiting 10 seconds. main run loop mode:
kCFRunLoopDefaultMode

I searched online for this type of error a lot, but couldn't find
anything useful. The code execution is on the main thread, the crash
happens on another thread.

Unfortunately I cannot reproduce this message again, so I don't recall
what was at the (--??--) place-holder above.

Any ideas?

Dimitrios

unread,
Aug 23, 2011, 2:11:10 PM8/23/11
to ASIHTTPRequest
Found the full message:

void SendDelegateMessage(NSInvocation*): delegate
(<CFNotificationCenter 0x5e199c0 [0x1a6a3e0]>) failed to return after

Dimitrios

unread,
Sep 6, 2011, 4:26:08 AM9/6/11
to ASIHTTPRequest
At last, I was able to find out what was happening. It was all due to
a compiler bug.

[DESCRIPTION]
The bug occurs on iOS 3.x (tested on our iPod Touch 1G).
The requirements for this to happen are:
i) Use the ASIHTTPRequest library
ii) Use the LLVM 2.0 compiler
iii) Use optimised code (anything other than None (-O0) in
Optimization Level

The application crashes when trying to make an http request. There is
no stack trace available
and the program may crash on random points in code.

[EXPLANATION]
This is a bug of Apple's compiler. When optimising the code of the
ASIHTTPRequest library files
under these settings, it gets them corrupted and they cannot execute
properly.

[SOLUTION]
There are numerous solutions to this issue.

The one we applied was to set a -O0 Compiler Flag in the 2 files that
caused the issue,
namely ASIHTTPRequest and ASIFormDataRequest (Build Phases > Compile
Sources > Compiler Flags column),
while keeping both the LLVM 2.0 compiler and -Os optimisation level in
the project's global settings.
This excludes the 2 files from the optimisation and their code does
not get corrupted.

Alternatives:
i) Use XCode 4.0.2 or greater (issue was fixed)
ii) Set -O0 optimisation level for ARMv6 only

[RESOURCES]
https://groups.google.com/group/asihttprequest/browse_thread/thread/7f0ecf0dc0f6c0a2
http://stackoverflow.com/questions/5490432/building-with-llvm-and-any-optimization-causes-app-to-crash-on-startup


Reply all
Reply to author
Forward
0 new messages