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

List:       pypy-dev
Subject:    Re: [pypy-dev] Mysterious IndexError in service running with PyPy
From:       "hubo" <hubo () jiedaibao ! com>
Date:       2018-05-22 7:15:22
Message-ID: 5B03C387.4020506 () jiedaibao ! com+E78C0CB65B51204C
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]

[Attachment #4 (text/plain)]

Thank you for your explaination!

One more thing I would like to confirm: looks like in PyPy3, a "yield from \
my_generator()" expression delegates all exceptions inside, so the finalizer in \
my_generator() is always executed. Am I right?

2018-05-22 

hubo 



发件人:Armin Rigo <armin.rigo@gmail.com>
发送时间:2018-05-22 14:21
主题:Re: [pypy-dev] Mysterious IndexError in service running with PyPy
收件人:"hubo"<hubo@jiedaibao.com>
抄送:"William ML Leslie"<william.leslie.ttg@gmail.com>,"PyPy Developer Mailing \
List"<pypy-dev@python.org>

Hi, 

On 22 May 2018 at 04:46, hubo <hubo@jiedaibao.com> wrote: 
> I think I found the cause, happily it is not a PyPy bug (although it is 
> PyPy-related). Some generators are calling some cleanup code in the 
> "finally" clause, but they are not correctly collected in PyPy until GC 
> (because PyPy does not use reference counting). Apparently when they are 
> collected by GC module, the "finally" clause is executed in a separated 
> thread. 

Unlike Java, we're not purposefully running finalizers in its own 
threads: instead, if your program has got more than one thread 
running, finalizers will run in the one where the GC happens to run. 
There isn't much we can do about that. 

All these hard GC issues also exist on CPython, but they are just more 
hidden.  Typically, if there is a cycle of objects which itself holds, 
indirectly, a reference to the generator-iterator, then you get the 
same effect: the cycle will be broken by the GC module of CPython at a 
random point in time and from a random thread, too.  So we can argue 
that you potentially have a bug even on CPython, in the sense that an 
apparently unrelated change somewhere else can make the same bug 
appear on CPython. 


A bientôt, 

Armin. 


[Attachment #5 (text/html)]

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=utf-8" http-equiv=Content-Type><!-- flashmail style \
begin --> <STYLE type=text/css>
body {border-width:0;margin:0}
img {border:0;margin:0;padding:0}
</STYLE>
<BASE target=_blank><!-- flashmail style end -->
<META name=GENERATOR content="MSHTML 11.00.10570.1001"></HEAD>
<BODY 
style="BORDER-LEFT-WIDTH: 0px; FONT-SIZE: 10.5pt; FONT-FAMILY: 微软雅黑; \
BORDER-RIGHT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; COLOR: #000000; MARGIN: 12px; \
LINE-HEIGHT: 1.5; BORDER-TOP-WIDTH: 0px"  marginheight="0" marginwidth="0">
<DIV>Thank you for your explaination!</DIV>
<DIV>&nbsp;</DIV>
<DIV>One more thing I would like to confirm: looks like in PyPy3, a "yield from 
my_generator()" expression delegates all exceptions inside, so the finalizer in 
my_generator() is always executed. Am I right?</DIV>
<DIV>&nbsp;</DIV>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana; COLOR: #c0c0c0" 
align=left>2018-05-22 
<HR id=SignNameHR 
style="BORDER-TOP: #c0c0c0 1px solid; HEIGHT: 1px; BORDER-RIGHT: 0px; WIDTH: 122px; \
BORDER-BOTTOM: 0px; BORDER-LEFT: 0px"  align=left>
<SPAN id=_FlashSignName>hubo</SPAN> </DIV>
<HR 
style="BORDER-TOP: #c0c0c0 1px solid; HEIGHT: 1px; BORDER-RIGHT: 0px; BORDER-BOTTOM: \
0px; BORDER-LEFT: 0px">

<BLOCKQUOTE id=ntes-flashmail-quote 
style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana; PADDING-LEFT: 0px; MARGIN-LEFT: 0px">
  <DIV><STRONG>发件人:</STRONG>Armin Rigo &lt;armin.rigo@gmail.com&gt;</DIV>
  <DIV><STRONG>发送时间:</STRONG>2018-05-22&nbsp;14:21</DIV>
  <DIV><STRONG>主题:</STRONG>Re: [pypy-dev] Mysterious IndexError in service 
  running with PyPy</DIV>
  <DIV><STRONG>收件人:</STRONG>"hubo"&lt;hubo@jiedaibao.com&gt;</DIV>
  <DIV><STRONG>抄送:</STRONG>"William ML 
  Leslie"&lt;william.leslie.ttg@gmail.com&gt;,"PyPy Developer Mailing 
  List"&lt;pypy-dev@python.org&gt;</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>
  <DIV>Hi,&nbsp;</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>On&nbsp;22&nbsp;May&nbsp;2018&nbsp;at&nbsp;04:46,&nbsp;hubo&nbsp;&lt;hubo@jiedaibao.com&gt;&nbsp;wrote:&nbsp;</DIV>
  <DIV>&gt;&nbsp;I&nbsp;think&nbsp;I&nbsp;found&nbsp;the&nbsp;cause,&nbsp;happily&nbsp \
;it&nbsp;is&nbsp;not&nbsp;a&nbsp;PyPy&nbsp;bug&nbsp;(although&nbsp;it&nbsp;is&nbsp;</DIV>
  <DIV>&gt;&nbsp;PyPy-related).&nbsp;Some&nbsp;generators&nbsp;are&nbsp;calling&nbsp;some&nbsp;cleanup&nbsp;code&nbsp;in&nbsp;the&nbsp;</DIV>
  <DIV>&gt;&nbsp;"finally"&nbsp;clause,&nbsp;but&nbsp;they&nbsp;are&nbsp;not&nbsp;correctly&nbsp;collected&nbsp;in&nbsp;PyPy&nbsp;until&nbsp;GC&nbsp;</DIV>
  <DIV>&gt;&nbsp;(because&nbsp;PyPy&nbsp;does&nbsp;not&nbsp;use&nbsp;reference&nbsp;counting).&nbsp;Apparently&nbsp;when&nbsp;they&nbsp;are&nbsp;</DIV>
  <DIV>&gt;&nbsp;collected&nbsp;by&nbsp;GC&nbsp;module,&nbsp;the&nbsp;"finally"&nbsp;clause&nbsp;is&nbsp;executed&nbsp;in&nbsp;a&nbsp;separated&nbsp;</DIV>
  <DIV>&gt;&nbsp;thread.&nbsp;</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>Unlike&nbsp;Java,&nbsp;we're&nbsp;not&nbsp;purposefully&nbsp;running&nbsp;finalizers&nbsp;in&nbsp;its&nbsp;own&nbsp;</DIV>
  <DIV>threads:&nbsp;instead,&nbsp;if&nbsp;your&nbsp;program&nbsp;has&nbsp;got&nbsp;more&nbsp;than&nbsp;one&nbsp;thread&nbsp;</DIV>
  <DIV>running,&nbsp;finalizers&nbsp;will&nbsp;run&nbsp;in&nbsp;the&nbsp;one&nbsp;where&nbsp;the&nbsp;GC&nbsp;happens&nbsp;to&nbsp;run.&nbsp;</DIV>
  <DIV>There&nbsp;isn't&nbsp;much&nbsp;we&nbsp;can&nbsp;do&nbsp;about&nbsp;that.&nbsp;</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>All&nbsp;these&nbsp;hard&nbsp;GC&nbsp;issues&nbsp;also&nbsp;exist&nbsp;on&nbsp;CPython,&nbsp;but&nbsp;they&nbsp;are&nbsp;just&nbsp;more&nbsp;</DIV>
  <DIV>hidden.&nbsp;&nbsp;Typically,&nbsp;if&nbsp;there&nbsp;is&nbsp;a&nbsp;cycle&nbsp;of&nbsp;objects&nbsp;which&nbsp;itself&nbsp;holds,&nbsp;</DIV>
  <DIV>indirectly,&nbsp;a&nbsp;reference&nbsp;to&nbsp;the&nbsp;generator-iterator,&nbsp;then&nbsp;you&nbsp;get&nbsp;the&nbsp;</DIV>
  <DIV>same&nbsp;effect:&nbsp;the&nbsp;cycle&nbsp;will&nbsp;be&nbsp;broken&nbsp;by&nbsp;the&nbsp;GC&nbsp;module&nbsp;of&nbsp;CPython&nbsp;at&nbsp;a&nbsp;</DIV>
  <DIV>random&nbsp;point&nbsp;in&nbsp;time&nbsp;and&nbsp;from&nbsp;a&nbsp;random&nbsp;thread,&nbsp;too.&nbsp;&nbsp;So&nbsp;we&nbsp;can&nbsp;argue&nbsp;</DIV>
  <DIV>that&nbsp;you&nbsp;potentially&nbsp;have&nbsp;a&nbsp;bug&nbsp;even&nbsp;on&nbsp;CPython,&nbsp;in&nbsp;the&nbsp;sense&nbsp;that&nbsp;an&nbsp;</DIV>
  <DIV>apparently&nbsp;unrelated&nbsp;change&nbsp;somewhere&nbsp;else&nbsp;can&nbsp;make&nbsp;the&nbsp;same&nbsp;bug&nbsp;</DIV>
  <DIV>appear&nbsp;on&nbsp;CPython.&nbsp;</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>A&nbsp;bientôt,&nbsp;</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>Armin.&nbsp;</DIV>
  <DIV>&nbsp;</DIV></DIV></BLOCKQUOTE></BODY></HTML>



_______________________________________________
pypy-dev mailing list
pypy-dev@python.org
https://mail.python.org/mailman/listinfo/pypy-dev


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

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