FIAS . Impressum . Privacy

Segmentation fault when using Vc::Memory as a member of a heap-allocated object

Giordano Khouri [please enable javascript to see the address]
Thu Feb 20 16:36:18 CET 2014


Without looking at any code other that what you posted, I would say the new allocation is unaligned and the stack allocation is aligned. The _mm256_store_pd operation requires an aligned address. In this modern day and age, the compiler knows enough to align the stack address of the variable, but still doesn't align a heap allocation.





[http://download2.nikon.net/images/logo/bsymbol.gif]
Khouri Giordano
Software Technology Researcher

Nikon Inc.
1300 Walt Whitman Road
Melville NY 11747-3064

Office: 631-547-4335    Fax: 631-547-0361

[please enable javascript to see the address][please enable javascript to see the address]>




www.nikonusa.com






[http://download2.nikon.net/images/logo/email-sig-1-7.jpg] <http://www.nikonusa.com/en/Nikon-Products/Product/Digital-SLR-Cameras/1532/D3300.html>
[please enable javascript to see the address][please enable javascript to see the address]] On Behalf Of Georgios Bitzes
Sent: Thursday, February 20, 2014 8:42 AM
[please enable javascript to see the address]
Subject: Segmentation fault when using Vc::Memory as a member of a heap-allocated object

Hi everyone,

I would like to report an issue I came across while using Vc. Here is a short example that reproduces it:

#include <Vc/Vc>

class A {
    private:
        Vc::Memory<Vc::double_v, 3> internal;
};

int main() {
    std::cout << "size: " << Vc::double_v::Size << std::endl;
    A *a = new A();
    return 0;
}

The example compiles but segfaults during the creation of object a.
$ ./a.out
size: 4
Segmentation fault

Backtrace:
$ gdb ./a.out
GNU gdb (GDB) 7.5.91.20130417-cvs-ubuntu
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /tmp/vcmemory/a.out...done.
(gdb) r
Starting program: /tmp/vcmemory/a.out
size: 4
Program received signal SIGSEGV, Segmentation fault.
0x000000000040142f in _mm256_store_pd (__A=..., __P=0x604010) at /usr/lib/gcc/x86_64-linux-gnu/4.7/include/avxintrin.h:829
829  *(__m256d *)__P = __A;
(gdb) bt
#0  0x000000000040142f in _mm256_store_pd (__A=..., __P=0x604010) at /usr/lib/gcc/x86_64-linux-gnu/4.7/include/avxintrin.h:829
#1  store<Vc::v0::Public::{anonymous}::LoadStoreFlags<> > (x=..., mem=0x604010) at /opt/Vc-a1d8b9fc31060d870386613cc72319546c850b87/include/Vc/avx/vectorhelper.h:106
#2  store<double, Vc::v0::Public::{anonymous}::LoadStoreFlags<> > (flags=..., mem=0x604010, this=0x7fffffffe420) at /opt/Vc-a1d8b9fc31060d870386613cc72319546c850b87/include/Vc/avx/vector.tcc:236
#3  store<Vc::v0::Public::{anonymous}::LoadStoreFlags<> > (flags=..., mem=0x604010, this=<optimized out>) at /opt/Vc-a1d8b9fc31060d870386613cc72319546c850b87/include/Vc/avx/vector.h:174
#4  operator=<Vc::v0::AVX::Vector<double> > (x=..., this=0x604010) at /opt/Vc-a1d8b9fc31060d870386613cc72319546c850b87/include/Vc/common/memorybase.h:85
#5  Vc::v0::Common::Memory<Vc::v0::AVX::Vector<double>, 3ul, 0ul, true>::Memory (this=0x604010) at /opt/Vc-a1d8b9fc31060d870386613cc72319546c850b87/include/Vc/common/memory.h:293
#6  0x00000000004011aa in A::A (this=0x604010) at main.cpp:4
#7  0x00000000004010fa in main () at main.cpp:11

The above code was compiled with:
g++ -fabi-version=6 -m64 -std=c++11  -g -fpermissive -ffast-math  -finline-limit=10000000 -mavx -ftree-vectorize main.cpp -I/opt/Vc-a1d8b9fc31060d870386613cc72319546c850b87/include -L/opt/Vc-a1d8b9fc31060d870386613cc72319546c850b87/lib/ -lVc -std=c++11

I took the latest commit of Vc (a1d8b9fc31060d870386613cc72319546c850b87), compiled and run on a Xeon E3-1280 v3 (Haswell) @ 3.60 GHz by g++ version 4.7.3-2ubuntu4.

On the contrary, if I replace "A *a = new A()" with "A a()" it runs fine. This appears to happen only when the object is allocated on the heap, not on the stack.

Is this a bug on the part of Vc or am I doing something wrong?

Cheers



CONFIDENTIAL:
This e-mail including any attachments is intended only for the party or parties to whom it is addressed and may contain information which is privileged and/or confidential. If you are not the intended recipient, you are hereby notified that any use, disclosure, dissemination, distribution, copying, or printing of any information contained in or attached to this e-mail is STRICTLY PROHIBITED and may constitute a breach of confidentiality and/or privilege. If you have received this e-mail in error, please notify immediately the sender by reply e-mail and then delete this e-mail and any attachments in their entirety from your system. Thank you. This e-mail message including any attachments is believed to be free of any viruses; however, it is the sole responsibility of the recipient to ensure that it is virus free, and Nikon does not accept any responsibility for any loss, disruption or damage to your data or computer system which may occur in connection with this e-mail including any attachments.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://compeng.uni-frankfurt.de/pipermail/vc/attachments/20140220/bf2af7e4/attachment-0001.html>


More information about the Vc mailing list
FIAS . Impressum . Privacy