-
Notifications
You must be signed in to change notification settings - Fork 18
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
SIGPIPE ignored, resulting in: "Unable to flush stdout: Broken pipe" #170
Comments
Unconditionally overwriting signal handlers in external libraries (like in MariaDB C Connector) is really bad thing and obviously cause issues. I did not know that MariaDB C Connector is doing it. It is really an issue in MariaDB C Connector, so please report this bug. We can add hack workaround into DBD::MariaDB to restore SIGPIPE handler after calling initialization of MariaDB C Connector from affected version. But this is just another hack which does not solve the root of the issue. |
That makes sense. I have a workaround in my local wrapper to restore the handler now, but if this doesn't get changed upstream, then I think it would be best for DBD::MariaDB to do so. I did file a bug upstream now: Thanks, |
…andler MariaDB Connector/C 3.0.0 in function mysql_server_init() for non-Windows systems started setting SIGPIPE handler to SIG_IGN. This breaks Perl applications which installed its own SIGPIPE signal handler. As a workaround use Perl rsignal_save() function to save existing SIGPIPE handler before calling mysql_server_init() and after that restore saved handler via Perl rsignal_restore() function. Add a test which verifies that DBI->connect() which calls DBD::MariaDB's mariadb_dr_connect() function and which calls mysql_server_init(), does not overwrite $SIG{PIPE} handler set in Perl code. Fixes: perl5-dbi#170 See: http://jira.mariadb.org/browse/CONC-591
Thank you. The PR tests out ok for me. |
Unfortunately simple workaround does not work, needs lot of more changes, explanation is in the pull request #196. |
When DBD::MariaDB (or DBD::mysql) is used to connect to a database, the perl program thereafter fails to handle SIGPIPE as expected. I do not think this is necessarily the fault of DBD::MariaDB, but this might be the best place to handle it.
Here is an example test program:
Without any arguments, the program does not connect and behaves as expected:
The program prints lines until the pipe closes, then exits cleanly.
When directed to, the program will fail by connecting (and disconnecting) before printing lines:
This message is described here:
https://stackoverflow.com/questions/50507849/weird-error-after-perl-upgrade-unable-to-flush-stdout
An strace reveals that SIGPIPE is indeed being ignored:
This appears to be coming from this commit in the C connector:
mariadb-corporation/mariadb-connector-c@1cefbbe#diff-478b1bbb2170532b687be58bd28e9850ccc0b9a6aec137eb8fff7b8e6d1107bbR3460
I can't tell what is the reason for this behavior; the commit message is rather cryptic.
The test program demonstrates good behavior again after resetting the default action for SIGPIPE:
This is about as far as I can troubleshoot the issue myself; I think somebody more familiar with the C connector would need to either:
a. Tell me this is bad behavior and I should file a bug upstream for the C connector.
b. Work around this behavior be saving/resetting the SIGPIPE action within DBD::MariaDB
Thanks,
Corey
The text was updated successfully, but these errors were encountered: