<div dir="ltr">On 11 October 2013 10:17, Anton Smirnov <span dir="ltr"><<a href="mailto:dev@antonsmirnov.name" target="_blank">dev@antonsmirnov.name</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">i tried to hold CXIndex as static variable in native code (array of pointers to be more detailed) and pass just index to java back and then pass index to native code in order to hold variable in native code without passing.<div>

<br></div><div>Still the same result.</div></div></blockquote><div><br></div><div>So, IIRC, it's not the stack itself (stack variables), but the return value, that on Intel is at the bottom of the stack. So it doesn't matter where your native objects live, if you try to return them (or a pointer to them), and the stack itself is too small, it'd subtract too much from the stack pointer and then wouldn't find the correct return value because the offset would be negative, and you get corrupted pointers.</div>
<div><br></div><div>Adding a "int a[1024]" to each function fixed the problem because even subtracting a lot, it'd never be negative when compared to the return value, and going back to the return address was still possible. Give it a try, at least to see if that's the problem we're looking for.</div>
<div><br></div><div>Be wary that that was 10 years ago, JNI may have bred some new bugs since then...</div><div><br></div><div>cheers,</div><div>--renato</div></div></div></div>