This is the mail archive of the cygwin mailing list for the Cygwin project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
Some code which worked for me with a previous version of cygwin now seg faults. The essential sequence of events leading to the segfault appears to include: 1) The menu_driver() function of ncurses sets errno to -8 2) The dlsym() function of cygwin picks up the errno internally, uses sterror() and attempts to strcpy() the error string. Leaving aside the question of why ncurses is returning a negative errno, strerror() does not appear to be working as advertised by the man page. According to the man page: "If `errnum' is not a known error number, the result points to an empty string.". The following code demonstrates the problem: #include <stdio.h> #include <string.h> int main(int argc, char *argv[]) { char *s; s = strerror(-8); printf("strerror returned pointer %p\n", s); printf("string is \"%s\"\n", s); return 0; } The output on my system is: $ ./test-strerror.exe strerror returned pointer 0x8c Segmentation fault (core dumped) The assembler dump from gdb for the strerror function looks weird (as do some other parts of cygwin.dll). Perhaps I don't understand it very well. The weird part of strerror() is the beginning: Dump of assembler code for function strerror: 0x61015ac0 <strerror+0>: push %ebp 0x61015ac1 <strerror+1>: mov %esp,%ebp 0x61015ac3 <strerror+3>: sub $0x18,%esp 0x61015ac6 <strerror+6>: mov 0x8(%ebp),%eax 0x61015ac9 <strerror+9>: cmp 0x610e778c,%eax 0x61015acf <strerror+15>: jge 0x61015ae0 <strerror+32> 0x61015ad1 <strerror+17>: mov 0x610e77ac(,%eax,4),%eax 0x61015ad8 <strerror+24>: leave 0x61015ad9 <strerror+25>: ret According to this, the test for a valid error number only tests for really huge positive numbers... cygcheck.out attached: (See attached file: cygcheck.out) Bill Metzenthen Cochlear Limited Level 1, 174 Victoria Parade East Melbourne Vic 3002 Australia PH: +61 3 9662 1202 FAX: +61 3 9663 8652 Web: http://www.cochlear.com ============================================== "The information contained in this e-mail message may be confidential information, and may also be privileged. If you are not the intended recipient, any use, interference with, disclosure or copying of this material is unauthorised and prohibited. If you have received this message in error, please notify us by return email and delete the original message."
Attachment:
cygcheck.out
Description: Binary data
-- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |