<div dir="ltr">Found the culprit, it was missing header (libva_x11.h). If anybody interested to know, this caused the compiler to think the function will return a 32 bit pointer, so the compiler inserted a cltq statement into the assembly code which was flipping the upper 32 bits to all 1s. <br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Oct 21, 2015 at 12:15 PM, Ratin <span dir="ltr"><<a href="mailto:ratin3@gmail.com" target="_blank">ratin3@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"># uname -a<br>Linux nuc1 3.16.0-51-generic #69~14.04.1-Ubuntu SMP Wed Oct 7 15:32:41 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux<br><br><br><br></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Oct 21, 2015 at 12:13 PM, Ratin <span dir="ltr"><<a href="mailto:ratin3@gmail.com" target="_blank">ratin3@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div>Breakpoint 1, vaGetDisplay (native_dpy=0x7fffe4312870) at va_x11.c:154<br>154    {<br>(gdb) list<br>149    <br>150    <br>151    VADisplay vaGetDisplay (<br>152        Display *native_dpy /* implementation specific */<br>153    )<br>154    {<br>155      VADisplay dpy = NULL;<br>156      VADisplayContextP pDisplayContext;<br>157    <br>;;;<br>179          pDisplayContext->opaque          = NULL; <br>177          pDisplayContext->vaDestroy       = va_DisplayContextDestroy;<br>178          pDisplayContext->vaGetDriverName = va_DisplayContextGetDriverName;<br>181          dpy                              = (VADisplay)pDisplayContext;<br>195    }<br>(gdb) p dpy<br>$2 = (VADisplay) 0x7fffe42d3160<br>(gdb) n <========================== stack unroll happens here<br>(gdb) list<br>935            pVAAPICNTX->vaDisplay = (VADisplay)  <==== upper level code vaGetDisplay(pVAAPICNTX->mX11Display);<br>936             pVAAPICNTX->voWindow = pRendererParams->mWindow;<br>(gdb) p pVAAPICNTX->vaDisplay<br>$3 = (void *) 0xffffffffe42d3160<br><br><br>pVAAPICNTX is malloced struct ptr and one of the element of it is the vaDisplay declated like this : <br><br>typedef struct _VAAPICNTX<br>{<br>    uint32_t                  VAContextID;<br>   Window                   voWindow;<br>   int voWidth;<br>   int voHeight;<br>;;;<br>;;;<br>    VADisplay               vaDisplay;<br><br>;;;<br><br>;;;<br><br>}VAAPICNTX, *PVAAPICNTX; <br><br><br></div>As you can see, dpy above around line 195 in  vaGetDisplay function is shown as  0x7fffe42d3160 but once the program counter comes out of that function and stack rolling happens, and context switches to upper level code, the assigned value has   0xffffffffe42d3160 (sign extended vs unsigned). What might cause this ? Next instance when I call vaInitialize with this vaDisplay, it craches:<br><br>Program received signal SIGSEGV, Segmentation fault.<br>vaDisplayIsValid (dpy=0xffffffffe42d3450) at va.c:102<br>102        return pDisplayContext && (pDisplayContext->vadpy_magic == VA_DISPLAY_MAGIC) && pDisplayContext->vaIsValid(pDisplayContext);<br><br><br><br></div>Any help/pointer would be appreciated. Thanks<br><br><br><br>gcc --version<br>gcc (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4<br>Copyright (C) 2013 Free Software Foundation, Inc.<br>This is free software; see the source for copying conditions.  There is NO<br>warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.<br><br>ls -la <a href="http://libc-2.19.so" target="_blank">libc-2.19.so</a><br>-rwxr-xr-x 1 root root 1845024 Dec  4  2014 <a href="http://libc-2.19.so" target="_blank">libc-2.19.so</a><br><br>ldd --version<br>ldd (Ubuntu EGLIBC 2.19-0ubuntu6.5) 2.19<br><br><br></div><div>Platform: <br><br></div>Ratin<br><div><div><br><div><br><br><br></div></div></div></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>