Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(394)

Issue 5966077: [ASan] remove <new> header (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
12 years ago by samsonov
Modified:
12 years ago
CC:
llvm-commits_cs.uiuc.edu
Base URL:
https://llvm.org/svn/llvm-project/compiler-rt/trunk/lib/asan/
Visibility:
Public.

Patch Set 1 : z #

Patch Set 2 : Move new/delete to other file. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+58 lines, -29 lines) Patch
M Makefile.old View 1 1 chunk +1 line, -0 lines 0 comments Download
M asan_interceptors.cc View 1 2 chunks +0 lines, -29 lines 0 comments Download
M asan_internal.h View 1 1 chunk +1 line, -0 lines 0 comments Download
A asan_new_delete.cc View 1 1 chunk +55 lines, -0 lines 0 comments Download
M asan_rtl.cc View 1 1 chunk +1 line, -0 lines 0 comments Download

Messages

Total messages: 9
samsonov
#include <new> brings a number of system libraries (e.g. <string.h> on Windows), which is probably ...
12 years ago (2012-04-04 14:53:14 UTC) #1
kcc1
I'd prefer to move our custom new/delete into asan_new_delete.cc, and in that file it would ...
12 years ago (2012-04-04 14:57:48 UTC) #2
samsonov
On 2012/04/04 14:57:48, kcc1 wrote: > I'd prefer to move our custom new/delete into asan_new_delete.cc, ...
12 years ago (2012-04-05 15:46:18 UTC) #3
kcc1
Oh, I mean that asan_new_delete.cc should be a part of asan rtl. Isn't that enough? ...
12 years ago (2012-04-05 16:25:08 UTC) #4
samsonov
On 2012/04/05 16:25:08, kcc1 wrote: > Oh, I mean that asan_new_delete.cc should be a part ...
12 years ago (2012-04-05 16:38:49 UTC) #5
kcc1
On Thu, Apr 5, 2012 at 9:38 AM, <samsonov@google.com> wrote: > On 2012/04/05 16:25:08, kcc1 ...
12 years ago (2012-04-05 16:48:36 UTC) #6
Evgeniy Stepanov
On 2012/04/05 16:38:49, samsonov wrote: > On 2012/04/05 16:25:08, kcc1 wrote: > > Oh, I ...
12 years ago (2012-04-05 16:49:52 UTC) #7
samsonov
On Thu, Apr 5, 2012 at 8:48 PM, Kostya Serebryany <kcc@google.com> wrote: > > > ...
12 years ago (2012-04-05 17:10:10 UTC) #8
kcc1
12 years ago (2012-04-05 17:40:15 UTC) #9
Looks good now (assuming the tests pass).
Thanks!

--kcc

On Thu, Apr 5, 2012 at 10:10 AM, Alexey Samsonov <samsonov@google.com>wrote:

>
>
> On Thu, Apr 5, 2012 at 8:48 PM, Kostya Serebryany <kcc@google.com> wrote:
>
>>
>>
>> On Thu, Apr 5, 2012 at 9:38 AM, <samsonov@google.com> wrote:
>>
>>> On 2012/04/05 16:25:08, kcc1 wrote:
>>>
>>>> Oh, I mean that asan_new_delete.cc should be a part of asan rtl.
>>>> Isn't that enough?
>>>>
>>>
>>> No, if ASan RTL doesn't depend on anything in asan_new_delete.cc.
>>>
>>
>> We know how to fix it.
>> Juts make an empty InitNewAndDelete() and call it from another file.
>>
>
> It's in the patch already.
>
>
>>
>>
>>> asan_new_delete.o will be archived into libasan .a but will not be
>>> statically linked into the exe file which contains a call to "new"
>>> (if we're unlucky, e.g. if libstdc++ is linked earlier).
>>>
>>>
>>>
>>>  On Thu, Apr 5, 2012 at 8:46 AM, <mailto:samsonov@google.com> wrote:
>>>>
>>>
>>>  > On 2012/04/04 14:57:48, kcc1 wrote:
>>>> >
>>>> >> I'd prefer to move our custom new/delete into asan_new_delete.cc,
>>>>
>>> and
>>>
>>>> >>
>>>> > in
>>>> >
>>>> >> that file it would probably be ok to include <new>.
>>>> >>
>>>> >
>>>> > Yep, that's reasonable, but we have to make sure that resulting
>>>> > asan_new_delete.o will be loaded from libasan .a file
>>>> > (otherwise our "new" implementation is just not linked into exe, and
>>>> > dynamic linker chooses libstdc++ implementation).
>>>> >
>>>> > We can
>>>> > 1) add a fake dependency between asan_rtl and asan_new_delete (in
>>>>
>>> this
>>>
>>>> > CL, a bit hacky)
>>>> > 2) hack lib/Driver/Tools.cpp and make sure that flag -lstdc++ is
>>>>
>>> passed
>>>
>>>> > to ld after .a with ASan RT (it is currently passed before). (looks
>>>>
>>> more
>>>
>>>> > hacky)
>>>> > 3) use -Wl,--whole-archive (omg).
>>>> >
>>>> >
>>>> >  --kcc
>>>> >>
>>>> >
>>>> >  On Wed, Apr 4, 2012 at 7:53 AM, <mailto:samsonov@google.com> wrote:
>>>> >>
>>>> >
>>>> >  > Reviewers: kcc1, timurrrr_at_google_com,
>>>> >> >
>>>> >> > Message:
>>>> >> > #include <new> brings a number of system libraries (e.g.
>>>>
>>> <string.h>
>>>
>>>> >>
>>>> > on
>>>> >
>>>> >> > Windows), which is probably unwanted. We (hopefully) can replace
>>>> >> > std::nothrow_t and std::bad_alloc by custom stubs, so that our
>>>> >>
>>>> > overload
>>>> >
>>>> >> > of new would still work in a user program.
>>>> >> >
>>>> >> >
>>>> >> >
>>>> >> > Please review this at
>>>> >>
>>>> >
>>>> >
http://codereview.appspot.com/******5966077/%253Chttp://**<http://codereview....
>>>> >
>>>>
>>>
>>>
codereview.appspot.com/****5966077/<http://codereview.appspot.com/**5966077/>
>>> <http://codereview.**appspot.com/**5966077/%3Chttp:**
>>>
//codereview.appspot.com/**5966077/<http://codereview.appspot.com/**5966077/%3Chttp://codereview.appspot.com/5966077/>
>>> >
>>>
>>>> > >
>>>> >
>>>> >  >
>>>> >> > Affected files:
>>>> >> >  M     asan_interceptors.cc
>>>> >> >
>>>> >> >
>>>> >> > Index: asan_interceptors.cc
>>>> >> >
>>>> >>
>>>> > ==============================******==========================**==**
>>>>
>>>> > ==**=======
>>>> >
>>>> >  > --- asan_interceptors.cc        (revision 154006)
>>>> >> > +++ asan_interceptors.cc        (working copy)
>>>> >> > @@ -22,8 +22,6 @@
>>>> >> >  #include "asan_thread_registry.h"
>>>> >> >  #include "interception/interception.h"
>>>> >> >
>>>> >> > -#include <new>
>>>> >> > -
>>>> >> >  // Use macro to describe if specific function should be
>>>> >> >  // intercepted on a given platform.
>>>> >> >  #if !defined(_WIN32)
>>>> >> > @@ -331,6 +329,10 @@
>>>> >> >  void *operator new(size_t size) { OPERATOR_NEW_BODY; }
>>>> >> >  void *operator new[](size_t size) { OPERATOR_NEW_BODY; }
>>>> >> >  #else
>>>> >> > +namespace std {
>>>> >> > +class bad_alloc {};
>>>> >> > +class nothrow_t;
>>>> >> > +}  // namespace std
>>>> >> >  void *operator new(size_t size) throw(std::bad_alloc) {
>>>> >> > OPERATOR_NEW_BODY; }
>>>> >> >  void *operator new[](size_t size) throw(std::bad_alloc) {
>>>> >> > OPERATOR_NEW_BODY; }
>>>> >> >  void *operator new(size_t size, std::nothrow_t const&) throw()
>>>> >> >
>>>> >> >
>>>> >> >
>>>> >>
>>>> >
>>>> >
>>>> >
>>>> >
>>>>
>>>
>>> http://codereview.appspot.com/****5966077/%3Chttp://**
>>>
codereview.appspot.com/**5966077/<http://codereview.appspot.com/**5966077/%3Chttp://codereview.appspot.com/5966077/>
>>> >
>>>
>>>> >
>>>>
>>>
>>>
>>>
>>>
http://codereview.appspot.com/**5966077/<http://codereview.appspot.com/5966077/>
>>>
>>
>>
>
>
> --
> Alexey Samsonov, MSK
>
>
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b