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

segfault in aggregate function #47

Closed
c-cube opened this issue Mar 18, 2021 · 6 comments
Closed

segfault in aggregate function #47

c-cube opened this issue Mar 18, 2021 · 6 comments

Comments

@c-cube
Copy link
Contributor

c-cube commented Mar 18, 2021

trying to use Aggregate.create_fun1 but I consistently get a segfault in the finalize part. Accumulator type is string list option. A trace follows:

Program terminated with signal SIGSEGV, Segmentation fault.
#0  camlBenchpress__Test__finalize_1603 () at src/core/Test.ml:251
251	    | Nopath _ -> Db.Data.NULL
[Current thread is 1 (Thread 0x7f95d07fd640 (LWP 2552230))]
(gdb) bt
#0  camlBenchpress__Test__finalize_1603 () at src/core/Test.ml:251
#1  0x000056342437eb60 in caml_start_program ()
#2  0x0000563424353d6b in caml_sqlite3_user_function_final (ctx=0x7f95d07faed0) at sqlite3_stubs.c:1489
#3  0x00007f95d2f8328a in sqlite3VdbeMemFinalize () from /usr/lib/libsqlite3.so.0
#4  0x00007f95d2f74da4 in sqlite3VdbeExec () from /usr/lib/libsqlite3.so.0
#5  0x00007f95d2f7c0b8 in sqlite3_step () from /usr/lib/libsqlite3.so.0
#6  0x0000563424355d7d in caml_sqlite3_step (v_stmt=<optimized out>) at sqlite3_stubs.c:1174
#7  0x000056342423d917 in camlSqlite3_utils__next__423 () at src/sqlite3_utils.ml:171
#8  0x000056342423da3b in camlSqlite3_utils__make__427 () at src/sqlite3_utils.ml:181
#9  0x000056342423e9b3 in camlSqlite3_utils__fun_1351 () at src/sqlite3_utils.ml:323
#10 0x000056342423e0d6 in camlSqlite3_utils__finally__562 () at src/sqlite3_utils.ml:249
#11 0x0000563424226e1b in camlBenchpress__Test__fun_3901 () at src/core/Test.ml:418
#12 0x000056342421c34e in camlBenchpress__Misc__err_with_inner_3839 () at src/core/Misc.ml:203
#13 0x000056342422965b in camlBenchpress__Test__fun_4166 () at src/core/Test.ml:730
#14 0x000056342421c34e in camlBenchpress__Misc__err_with_inner_3839 () at src/core/Misc.ml:203
#15 0x000056342423e0d6 in camlSqlite3_utils__finally__562 () at src/sqlite3_utils.ml:249
#16 0x00005634241db285 in camlBenchpress_server__get_meta_4678 () at src/server/benchpress_server.ml:999
#17 0x00005634241dd102 in camlBenchpress_server__fun_11570 () at src/server/benchpress_server.ml:1110
#18 0x00005634241ce5d8 in camlBenchpress_server__f$27_3089 () at src/server/benchpress_server.ml:218
#19 0x000056342421c34e in camlBenchpress__Misc__err_with_inner_3839 () at src/core/Misc.ml:203
#20 0x00005634241ce4c5 in camlBenchpress_server__query_wrap_2895 () at src/server/benchpress_server.ml:223
#21 0x0000563424217b94 in camlTiny_httpd__handle_client__1334 () at src/Tiny_httpd.ml:913
#22 0x00005634242182ab in camlTiny_httpd__fun_2892 () at src/Tiny_httpd.ml:964
#23 0x000056342429f299 in camlThread__fun_286 () at thread.ml:39
#24 0x000056342437eb60 in caml_start_program ()
#25 0x00005634243575a0 in caml_thread_start ()
#26 0x00007f95d2e8a299 in start_thread () from /usr/lib/libpthread.so.0
#27 0x00007f95d2c67053 in clone () from /usr/lib/libc.so.6
@mmottl
Copy link
Owner

mmottl commented Mar 19, 2021

Thanks for the report, I have just pushed a potential fix for your problem. The init value of aggregate functions was missing its GC registration.

Could you please test the change and confirm that it fixes your problem? I'll make a new release if it does.

@c-cube
Copy link
Contributor Author

c-cube commented Mar 19, 2021

Seems like master requires OCaml 4.12, that's kind of annoying for me as I'm still mostly on 4.08. Let me see if I can make a new switch…

@c-cube
Copy link
Contributor Author

c-cube commented Mar 19, 2021

Update: it doesn't seem to fix my segfault sadly :/. The segfault still happens in the aggregate finalize function.

@mmottl
Copy link
Owner

mmottl commented Mar 19, 2021

I have added another potential fix. It's possible that your selection was empty in which case the step function will never be called. In that case the aggregation context was not initialized.

@c-cube
Copy link
Contributor Author

c-cube commented Mar 19, 2021

It seems to work now! Thank you!

(btw, in general, I really appreciate the quality of this library.)

@c-cube c-cube closed this as completed Mar 19, 2021
@mmottl
Copy link
Owner

mmottl commented Mar 19, 2021

Great, thanks for the help and feedback, I'll make a new release soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants