Re: Proposal to ban the usage of refcounted objects inside C++ lambdas in Gecko

2015-04-14 Thread Ehsan Akhgari
On 2015-04-14 12:41 PM, Jan-Ivar Bruaroey wrote: 2. lambda capture use safer copy construction by default (hence the standout [&] above for reviewers). There is nothing safe about copying raw pointers to refcounted objects. There's nothing safe about copying raw pointers to heap object

Re: Proposal to ban the usage of refcounted objects inside C++ lambdas in Gecko

2015-04-14 Thread Jan-Ivar Bruaroey
On 4/14/15 10:06 AM, Ehsan Akhgari wrote: On 2015-04-13 1:36 PM, Jan-Ivar Bruaroey wrote: The above is a raw pointer bug, not a lambda bug. Yes, I'm aware. Please see bug 1114683. Thanks, I was not aware of this larger effort. This somewhat addresses my concern that we seem overly focused

Re: Proposal to ban the usage of refcounted objects inside C++ lambdas in Gecko

2015-04-14 Thread Ehsan Akhgari
On 2015-04-13 1:36 PM, Jan-Ivar Bruaroey wrote: On 4/10/15 2:09 PM, Seth Fowler wrote: On Apr 10, 2015, at 8:46 AM, Ehsan Akhgari wrote: I would like to propose that we should ban the usage of refcounted objects inside lambdas in Gecko. Here is the reason: Consider the following code: nsINo

Re: Proposal to ban the usage of refcounted objects inside C++ lambdas in Gecko

2015-04-14 Thread Ehsan Akhgari
On 2015-04-10 9:43 PM, Gregory Szorc wrote: On Fri, Apr 10, 2015 at 11:46 AM, Ehsan Akhgari mailto:ehsan.akhg...@gmail.com>> wrote: I would like to propose that we should ban the usage of refcounted objects inside lambdas in Gecko. Here is the reason: Consider the following cod

Re: Proposal to ban the usage of refcounted objects inside C++ lambdas in Gecko

2015-04-14 Thread Ehsan Akhgari
On 2015-04-13 1:55 PM, Trevor Saunders wrote: On Mon, Apr 13, 2015 at 01:28:05PM -0400, Ehsan Akhgari wrote: On 2015-04-13 5:26 AM, Nicolas B. Pierron wrote: On 04/10/2015 07:47 PM, Ehsan Akhgari wrote: On 2015-04-10 1:41 PM, Nicolas B. Pierron wrote: Also, what is the alternative? Acquiring

Re: Proposal to ban the usage of refcounted objects inside C++ lambdas in Gecko

2015-04-14 Thread Ehsan Akhgari
On 2015-04-10 9:43 PM, Gregory Szorc wrote: On Fri, Apr 10, 2015 at 11:46 AM, Ehsan Akhgari mailto:ehsan.akhg...@gmail.com>> wrote: I would like to propose that we should ban the usage of refcounted objects inside lambdas in Gecko. Here is the reason: Consider the following cod

Re: Proposal to ban the usage of refcounted objects inside C++ lambdas in Gecko

2015-04-13 Thread Jan-Ivar Bruaroey
On 4/10/15 4:26 PM, smaug wrote: I'd say that is rather painful for reviewers, since both Move() (I prefer .swap()) and lambda hide what is actually happening to the refcnt. Wanna ban copy construction? ;) Higher-level constructs inherently "hide" something, but I disagree they make things ha

Re: Proposal to ban the usage of refcounted objects inside C++ lambdas in Gecko

2015-04-13 Thread Jan-Ivar Bruaroey
On 4/13/15 1:36 PM, Jan-Ivar Bruaroey wrote: [2] http://mxr.mozilla.org/mozilla-central/source/xpco/glue/nsThreadUtils.cpp?mark=164-168#164 working link I hope: http://mxr.mozilla.org/mozilla-central/source/xpcom/glue/nsThreadUtils.cpp?mark=164-168#164

Re: Proposal to ban the usage of refcounted objects inside C++ lambdas in Gecko

2015-04-13 Thread Trevor Saunders
On Mon, Apr 13, 2015 at 01:28:05PM -0400, Ehsan Akhgari wrote: > On 2015-04-13 5:26 AM, Nicolas B. Pierron wrote: > >On 04/10/2015 07:47 PM, Ehsan Akhgari wrote: > >>On 2015-04-10 1:41 PM, Nicolas B. Pierron wrote: > Also, what is the alternative? Acquiring a nsCOMPtr/nsRefPtr inside the >

Re: Proposal to ban the usage of refcounted objects inside C++ lambdas in Gecko

2015-04-13 Thread Jan-Ivar Bruaroey
On 4/10/15 2:09 PM, Seth Fowler wrote: On Apr 10, 2015, at 8:46 AM, Ehsan Akhgari wrote: I would like to propose that we should ban the usage of refcounted objects inside lambdas in Gecko. Here is the reason: Consider the following code: nsINode* myNode; TakeLambda([&]() { myNode->Foo(); }

Re: Proposal to ban the usage of refcounted objects inside C++ lambdas in Gecko

2015-04-13 Thread Ehsan Akhgari
On 2015-04-13 5:26 AM, Nicolas B. Pierron wrote: On 04/10/2015 07:47 PM, Ehsan Akhgari wrote: On 2015-04-10 1:41 PM, Nicolas B. Pierron wrote: Also, what is the alternative? Acquiring a nsCOMPtr/nsRefPtr inside the Lambda constructor (or whatever it's called)? Yes, another option would be to

Re: Proposal to ban the usage of refcounted objects inside C++ lambdas in Gecko

2015-04-13 Thread Nicolas B. Pierron
On 04/10/2015 07:47 PM, Ehsan Akhgari wrote: On 2015-04-10 1:41 PM, Nicolas B. Pierron wrote: Also, what is the alternative? Acquiring a nsCOMPtr/nsRefPtr inside the Lambda constructor (or whatever it's called)? Yes, another option would be to ensure that the lambda cannot be used after a spec

Re: Proposal to ban the usage of refcounted objects inside C++ lambdas in Gecko

2015-04-12 Thread Eric Shepherd
Gregory Szorc April 10, 2015 at 9:43 PM On Fri, Apr 10, 2015 at 11:46 AM, Ehsan Akhgari Why do we merely update the style guide? We have a custom Clang compiler plugin. I think we should have the Clang compiler plugin enforce our style guidelines by refusing to compile

Re: Proposal to ban the usage of refcounted objects inside C++ lambdas in Gecko

2015-04-10 Thread Gregory Szorc
On Fri, Apr 10, 2015 at 11:46 AM, Ehsan Akhgari wrote: > I would like to propose that we should ban the usage of refcounted objects > inside lambdas in Gecko. Here is the reason: > > Consider the following code: > > nsINode* myNode; > TakeLambda([&]() { > myNode->Foo(); > }); > > There is noth

Re: Proposal to ban the usage of refcounted objects inside C++ lambdas in Gecko

2015-04-10 Thread smaug
On 04/10/2015 09:09 PM, Seth Fowler wrote: On Apr 10, 2015, at 8:46 AM, Ehsan Akhgari wrote: I would like to propose that we should ban the usage of refcounted objects inside lambdas in Gecko. Here is the reason: Consider the following code: nsINode* myNode; TakeLambda([&]() { myNode->Fo

Re: Proposal to ban the usage of refcounted objects inside C++ lambdas in Gecko

2015-04-10 Thread Andrew McCreight
On Fri, Apr 10, 2015 at 10:37 AM, Ehsan Akhgari wrote: > On 2015-04-10 12:33 PM, Andrew McCreight wrote: > >> >> >> On Fri, Apr 10, 2015 at 8:46 AM, Ehsan Akhgari > > wrote: >> >> I would like to propose that we should ban the usage of refcounted >> objects