[Soot-list] Problems with nested try..catch..finally?

Eric Bodden bodden at st.informatik.tu-darmstadt.de
Fri Oct 9 10:28:09 EDT 2009


> Actually, the code is using jsr instructions.

That's too bad because I have to try to remember again how JSRs work
;-) JSRs are actually a thing from the past and, from what I know,
they were basically already eliminated by most compilers when I
started working with Soot.

> See the byte code and source
> code below, nothing exceptionally complex, I suppose.
> Does this extract provide enough information to implement a bugfix? It would
> be great!

It would be very helpful to have the actual code in binary format,
along with a description of how exactly you run Soot, i.e., the
command-line parameters that you use.

Eric

>
> Best regards
>
> Attila
>
>
> public static boolean isPackageManufactured(java.lang.String workitemId,
> java.lang.String activityId, java.lang.String packageName);
>      0  new com.documentum.fc.common.DfId [16]
>      3  dup
>      4  aload_0 [workitemId]
>      5  invokespecial com.documentum.fc.common.DfId(java.lang.String) [17]
>      8  astore_3 [workitemIdObj]
>      9  iconst_0
>     10  istore 4 [bNeedScopeChange]
>     12  invokestatic
> com.documentum.web.formext.session.SessionManagerHttpBinding.getSessionManag
> er() : com.documentum.fc.client.IDfSessionManager [2]
>     15  astore 5 [sessionManager]
>     17  aconst_null
>     18  astore 6 [dfSession]
>     20  aconst_null
>     21  astore 7 [coll]
>     23  aload 5 [sessionManager]
>     25  invokestatic
> com.documentum.web.formext.session.SessionManagerHttpBinding.getCurrentDocba
> se() : java.lang.String [3]
>     28  invokeinterface
> com.documentum.fc.client.IDfSessionManager.getSession(java.lang.String) :
> com.documentum.fc.client.IDfSession [4] [nargs: 2]
>     33  astore 6 [dfSession]
>     35  aload 6 [dfSession]
>     37  invokeinterface
> com.documentum.fc.client.IDfSession.getDocbaseScope() : java.lang.String
> [46] [nargs: 1]
>     42  astore 8 [originalDocbaseScope]
>     44  aload_3 [workitemIdObj]
>     45  invokestatic
> com.documentum.web.formext.session.DocbaseUtils.getDocbaseNameFromId(com.doc
> umentum.fc.common.IDfId) : java.lang.String [47]
>     48  aload 8 [originalDocbaseScope]
>     50  invokevirtual java.lang.String.equals(java.lang.Object) : boolean
> [22]
>     53  ifne 60
>     56  iconst_1
>     57  goto 61
>     60  iconst_0
>     61  istore 4 [bNeedScopeChange]
>     63  invokestatic com.documentum.web.util.DfcUtils.getClientX() :
> com.documentum.com.IDfClientX [48]
>     66  invokeinterface com.documentum.com.IDfClientX.getQuery() :
> com.documentum.fc.client.IDfQuery [49] [nargs: 1]
>     71  astore 9 [query]
>     73  new java.lang.StringBuffer [50]
>     76  dup
>     77  sipush 160
>     80  invokespecial java.lang.StringBuffer(int) [51]
>     83  astore 10 [buf]
>     85  aload 10 [buf]
>     87  ldc <String "SELECT r_package_name FROM dm_portinfo WHERE
> r_object_id='"> [52]
>     89  invokevirtual java.lang.StringBuffer.append(java.lang.String) :
> java.lang.StringBuffer [53]
>     92  aload_1 [activityId]
>     93  invokevirtual java.lang.StringBuffer.append(java.lang.String) :
> java.lang.StringBuffer [53]
>     96  ldc <String "' AND r_package_name='"> [54]
>     98  invokevirtual java.lang.StringBuffer.append(java.lang.String) :
> java.lang.StringBuffer [53]
>    101  aload_2 [packageName]
>    102  invokestatic
> com.documentum.webcomponent.library.workflow.WorkflowUtil.escapeQuotedString
> (java.lang.String) : java.lang.String [55]
>    105  invokevirtual java.lang.StringBuffer.append(java.lang.String) :
> java.lang.StringBuffer [53]
>    108  ldc <String "' AND r_port_type='INPUT'"> [56]
>    110  invokevirtual java.lang.StringBuffer.append(java.lang.String) :
> java.lang.StringBuffer [53]
>    113  pop
>    114  aload 9 [query]
>    116  aload 10 [buf]
>    118  invokevirtual java.lang.StringBuffer.toString() : java.lang.String
> [57]
>    121  invokeinterface
> com.documentum.fc.client.IDfQuery.setDQL(java.lang.String) : void [58]
> [nargs: 2]
>    126  aload 9 [query]
>    128  aload 6 [dfSession]
>    130  iconst_0
>    131  invokeinterface
> com.documentum.fc.client.IDfQuery.execute(com.documentum.fc.client.IDfSessio
> n, int) : com.documentum.fc.client.IDfCollection [59] [nargs: 3]
>    136  astore 7 [coll]
>    138  aload 7 [coll]
>    140  invokeinterface com.documentum.fc.client.IDfCollection.next() :
> boolean [60] [nargs: 1]
>    145  ifne 152
>    148  iconst_1
>    149  goto 153
>    152  iconst_0
>    153  istore 11
>    155  jsr 183
>    158  iload 11
>    160  ireturn
>    161  astore 8 [dfe]
>    163  new com.documentum.web.common.WrapperRuntimeException [24]
>    166  dup
>    167  ldc <String "Failed to read package name"> [61]
>    169  aload 8 [dfe]
>    171  invokespecial
> com.documentum.web.common.WrapperRuntimeException(java.lang.String,
> java.lang.Throwable) [43]
>    174  athrow
>    175  astore 12
>    177  jsr 183
>    180  aload 12
>    182  athrow
>    183  astore 13
>    185  aload 7 [coll]
>    187  ifnull 197
>    190  aload 7 [coll]
>    192  invokeinterface com.documentum.fc.client.IDfCollection.close() :
> void [62] [nargs: 1]
>    197  jsr 225
>    200  goto 295
>    203  astore 14 [dfe2]
>    205  new com.documentum.web.common.WrapperRuntimeException [24]
>    208  dup
>    209  ldc <String "Failed to close collection"> [63]
>    211  aload 14 [dfe2]
>    213  invokespecial
> com.documentum.web.common.WrapperRuntimeException(java.lang.String,
> java.lang.Throwable) [43]
>    216  athrow
>    217  astore 15
>    219  jsr 225
>    222  aload 15
>    224  athrow
>    225  astore 16
>    227  aload 6 [dfSession]
>    229  ifnull 293
>    232  iload 4 [bNeedScopeChange]
>    234  iconst_1
>    235  if_icmpne 247
>    238  aload 6 [dfSession]
>    240  aload_3 [workitemIdObj]
>    241  invokeinterface
> com.documentum.fc.client.IDfSession.setDocbaseScopeById(com.documentum.fc.co
> mmon.IDfId) : java.lang.String [64] [nargs: 2]
>    246  pop
>    247  jsr 275
>    250  goto 293
>    253  astore 17 [dfe3]
>    255  new com.documentum.web.common.WrapperRuntimeException [24]
>    258  dup
>    259  ldc <String "Failed to set docbase scope"> [65]
>    261  aload 17 [dfe3]
>    263  invokespecial
> com.documentum.web.common.WrapperRuntimeException(java.lang.String,
> java.lang.Throwable) [43]
>    266  athrow
>    267  astore 18
>    269  jsr 275
>    272  aload 18
>    274  athrow
>    275  astore 19
>    277  aload 6 [dfSession]
>    279  ifnull 291
>    282  aload 5 [sessionManager]
>    284  aload 6 [dfSession]
>    286  invokeinterface
> com.documentum.fc.client.IDfSessionManager.release(com.documentum.fc.client.
> IDfSession) : void [7] [nargs: 2]
>    291  ret 19
>    293  ret 16
>    295  ret 13
>      Exception Table:
>        [pc: 23, pc: 158] -> 161 when : com.documentum.fc.common.DfException
>        [pc: 23, pc: 158] -> 175 when : any
>        [pc: 161, pc: 180] -> 175 when : any
>        [pc: 185, pc: 197] -> 203 when :
> com.documentum.fc.common.DfException
>        [pc: 185, pc: 200] -> 217 when : any
>        [pc: 203, pc: 222] -> 217 when : any
>        [pc: 232, pc: 247] -> 253 when :
> com.documentum.fc.common.DfException
>        [pc: 232, pc: 250] -> 267 when : any
>        [pc: 253, pc: 272] -> 267 when : any
>      Line numbers:
>        [pc: 0, line: 739]
>        [pc: 9, line: 740]
>        [pc: 12, line: 741]
>        [pc: 17, line: 743]
>        [pc: 20, line: 744]
>        [pc: 23, line: 747]
>        [pc: 35, line: 751]
>        [pc: 44, line: 754]
>        [pc: 63, line: 757]
>        [pc: 73, line: 758]
>        [pc: 85, line: 759]
>        [pc: 114, line: 764]
>        [pc: 126, line: 766]
>        [pc: 138, line: 768]
>        [pc: 161, line: 771]
>        [pc: 163, line: 773]
>        [pc: 175, line: 777]
>        [pc: 185, line: 780]
>        [pc: 190, line: 782]
>        [pc: 197, line: 784]
>        [pc: 200, line: 815]
>        [pc: 203, line: 785]
>        [pc: 205, line: 787]
>        [pc: 217, line: 792]
>        [pc: 232, line: 796]
>        [pc: 238, line: 800]
>        [pc: 247, line: 802]
>        [pc: 250, line: 813]
>        [pc: 253, line: 803]
>        [pc: 255, line: 805]
>        [pc: 267, line: 809]
>        [pc: 282, line: 811]
>      Local variable table:
>        [pc: 44, pc: 161] local: originalDocbaseScope index: 8 type:
> java.lang.String
>        [pc: 73, pc: 161] local: query index: 9 type:
> com.documentum.fc.client.IDfQuery
>        [pc: 85, pc: 161] local: buf index: 10 type: java.lang.StringBuffer
>        [pc: 163, pc: 175] local: dfe index: 8 type:
> com.documentum.fc.common.DfException
>        [pc: 205, pc: 217] local: dfe2 index: 14 type:
> com.documentum.fc.common.DfException
>        [pc: 255, pc: 267] local: dfe3 index: 17 type:
> com.documentum.fc.common.DfException
>        [pc: 0, pc: 297] local: workitemId index: 0 type: java.lang.String
>        [pc: 0, pc: 297] local: activityId index: 1 type: java.lang.String
>        [pc: 0, pc: 297] local: packageName index: 2 type: java.lang.String
>        [pc: 9, pc: 297] local: workitemIdObj index: 3 type:
> com.documentum.fc.common.DfId
>        [pc: 12, pc: 297] local: bNeedScopeChange index: 4 type: boolean
>        [pc: 17, pc: 297] local: sessionManager index: 5 type:
> com.documentum.fc.client.IDfSessionManager
>        [pc: 20, pc: 297] local: dfSession index: 6 type:
> com.documentum.fc.client.IDfSession
>        [pc: 23, pc: 297] local: coll index: 7 type:
> com.documentum.fc.client.IDfCollection
>
>
>
> /*      */   public static boolean isPackageManufactured(String workitemId,
> String activityId, String packageName)
> /*      */   {
> /*  739 */     DfId workitemIdObj = new DfId(workitemId);
> /*  740 */     boolean bNeedScopeChange = false;
> /*  741 */     IDfSessionManager sessionManager =
> SessionManagerHttpBinding.getSessionManager();
> /*      */
> /*  743 */     IDfSession dfSession = null;
> /*  744 */     IDfCollection coll = null;
> /*      */     try
> /*      */     {
> /*  747 */       dfSession =
> sessionManager.getSession(SessionManagerHttpBinding.getCurrentDocbase());
> /*      */
> /*  751 */       String originalDocbaseScope = dfSession.getDocbaseScope();
> /*      */
> /*  754 */       bNeedScopeChange =
> !(DocbaseUtils.getDocbaseNameFromId(workitemIdObj).equals(originalDocbaseSco
> pe));
> /*      */
> /*  757 */       IDfQuery query = DfcUtils.getClientX().getQuery();
> /*  758 */       StringBuffer buf = new StringBuffer(160);
> /*  759 */       buf.append("SELECT r_package_name FROM dm_portinfo WHERE
> r_object_id='").append(activityId).append("' AND
> _package_name='").append(WorkflowUtil.escapeQuotedString(packageName)).appen
> d("' AND r_port_type='INPUT'");
> /*      */
> /*  764 */       query.setDQL(buf.toString());
> /*      */
> /*  766 */       coll = query.execute(dfSession, 0);
> /*      */
> /*  768 */       return ((!(coll.next())) ? 1 : 0);
> /*      */     }
> /*      */     catch (DfException dfe)
> /*      */     {
> /*  773 */       throw new WrapperRuntimeException("Failed to read package
> name", dfe);
> /*      */     }
> /*      */     finally
> /*      */     {
> /*      */       try
> /*      */       {
> /*  780 */         if (coll != null)
> /*      */         {
> /*  782 */           coll.close();
> /*      */         }
> /*      */       }
> /*      */       catch (DfException dfe2)
> /*      */       {
> /*  787 */         throw new WrapperRuntimeException("Failed to close
> collection", dfe2);
> /*      */       }
> /*      */       finally
> /*      */       {
> /*  792 */         if (dfSession != null)
> /*      */         {
> /*      */           try
> /*      */           {
> /*  796 */             if (bNeedScopeChange == true)
> /*      */             {
> /*  800 */               dfSession.setDocbaseScopeById(workitemIdObj);
> /*      */             }
> /*      */           }
> /*      */           catch (DfException dfe3)
> /*      */           {
> /*  805 */             throw new WrapperRuntimeException("Failed to set
> docbase scope", dfe3);
> /*      */           }
> /*      */           finally
> /*      */           {
> /*  809 */             if (dfSession != null)
> /*      */             {
> /*  811 */               sessionManager.release(dfSession);
> /*      */             }
> /*      */           }
> /*      */         }
> /*      */       }
> /*      */     }
> /*      */   }
>
>
>
> -----Original Message-----
> From: eric.bodden at googlemail.com [mailto:eric.bodden at googlemail.com] On
> Behalf Of Eric Bodden
> Sent: Freitag, 9. Oktober 2009 13:15
> To: Attila Bartha
> Cc: soot-list at sable.mcgill.ca
> Subject: [?? Probable Spam] Re: [Soot-list] Problems with nested
> try..catch..finally?
>
> Hi Attila.
>
>> Are there any known issues and limitations with regards to Exception
>> handling?
>
> Not that I am aware of. Coffi has been one of the most stable
> components of Soot for as long as I can tell. It be really helpful to
> see the bytecode that causes this problem. Are you sure that it's
> legal bytecode, i.e., can you run it?
>
>> 1.       Is there a quick fix for this problem?
>
> I could add a check to the CFG class so that the constructor does not
> execute eliminateJsrRets() if there are no JSRs in the first place. (I
> am 99% sure that your code contains no JSRs, they have become very
> rare.) However, that would only cure the symptoms, not fix the
> problem.
>
>> 2.       Is it possible to skip or replace the call of
>> soot.coffi.CFG.eliminateJsrRets()?
>
> Well, yes, see above, but there's no command line option for skipping it.
>
>> 3.       Why does dava not generate finally blocks? It generates another
>> try..catch instead.
>
> Java uses certain heuristics to try to identify source-code patterns
> like "finally" in bytecode. Heuristics can fail. Having said that, I
> am not even sure if there is a heuristic for "finally" in dava. In any
> case, dava should hopefully generate at least correct code, even if
> that ocde is sometimes far from the original.
>
> Eric
>
> --
> Eric Bodden
> Software Technology Group, Technische Universität Darmstadt, Germany
> Tel: +49 6151 16-5478    Fax: +49 6151 16-5410
> Mailing Address: S2|02 A209, Hochschulstraße 10, 64289 Darmstadt
>
>



-- 
Eric Bodden
Software Technology Group, Technische Universität Darmstadt, Germany
Tel: +49 6151 16-5478    Fax: +49 6151 16-5410
Mailing Address: S2|02 A209, Hochschulstraße 10, 64289 Darmstadt


More information about the Soot-list mailing list