Cookie manager causing fatal signal 11
Asked Answered
D

3

12

My app silently crashes (no force close popup) when i try to set a cookie on the cookiemanager.

mHttpClient.getParams().setBooleanParameter(ClientPNames.HANDLE_REDIRECTS, false);
HttpGet http_get = new HttpGet(url); 
HttpResponse response = mHttpClient.execute(http_get);

for(Cookie cookie : mHttpClient.getCookieStore().getCookies()) {

    Log.d(AppPreferences.TESTTAG,"cookie =  " + cookie.getName());
    if(cookie.getName().equals("SACSID") || cookie.getName().equals("ACSID"))
    {
        response.getEntity().consumeContent();
        String cookieString = cookie.getName() + "=" + cookie.getValue() + "; domain=" + cookie.getDomain();  
        CookieManager.getInstance().setCookie(cookie.getDomain(), cookieString); //**crashes here**
        return true;
    }                   
}

Here's all i'm getting from logcat

04-19 22:51:35.277: W/dalvikvm(16704): Invalid indirect reference 0x414bb040 in decodeIndirectRef
04-19 22:51:35.277: E/dalvikvm(16704): VM aborting
04-19 22:51:35.281: A/libc(16704): Fatal signal 11 (SIGSEGV) at 0xdeadd00d (code=1), thread 16754 (AsyncTask #1)

Here's the tombstone log generated: http://textuploader.com/?p=6&id=gPpJ

It fails right on the CookieManager setCookie() line (i.e. I log a message before and after that line it prints the before message but not the one after)

Anyone run in to this problem?

Deherrera answered 19/4, 2013 at 15:14 Comment(0)
I
27

Add CookieSyncManager.createInstance(context); before calling CookieManager.

Impersonate answered 9/6, 2013 at 14:39 Comment(2)
without this my app was crashing on JellybeanPropriety
CookieSyncManager is now deprecated as of Android SDK 21. developer.android.com/reference/android/webkit/…Inhale
A
2

Try to create WebView in onCreate() method and destroy it. WebView create some "bridge" between ContentManager and WebKit. Some thing like this:

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_layout);
    WebView web = new WebView(this);
    web.destroy();
}
Alithia answered 26/11, 2013 at 10:6 Comment(0)
M
0

If you are completely certain that this crash is triggered by the code you have above, this represents a firmware bug. There's no way an Android SDK app should be able to trigger a SIGSEGV.

If this occurs on a Nexus device, on the emulator, or across multiple devices, it is probably an Android bug. File an issue on http://b.android.com (if there doesn't appear to be one already), pointing to this issue and probably attaching that tombstone log.

If this occurs only in some specific setting (e.g., one device, one ROM mod) and not others, it is probably something peculiar to that environment, in which case you should try to get help from the device or ROM mod maker.

Beyond that, make sure that cookie.getDomain() is returning a valid value, as, off the cuff, that seems like the most likely culprit.

Morava answered 19/4, 2013 at 15:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.