-
Notifications
You must be signed in to change notification settings - Fork 615
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
JNI Crash when calling MEDIAN function #418
Comments
I traced the stack violation down to the code in extension-functions.c, in the xFinal flow (after each xStep has been run): void node_iterate(node *n, map_iterator iter, void* p){
if(n){
if(n->l) {
node_iterate(n->l, iter, p);
}
iter(n->data, n->count, p);
if(n->r) {
node_iterate(n->r, iter, p);
}
}
} I'm not too familiar with how the JNI stack gets set and how it relates to the C stack, but on my machine it crashed after 16k entries, not enough . This also explains why the error happens when everything is sorted from largest to smallest. I checked node_insert (which gets run during xStep) and this was written in a tail-recursive style so the compiler can optimize out the extra stack frames. |
I was able to fix this by increasing the stack space to the JVM with the -Xss argument. I'll bring up the behavior of this function with the SQLite mailing list and see if it might make more sense for this to use a malloced stack for node traversal. |
Hi, I've run into a strange issue in JNI using the sqlite-jdbc driver and I was hoping someone here might have some ideas on how to get further. When calling the MEDIAN function on a sufficiently large array of sufficiently large doubles in descending order, a SIGSEGV causes my application to crash. The values being sorted from largest to smallest seems to matter, in that I can't reproduce this without it.
I've reproduced this crash in a project here: https://github.com/tildedave/sqlite-jdbc-crash and it crashes on both my Mac Powerbook and an x86_64 Virtualbox.
I wasn't able to reproduce this with a C program so my assumption is that this is some issue in how the JNI library is being built and packaged. Mostly I'm looking to understand this issue better so I can figure out what the right way to prevent it from happening is (we use these extension functions quite heavily).
Program Reproducing Error
Info From strace/GDB
On x86_64 Linux when run under
strace
the final failure is:The dumped core ends up looking like:
I dug around online and the
SEGV_ACCERR
error I'm getting looks like an illegal memory access from a stack frame violation.Other Things I Checked
Thanks for any help that you can provide.
The text was updated successfully, but these errors were encountered: