From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 86673 invoked by alias); 26 Oct 2019 15:07:20 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 86665 invoked by uid 89); 26 Oct 2019 15:07:19 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.5 required=5.0 tests=AWL,BAYES_00,KAM_INFOUSMEBIZ,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 spammy=work-around, wextra, Wextra, inspired X-HELO: rila.superhosting.bg Received: from rila.superhosting.bg (HELO rila.superhosting.bg) (91.196.125.212) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 26 Oct 2019 15:07:18 +0000 Received: from [78.128.48.21] (port=47276 helo=[192.168.0.10]) by rila.superhosting.bg with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.92) (envelope-from ) id 1iONeq-000AWl-By for cygwin@cygwin.com; Sat, 26 Oct 2019 18:07:15 +0300 From: Roumen Petrov Subject: program exit code, "at exit" handler and explicit close of shared objects To: cygwin@cygwin.com Message-ID: Date: Sat, 26 Oct 2019 15:07:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0 SeaMonkey/2.49.5 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------C739CC2AFC9CAC34FBE7FDF6" X-OutGoing-Spam-Status: No, score=-0.2 X-IsSubscribed: yes X-SW-Source: 2019-10/txt/msg00161.txt.bz2 --------------C739CC2AFC9CAC34FBE7FDF6 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1372 Hello Cygwin developers, This email is mainly for issue with exist code for a program. It is inspired from openssl issue #10107 - "test_ssl_old freezes on cygwin". Actually after one or another work-around "unfreeze" test and this shows that one of subtests fail. This failure is main topic of this email. More about failed test "testing connection with weak DH, expecting failure". So failure is expected and program code try to exit with 1. Unfortunately OS returns zero exit code. Since version 1.1 OpenSSL uses "at exit handler" to clean-up allocated resources. Removing registered handler restores program exit code. So something in handler triggers issue. After additional tests (research) I was able to isolate issues to simple test case. Please find attached "test-dlclose.c" and "Makefile". First test is as is: $ make cc -g -Wall -Wextra test-dlclose.c -o test-dlclose ./test-dlclose exit with code 33 make: [Makefile:4: all] Error 33 (ignored) For next test change test-dlclose.c to define DLCLOSE_ATEXIT ( s/#if 0/#if 1/ ): $ make cc -g -Wall -Wextra test-dlclose.c -o test-dlclose ./test-dlclose exit with code 33 As is visible make does not report error, i.e. program exit code is zero. Is there a way to bypass issue? For protocol: $ uname -srvm -> CYGWIN_NT-10.0 3.0.7(0.338/5/3) 2019-04-30 18:08 x86_64 Regards, Roumen Petrov --------------C739CC2AFC9CAC34FBE7FDF6 Content-Type: text/x-csrc; name="test-dlclose.c" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="test-dlclose.c" Content-length: 701 #include #include #include void *handle = NULL; #if 0 # define DLCLOSE_ATEXIT 1 #endif #ifdef DLCLOSE_ATEXIT static void dlclose_atexit(void) { if (dlclose(handle) != 0) { fprintf(stderr, "dlclose fail : %s\n", dlerror()); } } #endif int main() { handle = dlopen("libz.so", RTLD_LAZY | RTLD_NOW); if (handle == NULL) { fprintf(stderr, "dlopen fail : %s\n", dlerror()); return 1; } #ifndef DLCLOSE_ATEXIT if (dlclose(handle) != 0) { fprintf(stderr, "dlclose fail : %s\n", dlerror()); return 2; } #else if (atexit(dlclose_atexit) != 0) { fprintf(stderr, "atexit fail\n"); return 3; } #endif printf("exit with code 33\n"); return 33; } --------------C739CC2AFC9CAC34FBE7FDF6 Content-Type: text/plain; charset=UTF-8; name="Makefile" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="Makefile" Content-length: 86 Q0ZMQUdTID0gLWcgLVdhbGwgLVdleHRyYQoKYWxsOiB0ZXN0LWRsY2xvc2UK CS0uL3Rlc3QtZGxjbG9zZQo= --------------C739CC2AFC9CAC34FBE7FDF6 Content-Type: text/plain; charset=us-ascii Content-length: 219 -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple --------------C739CC2AFC9CAC34FBE7FDF6--