On 10/08/10 09:00, Christoffer Haglund wrote:

> Oh, sorry, that last reply wasn't very clear, let my try again. The
> problem occurs inside some proprietary code, so unfortunately I can't
> just copy the exact code that fails, but I'll try to describe it.
>
> There's a struct with the following definition
>
> typedef struct _session {
> ...
> char generic_buffer[255];
> } session_t;

Well the first question I'd be asking here, given that you are later 
accessing that buffer though an int pointer, is whether it is aligned on 
a 4 byte boundary or not..

> The function has the following definition:
>
> status_t do_stuff(input_t * input, char * charPtr)
> {
> int n = calculate_n(input);
> int value = calculate_value(input);
> int * intPrt = (int *) charPtr;
> for ( ; n < 0; n-- )
> *intPtr++ = value;
> }
>
> ...and when debugging I can see that calculate_n() returns 27 and
> calculate_value() returns 0x000000 for the test case when the
> application fails (which are correct values, compared to when the
> application is built with another compiler or with "-fno-tree-vectorize").

As I said above, my guess is that you have an alignment problem. On x86 
the alignment doesn't normally matter (though doing 4 byte accesses 
through an unaligned pointer is likely to be inefficient).

Once you start vectorising and using SSE instructions that will change 
however as many SSE instructions do care about alignment and will fault 
if the data is not correctly aligned.

Most probably the reason it works in valgrind is that in the process of 
annotating the code the actual instructions being used are changed and 
the ones valgrind has selected don't have the same alignment requirements.

Tom

-- 
Tom Hughes ([email protected])
http://compton.nu/

------------------------------------------------------------------------------
This SF.net email is sponsored by 

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
_______________________________________________
Valgrind-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/valgrind-users

Reply via email to