Re: [lldb-dev] Passing std::atomics by value

2016-08-29 Thread Greg Clayton via lldb-dev
> On Aug 29, 2016, at 8:56 AM, Zachary Turner wrote: > > How about making it a std::unique_ptr>? This way > there's no risk of re-introducing a potential race, and copying still works. lldb_private::Address is a member variable in lldb_private::Symbol and it needs to say as small as possible

Re: [lldb-dev] Passing std::atomics by value

2016-08-29 Thread Zachary Turner via lldb-dev
How about making it a std::unique_ptr>? This way there's no risk of re-introducing a potential race, and copying still works. On Mon, Aug 29, 2016 at 8:49 AM Zachary Turner wrote: > My concern is that by not taking out the copy constructor, someone passes > another Address by value later. If pa

Re: [lldb-dev] Passing std::atomics by value

2016-08-29 Thread Zachary Turner via lldb-dev
My concern is that by not taking out the copy constructor, someone passes another Address by value later. If passing by value is unsafe (ignoring whether it generates a compiler error) it should be prevented by the compiler. That is doing due diligence. I will track down the commit that introduced

Re: [lldb-dev] Passing std::atomics by value

2016-08-29 Thread Greg Clayton via lldb-dev
> On Aug 26, 2016, at 5:37 PM, Zachary Turner wrote: > > How would you enforce that, other than to ask people to try to remember not > to do it? It seems to me like std::atomic not being copy-constructible is > telling you that, well, you shouldn't be copying it. It just won't compile on pla

Re: [lldb-dev] Passing std::atomics by value

2016-08-26 Thread Zachary Turner via lldb-dev
How would you enforce that, other than to ask people to try to remember not to do it? It seems to me like std::atomic not being copy-constructible is telling you that, well, you shouldn't be copying it. BTW, nobody has commented on my original concern that the atomic may not even be necessary in

Re: [lldb-dev] Passing std::atomics by value

2016-08-26 Thread Greg Clayton via lldb-dev
There is no need to delete the lldb_private::Address copy constructor. Just stop functions from passing it by value. > On Aug 26, 2016, at 1:13 PM, Zachary Turner wrote: > > IOW, marking it =delete() is no different than deleting the copy constructor > above, but at least if you mark it delete

Re: [lldb-dev] Passing std::atomics by value

2016-08-26 Thread Mehdi Amini via lldb-dev
> On Aug 26, 2016, at 1:13 PM, Zachary Turner wrote: > > IOW, marking it =delete() is no different than deleting the copy constructor > above, but at least if you mark it delete, maybe someone will read the > comment above it that explains why it's deleted :) Got it, make sense. Thanks. —

Re: [lldb-dev] Passing std::atomics by value

2016-08-26 Thread Zachary Turner via lldb-dev
IOW, marking it =delete() is no different than deleting the copy constructor above, but at least if you mark it delete, maybe someone will read the comment above it that explains why it's deleted :) On Fri, Aug 26, 2016 at 1:13 PM Zachary Turner wrote: > I think so. But in this case lldb::Addre

Re: [lldb-dev] Passing std::atomics by value

2016-08-26 Thread Zachary Turner via lldb-dev
I think so. But in this case lldb::Address explicitly supplied a copy constructor that looked like this: Address (const Address& rhs) : m_section_wp (rhs.m_section_wp), m_offset(rhs.m_offset.load()) // this is the std::atomic<> { } circumventing the problem. On Fri

Re: [lldb-dev] Passing std::atomics by value

2016-08-26 Thread Mehdi Amini via lldb-dev
> On Aug 26, 2016, at 1:02 PM, Zachary Turner via lldb-dev > wrote: > > It seems to be. I will also make the copy constructor =delete() to make sure > this cannot happen again. Just curious: if a member has a deleted copy-ctor (like std::atomic right?), isn’t the copy constructor automatica

Re: [lldb-dev] Passing std::atomics by value

2016-08-26 Thread Zachary Turner via lldb-dev
It seems to be. I will also make the copy constructor =delete() to make sure this cannot happen again. I'm still concerned that the std::atomic is unnecessary, but at that point at least it just becomes a performance problem and not a bug. On Fri, Aug 26, 2016 at 1:00 PM Greg Clayton wrote: >

Re: [lldb-dev] Passing std::atomics by value

2016-08-26 Thread Greg Clayton via lldb-dev
So after speaking with local experts on the subject, we do indeed have a problem. Please convert all placed where we pass lldb_private::Address by value to pass by "const Address &". Anyone that is modifying the address should make a local copy and work with that. Is Address the only class that

Re: [lldb-dev] Passing std::atomics by value

2016-08-26 Thread Zachary Turner via lldb-dev
gust 26, 2016 2:32 PM > To: Zachary Turner > Cc: LLDB > Subject: Re: [lldb-dev] Passing std::atomics by value > > That seems to me a compiler bug, not: "You can't pass structures with > std::atomic" elements in them by value. It would crazy to add a type to > the

Re: [lldb-dev] Passing std::atomics by value

2016-08-26 Thread Ted Woodward via lldb-dev
urora Forum, a Linux Foundation Collaborative Project -Original Message- From: lldb-dev [mailto:lldb-dev-boun...@lists.llvm.org] On Behalf Of Jim Ingham via lldb-dev Sent: Friday, August 26, 2016 2:32 PM To: Zachary Turner Cc: LLDB Subject: Re: [lldb-dev] Passing std::atomics by value

Re: [lldb-dev] Passing std::atomics by value

2016-08-26 Thread Jim Ingham via lldb-dev
That seems to me a compiler bug, not: "You can't pass structures with std::atomic" elements in them by value. It would crazy to add a type to the C++ language that you couldn't use everywhere. There doesn't seem to be any official restriction. And anecdotally there's a reference to the proble

Re: [lldb-dev] Passing std::atomics by value

2016-08-26 Thread Zachary Turner via lldb-dev
It could, in theory, it just doesn't. I compiled a quick program using i686-darwin as the target and the generated assembly makes no attempt to pad the arguments. I'll post some code later On Fri, Aug 26, 2016 at 11:42 AM Jim Ingham wrote: > > > On Aug 26, 2016, at 11:36 AM, Zachary Turner via

Re: [lldb-dev] Passing std::atomics by value

2016-08-26 Thread Jim Ingham via lldb-dev
> On Aug 26, 2016, at 11:44 AM, Adrian McCarthy via lldb-dev > wrote: > > Methods like Address::SetOffset and Address::Slide seem to have data races > despite m_offset being atomic. Callers of those methods would have to > guarantee that nothing else is trying to write to m_offset. And if t

Re: [lldb-dev] Passing std::atomics by value

2016-08-26 Thread Adrian McCarthy via lldb-dev
Methods like Address::SetOffset and Address::Slide seem to have data races despite m_offset being atomic. Callers of those methods would have to guarantee that nothing else is trying to write to m_offset. And if they're doing that, then there doesn't appear to be a need for std::atomic on that fi

Re: [lldb-dev] Passing std::atomics by value

2016-08-26 Thread Jim Ingham via lldb-dev
> On Aug 26, 2016, at 11:36 AM, Zachary Turner via lldb-dev > wrote: > > The thing is, the code is already full of data races. I think the > std::atomic is actually used incorrectly and is not even doing anything. > > That said, consider darwin on 32-bit, where I believe each stack frame is

Re: [lldb-dev] Passing std::atomics by value

2016-08-26 Thread Zachary Turner via lldb-dev
The thing is, the code is already full of data races. I think the std::atomic is actually used incorrectly and is not even doing anything. That said, consider darwin on 32-bit, where I believe each stack frame is 4-byte aligned. I dont' think there's any way the compiler can guarantee that a fun

Re: [lldb-dev] Passing std::atomics by value

2016-08-26 Thread Greg Clayton via lldb-dev
> On Aug 26, 2016, at 11:24 AM, Greg Clayton via lldb-dev > wrote: > >> >> On Aug 26, 2016, at 10:51 AM, Zachary Turner via lldb-dev >> wrote: >> >> I recently updated to Visual Studio 2015 Update 3, which has improved its >> diagnostics. As a result of this, LLDB is uncompilable due to a

Re: [lldb-dev] Passing std::atomics by value

2016-08-26 Thread Greg Clayton via lldb-dev
> On Aug 26, 2016, at 10:51 AM, Zachary Turner via lldb-dev > wrote: > > I recently updated to Visual Studio 2015 Update 3, which has improved its > diagnostics. As a result of this, LLDB is uncompilable due to a slew of > errors of the following nature: > > D:\src\llvm\tools\lldb\include\l

[lldb-dev] Passing std::atomics by value

2016-08-26 Thread Zachary Turner via lldb-dev
I recently updated to Visual Studio 2015 Update 3, which has improved its diagnostics. As a result of this, LLDB is uncompilable due to a slew of errors of the following nature: D:\src\llvm\tools\lldb\include\lldb/Target/Process.h(3256): error C2719: 'default_stop_addr': formal parameter with req