Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-Werror=use-after-free in IntrusivePtr #95

Open
jerinphilip opened this issue Jun 12, 2022 · 1 comment
Open

-Werror=use-after-free in IntrusivePtr #95

jerinphilip opened this issue Jun 12, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@jerinphilip
Copy link

yay builds of translateLocally fail with the following error, coming from marian-dev.

In file included from /home/jerin/.cache/yay/translatelocally-git/src/translateLocally/3rd_party/bergamot-translator/3rd_party/marian-dev/src/common/definitions.h:5,
                 from /home/jerin/.cache/yay/translatelocally-git/src/translateLocally/3rd_party/bergamot-translator/3rd_party/marian-dev/src/common/cli_wrapper.h:6,
                 from /home/jerin/.cache/yay/translatelocally-git/src/translateLocally/3rd_party/bergamot-translator/3rd_party/marian-dev/src/common/config_parser.h:4,
                 from /home/jerin/.cache/yay/translatelocally-git/src/translateLocally/3rd_party/bergamot-translator/3rd_party/marian-dev/src/common/config.h:5,
                 from /home/jerin/.cache/yay/translatelocally-git/src/translateLocally/3rd_party/bergamot-translator/3rd_party/marian-dev/src/graph/expression_graph.h:3,
                 from /home/jerin/.cache/yay/translatelocally-git/src/translateLocally/3rd_party/bergamot-translator/3rd_party/marian-dev/src/graph/expression_graph.cpp:1:
In function ‘void marian::intrusivePtrRelease(TensorBase*)’,
    inlined from ‘IntrusivePtr<T>::~IntrusivePtr() [with T = marian::TensorBase]’ at /home/jerin/.cache/yay/translatelocally-git/src/translateLocally/3rd_party/bergamot-translator/3rd_party/marian-dev/src/common/intrusive_ptr.h:66:26,
    inlined from ‘void marian::ExpressionGraph::backward(bool, float)’ at /home/jerin/.cache/yay/translatelocally-git/src/translateLocally/3rd_party/bergamot-translator/3rd_party/marian-dev/src/graph/expression_graph.cpp:207:14:
/home/jerin/.cache/yay/translatelocally-git/src/translateLocally/3rd_party/bergamot-translator/3rd_party/marian-dev/src/common/intrusive_ptr.h:24:23: error: pointer used after ‘void operator delete(void*)’ [-Werror=use-after-free]
   24 |     if(x != 0 && --x->references_ == 0) {    \
      |                    ~~~^~~~~~~~~~~
/home/jerin/.cache/yay/translatelocally-git/src/translateLocally/3rd_party/bergamot-translator/3rd_party/marian-dev/src/tensors/tensor.h:30:3: note: in expansion of macro ‘ENABLE_INTRUSIVE_PTR’
   30 |   ENABLE_INTRUSIVE_PTR(TensorBase)
      |   ^~~~~~~~~~~~~~~~~~~~
In file included from /home/jerin/.cache/yay/translatelocally-git/src/translateLocally/3rd_party/bergamot-translator/3rd_party/marian-dev/src/tensors/tensor_allocator.h:8,
                 from /home/jerin/.cache/yay/translatelocally-git/src/translateLocally/3rd_party/bergamot-translator/3rd_party/marian-dev/src/graph/expression_graph.h:7:
In destructor ‘virtual marian::TensorBase::~TensorBase()’,
    inlined from ‘void marian::intrusivePtrRelease(TensorBase*)’ at /home/jerin/.cache/yay/translatelocally-git/src/translateLocally/3rd_party/bergamot-translator/3rd_party/marian-dev/src/tensors/tensor.h:30:3,
    inlined from ‘IntrusivePtr<T>::~IntrusivePtr() [with T = marian::TensorBase]’ at /home/jerin/.cache/yay/translatelocally-git/src/translateLocally/3rd_party/bergamot-translator/3rd_party/marian-dev/src/common/intrusive_ptr.h:66:26,
    inlined from ‘void marian::Element(Functor, Tensor, Tensors ...) [with Functor = functional::Assign<functional::Var<1>, functional::BinaryFunctor<functional::elem::Clip, functional::Assignee<1>, functional::Capture> >; Tensors = {}]’ at /home/jerin/.cache/yay/translatelocally-git/src/translateLocally/3rd_party/bergamot-translator/3rd_party/marian-dev/src/tensors/tensor_operators.h:50:17,
    inlined from ‘void marian::ExpressionGraph::backward(bool, float)’ at /home/jerin/.cache/yay/translatelocally-git/src/translateLocally/3rd_party/bergamot-translator/3rd_party/marian-dev/src/graph/expression_graph.cpp:207:14:
/home/jerin/.cache/yay/translatelocally-git/src/translateLocally/3rd_party/bergamot-translator/3rd_party/marian-dev/src/tensors/tensor.h:67:26: note: call to ‘void operator delete(void*)’ here
   67 |   virtual ~TensorBase() {}
      |                          ^
cc1plus: all warnings being treated as errors
make[2]: *** [3rd_party/bergamot-translator/3rd_party/marian-dev/src/CMakeFiles/marian.dir/build.make:664: 3rd_party/bergamot-translator/3rd_party/marian-dev/src/CMakeFiles/marian.dir/graph/expression_graph.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:557: 3rd_party/bergamot-translator/3rd_party/marian-dev/src/CMakeFiles/marian.dir/all] Error 2
make: *** [Makefile:156: all] Error 2
==> ERROR: A failure occurred in build().
    Aborting...
 -> error making: translatelocally-git

I am assuming the following compiler is used on my ArchLinux:

$ g++ --version
g++ (GCC) 12.1.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
@jerinphilip jerinphilip added the bug Something isn't working label Jun 12, 2022
@XapaJIaMnu
Copy link
Collaborator

This is a GCC issue and also happens in upstream marian, not sure how exactly to fix it. Need to spend more time on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants