6

UiLifecycleHelper から奇妙な StackOverflow エラーが発生します。シリアル化されたオブジェクトを読み込もうとしているように見えますが、おそらくデータの破損が原因で、ObjectInputStream が再帰ループに陥っています。onCreate メソッドでのみ発生します。ここにスタックトレースがあります

アップデート

StackOverflowError は実際には onSaveInstance 状態でも発生しますが、ObjectStream 書き込みでループします。ただし、これを示すクラッシュ ログは 4 つしかなく、onCreate での読み取りに関する 49 のクラッシュ ログがあります。使用されているコードは次のとおりです。

uiHelper は、想定されるすべてのメソッド onCreate、onResume、onPause、onSaveInstanceState、onDestroy で呼び出され、ドキュメントからまったく逸脱することはありません。使用された他のすべての Facebook コードを以下に示します。

//onClick facebook button
private void facebook() {
    Session session = Session.getActiveSession();
    if (session != null && session.isOpened()) {
        Log.v("W", "Already have session");
        publishog(session);
    } else {

        Session.openActiveSession(WWhisperActivity.this, true, callback);
    }
}

private void onSessionStateChange(Session session, SessionState state,
        Exception e) {
    if (e != null && !e.getLocalizedMessage().contains("user denied")) {
        BugSenseHandler.sendException(e);
    }
    if (state.equals(SessionState.OPENING)) {
        Log.v("W", "Session opening state");
    } else if (state.equals(SessionState.CREATED)
            || state.equals(SessionState.CREATED_TOKEN_LOADED)) {
        Log.v("W", "Session created state");
    }
    if (state.isOpened()) {
        Log.v("W", "Open session");
        if (!session.getPermissions().contains("publish_actions")) {
            Log.v("W", "Getting publish permission");
            Session.NewPermissionsRequest r = new Session.NewPermissionsRequest(
                    this, Arrays.asList("publish_actions"));
            session.requestNewPublishPermissions(r);
        } else {
            Log.v("W", "Session opened, publishing og");
            publishog(session);
        }
    } else if (state.equals(SessionState.CLOSED)
            || state.equals(SessionState.CLOSED_LOGIN_FAILED)) {
        Log.v("W", "Session not open");
        session.closeAndClearTokenInformation();
        if (state.equals(SessionState.CLOSED_LOGIN_FAILED)) {
            if (e == null || !e.getLocalizedMessage().contains("abort")
                    && !e.getLocalizedMessage().contains("user denied"))
                Session.openActiveSession(this, true, callback);
        }
    }
}

private void publishog(Session session) {
    Log.v("W", "Publishing OG");
    WObject wo = GraphObject.Factory.create(WObject.class);
    wo.setId(w.wid);
    wo.setUrl(shorturl);
    WOGShare ws = GraphObject.Factory.create(WOGShare.class);
    ws.setWhisper(shorturl);
    com.facebook.Request.executePostRequestAsync(session,
            "me/whisper_app:share", ws,
            new com.facebook.Request.Callback() {

                @Override
                public void onCompleted(Response response) {
                    pd.dismiss();
                    if (response.getError() != null) {

                    } else {

                    }

                }

            });
}

クラッシュログ:

java.lang.StackOverflowError
1at java.lang.ThreadLocal.get(ThreadLocal.java:65)
2at java.io.ObjectStreamClass.getCache(ObjectStreamClass.java:1093)
3at java.io.ObjectStreamClass.lookupStreamClass(ObjectStreamClass.java:1066)
4at java.io.ObjectStreamClass.lookup(ObjectStreamClass.java:1037)
5at java.io.ObjectStreamClass.createClassDesc(ObjectStreamClass.java:248)
6at java.io.ObjectStreamClass.lookupStreamClass(ObjectStreamClass.java:1069)
7at java.io.ObjectStreamClass.lookup(ObjectStreamClass.java:1037)
8at java.io.ObjectStreamClass.createClassDesc(ObjectStreamClass.java:248)
9at java.io.ObjectStreamClass.lookupStreamClass(ObjectStreamClass.java:1069)
10at java.io.ObjectStreamClass.lookup(ObjectStreamClass.java:1037)
11at java.io.ObjectStreamClass.createClassDesc(ObjectStreamClass.java:248)
12at java.io.ObjectStreamClass.lookupStreamClass(ObjectStreamClass.java:1069)
13at java.io.ObjectInputStream.verifyAndInit(ObjectInputStream.java:2375)
14at java.io.ObjectInputStream.readNewClassDesc(ObjectInputStream.java:1662)
15at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:683)
16at java.io.ObjectInputStream.readNewObject(ObjectInputStream.java:1803)
17at java.io.ObjectInputStream.readNonPrimitiveContent(ObjectInputStream.java:787)
18at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2003)
19at java.io.ObjectInputStream.readObject(ObjectInputStream.java:1960)
20at java.io.ObjectInputStream.readFieldValues(ObjectInputStream.java:1137)
21at java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:455)
22at java.io.ObjectInputStream.readObjectForClass(ObjectInputStream.java:1369)
23at java.io.ObjectInputStream.readHierarchy(ObjectInputStream.java:1266)
24at java.io.ObjectInputStream.readNewObject(ObjectInputStream.java:1855)
25at java.io.ObjectInputStream.readNonPrimitiveContent(ObjectInputStream.java:787)
26at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2003)
27at java.io.ObjectInputStream.readObject(ObjectInputStream.java:1960)
28at java.io.ObjectInputStream.readFieldValues(ObjectInputStream.java:1137)
29at java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:455)
30at java.io.ObjectInputStream.readObjectForClass(ObjectInputStream.java:1369)
31at java.io.ObjectInputStream.readHierarchy(ObjectInputStream.java:1266)
32at java.io.ObjectInputStream.readNewObject(ObjectInputStream.java:1855)
33at java.io.ObjectInputStream.readNonPrimitiveContent(ObjectInputStream.java:787)
34at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2003)
35at java.io.ObjectInputStream.readObject(ObjectInputStream.java:1960)
36at java.io.ObjectInputStream.readFieldValues(ObjectInputStream.java:1137)
37at java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:455)
38at java.io.ObjectInputStream.readObjectForClass(ObjectInputStream.java:1369)
39at java.io.ObjectInputStream.readHierarchy(ObjectInputStream.java:1266)
40at java.io.ObjectInputStream.readNewObject(ObjectInputStream.java:1855)
41at java.io.ObjectInputStream.readNonPrimitiveContent(ObjectInputStream.java:787)
42at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2003)
43at java.io.ObjectInputStream.readObject(ObjectInputStream.java:1960)
44at java.io.ObjectInputStream.readFieldValues(ObjectInputStream.java:1137)
45at java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:455)
46at java.io.ObjectInputStream.readObjectForClass(ObjectInputStream.java:1369)
47at java.io.ObjectInputStream.readHierarchy(ObjectInputStream.java:1266)
48at java.io.ObjectInputStream.readNewObject(ObjectInputStream.java:1855)
49at java.io.ObjectInputStream.readNonPrimitiveContent(ObjectInputStream.java:787)
50at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2003)
51at java.io.ObjectInputStream.readObject(ObjectInputStream.java:1960)
52at java.io.ObjectInputStream.readFieldValues(ObjectInputStream.java:1137)
53at java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:455)
54at java.io.ObjectInputStream.readObjectForClass(ObjectInputStream.java:1369)
55at java.io.ObjectInputStream.readHierarchy(ObjectInputStream.java:1266)
56at java.io.ObjectInputStream.readNewObject(ObjectInputStream.java:1855)
57at java.io.ObjectInputStream.readNonPrimitiveContent(ObjectInputStream.java:787)
58at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2003)
59at java.io.ObjectInputStream.readObject(ObjectInputStream.java:1960)
60at java.io.ObjectInputStream.readFieldValues(ObjectInputStream.java:1137)
61at java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:455)
62at java.io.ObjectInputStream.readObjectForClass(ObjectInputStream.java:1369)
63at java.io.ObjectInputStream.readHierarchy(ObjectInputStream.java:1266)
64at java.io.ObjectInputStream.readNewObject(ObjectInputStream.java:1855)
65at java.io.ObjectInputStream.readNonPrimitiveContent(ObjectInputStream.java:787)
66at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2003)
67at java.io.ObjectInputStream.readObject(ObjectInputStream.java:1960)
68at java.io.ObjectInputStream.readFieldValues(ObjectInputStream.java:1137)
69at java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:455)
70at java.io.ObjectInputStream.readObjectForClass(ObjectInputStream.java:1369)
71at java.io.ObjectInputStream.readHierarchy(ObjectInputStream.java:1266)
72at java.io.ObjectInputStream.readNewObject(ObjectInputStream.java:1855)
73at java.io.ObjectInputStream.readNonPrimitiveContent(ObjectInputStream.java:787)
74at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2003)
75at java.io.ObjectInputStream.readObject(ObjectInputStream.java:1960)
76at java.io.ObjectInputStream.readFieldValues(ObjectInputStream.java:1137)
77at java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:455)
78at java.io.ObjectInputStream.readObjectForClass(ObjectInputStream.java:1369)
79at java.io.ObjectInputStream.readHierarchy(ObjectInputStream.java:1266)
325at java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:455)
326at java.io.ObjectInputStream.readObjectForClass(ObjectInputStream.java:1369)
327at java.io.ObjectInputStream.readHierarchy(ObjectInputStream.java:1266)
328at java.io.ObjectInputStream.readNewObject(ObjectInputStream.java:1855)
329at java.io.ObjectInputStream.readNonPrimitiveContent(ObjectInputStream.java:787)
330at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2003)
331at java.io.ObjectInputStream.readObject(ObjectInputStream.java:1960)
332at com.facebook.Session.restoreSession(Session.java:701)
333at com.facebook.UiLifecycleHelper.onCreate(UiLifecycleHelper.java:70)
334at sh.whisper.WWhisperActivity.onCreate(WWhisperActivity.java:279)
335at android.app.Activity.performCreate(Activity.java:5160)
336at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
337at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2074)
338at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135)
339at android.app.ActivityThread.access$700(ActivityThread.java:143)
340at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1241)
341at android.os.Handler.dispatchMessage(Handler.java:99)
342at android.os.Looper.loop(Looper.java:137)
343at android.app.ActivityThread.main(ActivityThread.java:4953)
344at java.lang.reflect.Method.invokeNative(Native Method)
345at java.lang.reflect.Method.invoke(Method.java:511)
346at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1004)
347at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:771)

348at dalvik.system.NativeStart.main(Native Method)
4

1 に答える 1

1

パラメーターとローカル変数はスタックに割り当てられます (参照型を使用すると、オブジェクトはヒープ上に存在し、変数はそのオブジェクトを参照します)。スタックは通常、アドレス空間の上端に存在し、使い尽くされると、アドレス空間の底 (つまりゼロ) に向かいます。

GUI プログラミングでは、間接再帰を生成できます。たとえば、アプリがペイント メッセージを処理していて、それらの処理中に、システムに別のペイント メッセージを送信させる関数を呼び出す場合があります。ここでは、明示的に自分自身を呼び出していませんが、OS/VM が呼び出しています。

前に同じエラーが発生しました。クラスのすぐ下にある初期化を削除して、onCreate()または内に移動するだけonResume()です。

于 2013-06-13T18:05:13.063 に答える