[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Review Request 110027: kjs: Don't crash if code in with-statement causes a "pre"-exception
From:       "Bernd Buschinski" <b.buschinski () googlemail ! com>
Date:       2013-04-15 15:44:53
Message-ID: 20130415154453.19543.16048 () vidsolbach ! de
[Download RAW message or body]

-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://git.reviewboard.kde.org/r/110027/
-----------------------------------------------------------

Review request for kdelibs.


Description
-------

For js code like:
with({}) { with({}) { with({}) { import x.x; }  }  }

the import statement can cause an exception, the import-exception is generated (but \
not fired) before it executes the other code. The With-statement has 2 operations to \
push and pop the new scope it should be used with. As the pre-generated Exception is \
already present, PushScope checks that and does not Push a new Scope. But PopScope \
does not check that, and tries to pop, which leads us to a crash. The Scope should be \
cleared by the Exceptionhandler on exception case, and PopScope should do nothing.

NOTE: I must admit I am unsure if this is the best solution, a review by a \
experienced kjs developer would be super helpful


This addresses bugs 311512 and 311513.
    http://bugs.kde.org/show_bug.cgi?id=311512
    http://bugs.kde.org/show_bug.cgi?id=311513


Diffs
-----

  kjs/bytecode/codes.def 59fea6c 

Diff: http://git.reviewboard.kde.org/r/110027/diff/


Testing
-------

Fixes the crash cases in the bugreport:

{with({}) { import window.x; } M:do {with(NaN = y)NaN = 1.3; } while(0); }
try { with({}) /*TODE2*/if(window) { if (V) {continue ;; }} else import set.x; } \
finally { x.__proto__ = x; } try { with({}) { import x.*; }  } finally { return (x); \
} with({}) { with({}) { with({}) { import x.x; }  }  }


and still keeps normal cases working like for example:
with({a:2}) { print(a); }
with(Math) { a= PI *2; print(a); }


Thanks,

Bernd Buschinski


[Attachment #3 (text/html)]

<html>
 <body>
  <div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
   <table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 \
solid;">  <tr>
     <td>
      This is an automatically generated e-mail. To reply, visit:
      <a href="http://git.reviewboard.kde.org/r/110027/">http://git.reviewboard.kde.org/r/110027/</a>
  </td>
    </tr>
   </table>
   <br />




<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" \
style="background-image: \
url('http://git.reviewboard.kde.org/static/rb/images/review_request_box_top_bg.ab6f3b1072c9.png'); \
background-position: left top; background-repeat: repeat-x; border: 1px black \
solid;">  <tr>
  <td>

<div>Review request for kdelibs.</div>
<div>By Bernd Buschinski.</div>







<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
 <table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" \
style="border: 1px solid #b8b5a0">  <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: \
-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: \
break-word;">For js code like: with({}) { with({}) { with({}) { import x.x; }  }  }

the import statement can cause an exception, the import-exception is generated (but \
not fired) before it executes the other code. The With-statement has 2 operations to \
push and pop the new scope it should be used with. As the pre-generated Exception is \
already present, PushScope checks that and does not Push a new Scope. But PopScope \
does not check that, and tries to pop, which leads us to a crash. The Scope should be \
cleared by the Exceptionhandler on exception case, and PopScope should do nothing.

NOTE: I must admit I am unsure if this is the best solution, a review by a \
experienced kjs developer would be super helpful</pre>  </td>
 </tr>
</table>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: \
1px solid #b8b5a0">  <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: \
-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: \
break-word;">Fixes the crash cases in the bugreport:

{with({}) { import window.x; } M:do {with(NaN = y)NaN = 1.3; } while(0); }
try { with({}) /*TODE2*/if(window) { if (V) {continue ;; }} else import set.x; } \
finally { x.__proto__ = x; } try { with({}) { import x.*; }  } finally { return (x); \
} with({}) { with({}) { with({}) { import x.x; }  }  }


and still keeps normal cases working like for example:
with({a:2}) { print(a); }
with(Math) { a= PI *2; print(a); }</pre>
  </td>
 </tr>
</table>



<div style="margin-top: 1.5em;">
 <b style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Bugs: </b>


 <a href="http://bugs.kde.org/show_bug.cgi?id=311512">311512</a>, 

 <a href="http://bugs.kde.org/show_bug.cgi?id=311513">311513</a>


</div>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">

 <li>kjs/bytecode/codes.def <span style="color: grey">(59fea6c)</span></li>

</ul>

<p><a href="http://git.reviewboard.kde.org/r/110027/diff/" style="margin-left: \
3em;">View Diff</a></p>







  </td>
 </tr>
</table>




  </div>
 </body>
</html>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic