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

[vector] General Protection Fault #1

Open
cedricfung opened this issue Jul 20, 2013 · 7 comments
Assignees
Labels
bug

Comments

@cedricfung
Copy link
Owner

@cedricfung cedricfung commented Jul 20, 2013

How to produce:

struct foo {
  mat4d m;
};

struct foo *f = malloc(sizeof(struct foo));
f->m[0] = 1;

However, if I use valgrind to do memcheck, it will work!

And code below also works:

struct foo f;
f.m[0] = 1;

mat4d m;
m[0] = 1;

mat4d *m = malloc(sizeof(mat4d));
(*m)[0] = 1;
@ghost ghost assigned cedricfung Jul 20, 2013
@crossle

This comment has been minimized.

Copy link

@crossle crossle commented Jul 20, 2013

Compile use gcc 4.7 on ubuntu 13.04
gcc -std=c99 -g -march=native -Wall -Wno-psabi -Iinclude -o test src/*.c tests/*.c -lm

@cedricfung

This comment has been minimized.

Copy link
Owner Author

@cedricfung cedricfung commented Jul 20, 2013

If I disable AVX, then the crash will disappear.

@cedricfung

This comment has been minimized.

Copy link
Owner Author

@cedricfung cedricfung commented Aug 18, 2013

gcc, If I wrap the vector in a union, the crash will disappear, even with AVX enabled.

But clang still crashes.

@cedricfung

This comment has been minimized.

Copy link
Owner Author

@cedricfung cedricfung commented Aug 19, 2013

[11899.948884] traps: valo[15344] general protection ip:40868a sp:7fffdfb96c80 error:0 in valo[400000+c000]

@cedricfung

This comment has been minimized.

Copy link
Owner Author

@cedricfung cedricfung commented Aug 20, 2013

Also the AVX of GCC has no performance improvement according to benchmark

@aktau

This comment has been minimized.

Copy link

@aktau aktau commented Sep 14, 2013

Actually, in my own experiments with vector types, AVX has a serious benefit. I noticed because I could only enable AVX quite recently on my OSX install. As the default gas on OSX doesn't understand AVX. But now that I use a workaround to use a newer gas gcc can emit AVX, in some cases the runtime dropped by 50%

@zygoloid

This comment has been minimized.

Copy link

@zygoloid zygoloid commented Dec 2, 2013

Your malloc call is probably returning underaligned memory. Some AVX instructions require 16 byte alignment, and malloc may only be giving you 8 byte alignment. Try using aligned_alloc(__alignof__(struct foo), sizeof(struct foo)).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.