<p>Pau Espin Pedrol <strong>uploaded patch set #2</strong> to this change.</p><p><a href="https://gerrit.osmocom.org/12085">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">SigProcLib: Improve Vector buffer allocation mess<br><br>Original issue: In order to use SSE instructions, 16-byte aligned memory<br>chunks are needed, and C++ version < C++11 doesn't provide for a native<br>new/delete store. For that reason, memalign() must be used in the<br>implementation of convolve_h_alloc() for some buffers.<br>On the other side, The C++ code relies on C++ "new T[]" operator to<br>allocate a chunk of memory containing an array of class instances. As<br>classes are complex types, they cannot be allocated through C structures<br>(calling malloc). Experimentally can be seen too that it's unreliable<br>and the process will crash during startup if malloc() is used and then a<br>Complex<> deferred from it.<br><br>Previous implementation allowed for use of convolve_h_alloc or new[]<br>based on how the (signal)Vector is called, because then the buffer is<br>not going to be managed internally. But that's unreliable since resize()<br>calling resize() on it could use "delete" operator on a malloc'ed<br>buffer, and end up having a new new[] allocated buffer. It was also<br>found that some of the callers were actually leaking memory through ASan (because the<br>buffer is not managed by the Vector instance).<br><br>IMHO best option would be to rewrite all this code using C structures<br>and malloc/free exclusively, since it would make all this cod eeasier to<br>maintain.<br><br>But for now, let's extend the Vector class to allow specifying an<br>external alloc/free function and let the Vector instance take care of<br>the ownership of the buffer in all scenarios.<br><br>Change-Id: Ie484a4762a7f77fe1b105188ea03a6f025730b82<br>---<br>M CommonLibs/Vector.h<br>M Transceiver52M/arch/common/convolve.h<br>M Transceiver52M/arch/common/convolve_base.c<br>M Transceiver52M/sigProcLib.cpp<br>M Transceiver52M/signalVector.cpp<br>M Transceiver52M/signalVector.h<br>6 files changed, 52 insertions(+), 47 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/osmo-trx refs/changes/85/12085/2</pre><p>To view, visit <a href="https://gerrit.osmocom.org/12085">change 12085</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/12085"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-trx </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newpatchset </div>
<div style="display:none"> Gerrit-Change-Id: Ie484a4762a7f77fe1b105188ea03a6f025730b82 </div>
<div style="display:none"> Gerrit-Change-Number: 12085 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: Pau Espin Pedrol <pespin@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder (1000002) </div>
<div style="display:none"> Gerrit-CC: Vadim Yanitskiy <axilirator@gmail.com> </div>