[PATCH] Gold-plugin: Broaden scope of get/release_input_file to scope of Module.

Rafael EspĂ­ndola rafael.espindola at gmail.com
Tue Feb 10 15:13:55 PST 2015


On 10 February 2015 at 16:00, Jan Voung <jvoung at chromium.org> wrote:
> I've been testing with gold instead bfd ld.
>
> The call chain is roughly this:
>
> #0  gold::File_read::View::~View (this=0x86891e8) at ../../../src/binutils/gold/fileread.cc:141
> #1  0x0821dafa in gold::File_read::clear_views (this=0x86734c8, mode=gold::File_read::CLEAR_VIEWS_NORMAL) at ../../../src/binutils/gold/fileread.cc:844
> #2  0x0821ed7e in gold::File_read::release (this=0x86734c8) at ../../../src/binutils/gold/fileread.cc:300
> #3  0x0821eef0 in gold::File_read::unlock (this=0x86734c8, task=0x8673260) at ../../../src/binutils/gold/fileread.cc:332
> #4  0x0810dc97 in gold::Object::unlock (this=0x8679140, t=0x8673260) at ../../../src/binutils/gold/object.h:431
> #5  0x083d9e49 in gold::Plugin_manager::release_input_file (this=0x8663ba8, handle=0) at ../../../src/binutils/gold/plugin.cc:801
> #6  0x083d5f30 in gold::release_input_file (handle=0x0) at ../../../src/binutils/gold/plugin.cc:1521
> #7  0xf7fca621 in allSymbolsReadHook(llvm::raw_fd_ostream*) () from LLVMgold.so
>
> Where line 141 at the top of the stack is:
>
> File_read::View::~View() {
> //...
>
>   case DATA_MMAPPED:
>     if (::munmap(const_cast<unsigned char*>(this->data_), this->size_) != 0)
>
> //...
> }
>
> So are you saying that clear_views() shouldn't be called?

Interesting.

Looking at it a bit it is clear that get_view cannot create a lock
(there is no release_view) and given that the memory it returns must
be handle as "brittle". It can go away any time the control flow goes
back to gold.

Given that, something along the lines of this patch is needed.
getModuleForFile only needs the file size, so pass in just that
instead of the full ld_plugin_input_file.

Does it fail reliably on 32 bits? If so, please also add a test case.

Thanks!
Rafael



More information about the llvm-commits mailing list