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

Fork imap process #133

Closed
jrse opened this issue Apr 18, 2018 · 3 comments
Closed

Fork imap process #133

jrse opened this issue Apr 18, 2018 · 3 comments
Assignees

Comments

@jrse
Copy link
Contributor

jrse commented Apr 18, 2018

When forking the imapprocess with active rbox_storage plugin,
the child process will wait forever for a mutex:

Stacktrace:

(gdb) bt
#0 0x00007f13661920cf in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0

#1 0x00007f1361379ace in Cond::Wait(Mutex&) () from /usr/lib64/librados.so.2

#2 0x00007f13613814eb in librados::RadosClient::watch_flush() () from /usr/lib64/librados.so.2

#3 0x00007f1361381753 in librados::RadosClient::shutdown() () from /usr/lib64/librados.so.2

#4 0x00007f1361336a58 in librados::Rados::shutdown() () from /usr/lib64/librados.so.2

#5 0x00007f1367948129 in __run_exit_handlers () from /lib64/libc.so.6

#6 0x00007f1367948175 in exit () from /lib64/libc.so.6

#7 0x00007f1363c32c5b in dg_resize_helper () from /opt/app/dovecot/lib/dovecot/libfundovecotgraphics.so.7

#8 0x00007f1363c32e2f in dovecot_graphics_resize_image_blob () from /opt/app/dovecot/lib/dovecot/libfundovecotgraphics.so.7

#9 0x00007f1364042bda in parse_message_part () from /opt/app/dovecot/lib/dovecot/lib91_fun_extended_listview_plugin.so

#10 0x00007f1364041a1e in parse_message_part () from /opt/app/dovecot/lib/dovecot/lib91_fun_extended_listview_plugin.so

#11 0x00007f136404367a in elv_save_mail_message_real () from /opt/app/dovecot/lib/dovecot/lib91_fun_extended_listview_plugin.so

#12 0x00007f13640438fd in elv_save_mail_message_by_guid () from /opt/app/dovecot/lib/dovecot/lib91_fun_extended_listview_plugin.so

#13 0x00007f1364043dda in elv_mail_transaction_commit () from /opt/app/dovecot/lib/dovecot/lib91_fun_extended_listview_plugin.so

#14 0x00007f1365d6b718 in notify_contexts_mail_transaction_commit () from /opt/app/dovecot/lib/dovecot/lib15_notify_plugin.so

#15 0x00007f1365d6c3b1 in notify_transaction_commit () from /opt/app/dovecot/lib/dovecot/lib15_notify_plugin.so

#16 0x00007f1365f7c354 in quota_mailbox_transaction_commit () from /opt/app/dovecot/lib/dovecot/lib10_quota_plugin.so

#17 0x00007f1367ff7171 in mailbox_transaction_commit_get_changes () from /opt/app/dovecot/lib/dovecot/libdovecot-storage.so.0

#18 0x00007f13682e68bc in mail_deliver_save () from /opt/app/dovecot/lib/dovecot/libdovecot-lda.so.0

#19 0x00007f13682e6c73 in mail_deliver () from /opt/app/dovecot/lib/dovecot/libdovecot-lda.so.0

#20 0x00005628c1429544 in client_input_data_write ()

#21 0x00005628c1429c93 in client_input_data_handle ()

#22 0x00005628c142bd8e in cmd_data ()

#23 0x00005628c14283bb in client_input_handle ()

#24 0x00007f1367d463fc in io_loop_call_io () from /opt/app/dovecot/lib/dovecot/libdovecot.so.0

#25 0x00007f1367d47707 in io_loop_handler_run_internal () from /opt/app/dovecot/lib/dovecot/libdovecot.so.0

#26 0x00007f1367d46485 in io_loop_handler_run () from /opt/app/dovecot/lib/dovecot/libdovecot.so.0

#27 0x00007f1367d46638 in io_loop_run () from /opt/app/dovecot/lib/dovecot/libdovecot.so.0

#28 0x00007f1367ce4113 in master_service_run () from /opt/app/dovecot/lib/dovecot/libdovecot.so.0

#29 0x00005628c14279f5 in main ()

@jrse
Copy link
Contributor Author

jrse commented Apr 18, 2018

Ansi C++ Standard:

§ 18.3/8The function exit() has additional behavior in this International Standard:— First, objects with static storage duration are destroyed and functions registered by calling atexit are

called. Non-local objects with static storage duration are destroyed in the reverse order of the completion

of their constructor. (Automatic objects are not destroyed as a result of calling exit().) ...

=> ~librados::Rados() is called due to the fact that librmb::RadosClient creates a static reference of librados::Rados on the stack this leads to the call of ~librados::Rados() ->shutdown();

There are two possible solutions for this problem:

  1. Do not create librados::Rados on the stack
  2. register additional exit handler with atexit and call _exit(0) if current process is the child process, within the exit handler to avoid additional calls to exit handlers.

jrse added a commit that referenced this issue Apr 18, 2018
A new exit handler is registerd with atexit. The handler detects if the
current process is a child (fork). If this is the case, the exit handler
will call _exit(EXIT_SUCCESS) to avoid additional calls to exit
handlers.
@jrse jrse self-assigned this Apr 18, 2018
@jrse
Copy link
Contributor Author

jrse commented Apr 18, 2018

we decided to implement solution number 2.

@jrse jrse closed this as completed Apr 18, 2018
@jrse jrse reopened this Apr 19, 2018
jrse added a commit that referenced this issue Apr 19, 2018
@jrse
Copy link
Contributor Author

jrse commented Apr 19, 2018

after discussing this issue again, we decided to implement solution 1, because solution two is more or less a workaround.

@jrse jrse closed this as completed Apr 19, 2018
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

1 participant