X-Recipient: archive-cygwin AT delorie DOT com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:content-type :content-transfer-encoding:mime-version; q=dns; s=default; b=lsy WQ/YqsjdWt016DBdmW3b+wP7Va4NAowfjG9P/4QD3fOJv69Goqs0fnLeY8Oifuln 1Z+MjXY43EGrdbWcuqYJJmSkNEiwop/1QecdryLlNCkz4e+MXhODVn7m/UVvKiAU /VcZtUWJ+4uBoVEDfmHRqLMunMidcINjczsJpZSo= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:content-type :content-transfer-encoding:mime-version; s=default; bh=v1XPJToSR +JNEgbvh3Jf0wAdjFI=; b=cOKDClXYRVVyDKvPcAQxv3XmLt4WSXtPMKyK/1EWz 9W2vzq3x2qndIgTVt5lFymLhjq4JjpM7eZr5/yHpfF6ZfNTUahjvw3lmk5K2XQkJ +4R2KUi7XZpppEEefG9lE4c4aYGCwHZ3mU9YINGDxMmUVV2ZMsx3SDwlpUnRcfH0 J8= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.8 required=5.0 tests=AWL,BAYES_99,BAYES_999,MIME_BASE64_BLANKS,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_PASS autolearn=no version=3.3.2 spammy=Lucky, collins, ss, MUST X-HELO: emea01-db3-obe.outbound.protection.outlook.com From: =?utf-8?B?U3RhbmlzxYJhdyBXYXdzemN6YWs=?= To: "cygwin AT cygwin DOT com" Subject: Cygwin IPC - ftok() returns negative values - Bug Report Date: Wed, 29 Jun 2016 13:14:18 +0000 Message-ID: authentication-results: spf=none (sender IP is ) smtp.mailfrom=stanislaw DOT wawszczak AT iscg DOT pl; x-ms-office365-filtering-correlation-id: fdcee1c2-5043-4ad2-6fac-08d3a01f4738 x-microsoft-exchange-diagnostics: 1;AM3PR05MB337;6:lINzozYyKpvBrC4nIsVv/HVN2n0x/I4pmwRVUusK9kuDZNHyQBhUXcPu3/WUmqT5IzDODVI6i7a/dnqa4HuOtd7PWIwTOzwVSzbtu9s9TEu2XadXhO/V1+S0yH61Lv8shJl3RMQ3Z+XsHVDzL6nGZ1PV6Bdp2W4tZ9umEc+dO47TCr47etPRiAHOnqff0Fbk+VtkcW9Gj0q9fzxxYBfjMLNoAO36WhWb+X8b8DP4Vjt6hyfIdBRbrV07km85/UYE+YKTM6Ys7js6yhHUX8NVMzFz25YVF1G8pXIKG1mGOIzpSt8dM68H2wy/BqX/aZqoP1N0m2AcM7iL0MY6YijSaw==;5:tYJfJyS/SK/SqbkC6ct/ZZypXBwBuCBQ42xocwOGMBSNgtTpArNALmz3rheWlN4iOz4YRnqskr3BRgY8dI1vIScpEmDkR8pjNhwAUotMbCucWH+o2SGl5kU+IpW8vaWpBAMTmRq+ewHbQA+5qVmQ4A==;24:VU5xk/F+UxptRCDNCI6UZM3UrkARvPZiXLMlHYR1NUeW0t2NmdaE53ouizIQmaqKfV92KAkSeYqKQqRFD7G98/VmQyuoS4V+jE2nxN8FWOk=;7:ZrlvIPK/oHBPKrztrVJbgNruARvp2Ssz2HrycfCMqKtwf6V5P9ZoVXMLMKAVPIG7rcbIGuJVmmUKbKw1zB3cwWqlNIGmXusjBkUlFFiIG6lDGcMJ7fR7ujbWVfW2SNJD42uInaGW7rb4nedPYpcu0pVGjMBozh/Q3mz+4V23BjrPGKm6xOYD9aOsTmF2idoR19slIsdeHjP3Nchwml0GAAazJrRkPSMJjiD7IAqZZA17hzI+Ctyo70TAPNbTKKV9kWn9JO1zhUAEMwwlY7ANIQ== x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:AM3PR05MB337; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(194151415913766); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6040130)(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001)(6041072)(6043046);SRVR:AM3PR05MB337;BCL:0;PCL:0;RULEID:;SRVR:AM3PR05MB337; x-forefront-prvs: 09888BC01D x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(7916002)(189002)(199003)(54356999)(74482002)(5002640100001)(586003)(5003600100003)(305945005)(8676002)(7846002)(7736002)(87936001)(11100500001)(50986999)(66066001)(8936002)(1730700003)(68736007)(81156014)(76576001)(3846002)(7696003)(81166006)(102836003)(19580395003)(189998001)(6116002)(3660700001)(2906002)(3280700002)(86362001)(107886002)(89622001)(106356001)(74316001)(101416001)(85202003)(2900100001)(97736004)(5640700001)(9686002)(575784001)(19580405001)(33656002)(2501003)(5890100001)(85182001)(2351001)(5250100002)(92566002)(110136002)(229853001)(105586002)(450100001)(569005);DIR:OUT;SFP:1102;SCL:1;SRVR:AM3PR05MB337;H:AM3PR05MB339.eurprd05.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; received-spf: None (protection.outlook.com: iscg.pl does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 X-OriginatorOrg: iscg.pl X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Jun 2016 13:14:18.6311 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 5d91e211-393e-4cc2-bc59-c077247cadc0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM3PR05MB337 X-IsSubscribed: yes Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by delorie.com id u5TDEv89022619 Dear All,   I have had to compile sblim-sfcbd-1.4.10 on Cygwin. It is using IPC semaphores. Unfortunately it is returning wrong value as the result of complicated bit-wise logical operations. I have tried to “hack the system” and make multiplication of returned value by -1, but it triggers error in semget() Environment: Windows 2012 R2 with latest patches I have installed Cygwin from official installer couple days ago.   I have attached the gdb session from such invocation. You can see the path and id in arguments are correct and stat() function returns correct values. Finally result in %rax is negative: rax            0xaf0b000701cc1d53       -5833568862233420461 Best Regards, Stanislaw Wawszczak Iscg Poland ############################################################### # GDB session ###############################################################   Breakpoint 1, ftok (path=0x4b11f1912 "/usr/local/sbin/sfcbd.exe", id=83) at /usr/src/debug/cygwin-2.5.2-1/winsup/cygwin/ipc.cc:18 18      { (gdb) x/5i    0x4b1201438 :   (bad)    0x4b1201439 : add    %al,(%rax)    0x4b120143b : add    %al,(%rdi)    0x4b120143d : add    %al,(%rax)    0x4b120143f : add    %al,(%rbx) (gdb) x/5i    0x4b1201441 :       add    %al,(%rax)    0x4b1201443 :       add    %al,0x0(%rip)        # 0x4b1201449    0x4b1201449 :      add    %al,(%rax)    0x4b120144b :      add    %al,(%rax)   0x4b120144d :      add    %al,(%rax) (gdb) x/5i $pc => 0x1800c6e50 :        push   %rbx    0x1800c6e51 :      sub    $0xa0,%rsp    0x1800c6e58 :      mov    %edx,%ebx   0x1800c6e5a :     lea    0x20(%rsp),%rdx    0x1800c6e5f :     callq  0x180144970 (gdb) x/5i    0x1800c6e64 :     test   %eax,%eax    0x1800c6e66 :     jne    0x1800c6ec0    0x1800c6e68 :     mov    0x20(%rsp),%edx    0x1800c6e6c :     mov    0x28(%rsp),%r8    0x1800c6e71 :     mov    %edx,%eax (gdb) x/5i    0x1800c6e73 :     movzbl %dl,%edx    0x1800c6e76 :     and    $0xff0000,%eax    0x1800c6e7b :     shl    $0x30,%rdx    0x1800c6e7f :     shl    $0x28,%rax    0x1800c6e83 :     or     %rdx,%rax (gdb) x/5i    0x1800c6e86 :     movabs $0xffffc00000000000,%rdx    0x1800c6e90 :     and    %r8,%rdx    0x1800c6e93 :     and    $0x3fffff,%r8d    0x1800c6e9a :     shr    $0x10,%rdx    0x1800c6e9e :     shl    $0x8,%r8 (gdb) x/5i    0x1800c6ea2 :     or     %rdx,%rax    0x1800c6ea5 :     mov    %rax,%rcx    0x1800c6ea8 :     movzbl %bl,%eax    0x1800c6eab :     or     %r8,%rax    0x1800c6eae :     or     %rcx,%rax (gdb) x/5i    0x1800c6eb1 :     add    $0xa0,%rsp    0x1800c6eb8 :    pop    %rbx    0x1800c6eb9 :    retq    0x1800c6eba :    nopw   0x0(%rax,%rax,1)    0x1800c6ec0 :    mov    $0xffffffffffffffff,%rax (gdb) x/5i    0x1800c6ec7 :    jmp    0x1800c6eb1    0x1800c6ec9 :      nop    0x1800c6eca :      nop    0x1800c6ecb :      nop    0x1800c6ecc :      nop (gdb) ni 0x00000001800c6e51      18      { (gdb) ni 18      { (gdb) ni 21        if (stat64 (path, &statbuf)) (gdb) x/5i $pc => 0x1800c6e5a :     lea    0x20(%rsp),%rdx    0x1800c6e5f :     callq  0x180144970    0x1800c6e64 :     test   %eax,%eax    0x1800c6e66 :     jne    0x1800c6ec0    0x1800c6e68 :     mov    0x20(%rsp),%edx (gdb) ni 0x00000001800c6e5f      21        if (stat64 (path, &statbuf)) (gdb) x/5i $pc => 0x1800c6e5f :     callq  0x180144970    0x1800c6e64 :     test   %eax,%eax    0x1800c6e66 :     jne    0x1800c6ec0    0x1800c6e68 :     mov    0x20(%rsp),%edx    0x1800c6e6c :     mov    0x28(%rsp),%r8 (gdb) ni 0x00000001800c6e64      21        if (stat64 (path, &statbuf)) (gdb) x/5i $pc => 0x1800c6e64 :     test   %eax,%eax    0x1800c6e66 :     jne    0x1800c6ec0    0x1800c6e68 :     mov    0x20(%rsp),%edx    0x1800c6e6c :     mov    0x28(%rsp),%r8    0x1800c6e71 :     mov    %edx,%eax (gdb) r %eax The program being debugged has been started already. Start it from the beginning? (y or n) n Program not restarted. (gdb) info registers rax            0x0      0 rbx            0x53     83 rcx            0x7ffa7b5dac7a   140713788288122 rdx            0x0      0 rsi            0x4      4 rdi            0x10040596e      4299184494 rbp            0x4b1201464      0x4b1201464 rsp            0xffffc930       0xffffc930 r8             0xffffc768       4294952808 r9             0x4b1201464      20151538788 r10            0x0      0 r11            0x203    515 r12            0x4b11ef0c0      20151464128 r13            0x20     32 r14            0x0      0 r15            0x5      5 rip            0x1800c6e64      0x1800c6e64 eflags         0x202    [ IF ] cs             0x33     51 ss             0x2b     43 ds             0x2b     43 es             0x2b     43 fs             0x53     83 gs             0x2b     43 (gdb) ni 0x00000001800c6e66      21        if (stat64 (path, &statbuf)) (gdb) r %eax The program being debugged has been started already. Start it from the beginning? (y or n) n Program not restarted. (gdb) x/5i $pc => 0x1800c6e66 :     jne    0x1800c6ec0    0x1800c6e68 :     mov    0x20(%rsp),%edx    0x1800c6e6c :     mov    0x28(%rsp),%r8    0x1800c6e71 :     mov    %edx,%eax    0x1800c6e73 :     movzbl %dl,%edx (gdb) ni 78        tmp  = (((key_t) statbuf.st_dev) & 0x0000000000ff0000LL) << 40; (gdb) print 0x20(%rsp A syntax error in expression, near `%rsp'. (gdb) print 0x20(%rsp) A syntax error in expression, near `%rsp)'. (gdb) ni 83        tmp |= (((key_t) statbuf.st_ino) & 0xffffc00000000000LL) >> 16; (gdb) x/5i $pc => 0x1800c6e6c :     mov    0x28(%rsp),%r8    0x1800c6e71 :     mov    %edx,%eax    0x1800c6e73 :     movzbl %dl,%edx    0x1800c6e76 :     and    $0xff0000,%eax    0x1800c6e7b :     shl    $0x30,%rdx (gdb) info registers rax            0x0      0 rbx            0x53     83 rcx            0x7ffa7b5dac7a   140713788288122 rdx            0x7eafb40b       2125444107 rsi            0x4      4 rdi            0x10040596e      4299184494 rbp            0x4b1201464      0x4b1201464 rsp            0xffffc930       0xffffc930 r8             0xffffc768       4294952808 r9             0x4b1201464      20151538788 r10            0x0      0 r11            0x203    515 r12            0x4b11ef0c0      20151464128 r13            0x20     32 r14            0x0      0 r15            0x5      5 rip            0x1800c6e6c      0x1800c6e6c eflags         0x246    [ PF ZF IF ] cs             0x33     51 ss             0x2b     43 ds             0x2b     43 es             0x2b     43 fs             0x53     83 gs             0x2b     43 (gdb) ni 78        tmp  = (((key_t) statbuf.st_dev) & 0x0000000000ff0000LL) << 40; (gdb) x/5i $pc => 0x1800c6e71 :     mov    %edx,%eax    0x1800c6e73 :     movzbl %dl,%edx    0x1800c6e76 :     and    $0xff0000,%eax    0x1800c6e7b :     shl    $0x30,%rdx    0x1800c6e7f :     shl    $0x28,%rax (gdb) ni 83        tmp |= (((key_t) statbuf.st_ino) & 0xffffc00000000000LL) >> 16; (gdb) x/5i $pc => 0x1800c6e73 :     movzbl %dl,%edx    0x1800c6e76 :     and    $0xff0000,%eax    0x1800c6e7b :     shl    $0x30,%rdx    0x1800c6e7f :     shl    $0x28,%rax    0x1800c6e83 :     or     %rdx,%rax (gdb) info registers rax            0x7eafb40b       2125444107 rbx            0x53     83 rcx            0x7ffa7b5dac7a   140713788288122 rdx            0x7eafb40b       2125444107 rsi            0x4      4 rdi            0x10040596e      4299184494 rbp            0x4b1201464      0x4b1201464 rsp            0xffffc930       0xffffc930 r8             0x700000001cc1d  1970324837092381 r9             0x4b1201464      20151538788 r10            0x0      0 r11            0x203    515 r12            0x4b11ef0c0      20151464128 r13            0x20     32 r14            0x0      0 r15            0x5      5 rip            0x1800c6e73      0x1800c6e73 eflags         0x246    [ PF ZF IF ] cs             0x33     51 ss             0x2b     43 ds             0x2b     43 es             0x2b     43 fs             0x53     83 gs             0x2b     43 (gdb) ni 78        tmp  = (((key_t) statbuf.st_dev) & 0x0000000000ff0000LL) << 40; (gdb) info registers rax            0x7eafb40b       2125444107 rbx            0x53     83 rcx            0x7ffa7b5dac7a   140713788288122 rdx            0xb      11 rsi            0x4      4 rdi            0x10040596e      4299184494 rbp            0x4b1201464      0x4b1201464 rsp            0xffffc930       0xffffc930 r8             0x700000001cc1d  1970324837092381 r9             0x4b1201464      20151538788 r10            0x0      0 r11            0x203    515 r12            0x4b11ef0c0      20151464128 r13            0x20     32 r14            0x0      0 r15            0x5      5 rip            0x1800c6e76      0x1800c6e76 eflags         0x246    [ PF ZF IF ] cs             0x33     51 ss             0x2b     43 ds             0x2b     43 es             0x2b     43 fs             0x53     83 gs             0x2b     43 (gdb) x/5i $pc => 0x1800c6e76 :     and    $0xff0000,%eax    0x1800c6e7b :     shl    $0x30,%rdx    0x1800c6e7f :     shl    $0x28,%rax    0x1800c6e83 :     or     %rdx,%rax    0x1800c6e86 :     movabs $0xffffc00000000000,%rdx (gdb) ni; x/5i $pc; info registers Invalid character ';' in expression. (gdb) ni 83        tmp |= (((key_t) statbuf.st_ino) & 0xffffc00000000000LL) >> 16; (gdb) x/5i $pc => 0x1800c6e7b :     shl    $0x30,%rdx    0x1800c6e7f :     shl    $0x28,%rax    0x1800c6e83 :     or     %rdx,%rax    0x1800c6e86 :     movabs $0xffffc00000000000,%rdx    0x1800c6e90 :     and    %r8,%rdx (gdb) info registers rax            0xaf0000 11468800 rbx            0x53     83 rcx            0x7ffa7b5dac7a   140713788288122 rdx            0xb      11 rsi            0x4      4 rdi            0x10040596e      4299184494 rbp            0x4b1201464      0x4b1201464 rsp            0xffffc930       0xffffc930 r8             0x700000001cc1d  1970324837092381 r9             0x4b1201464      20151538788 r10            0x0      0 r11            0x203    515 r12            0x4b11ef0c0      20151464128 r13            0x20     32 r14            0x0      0 r15            0x5      5 rip            0x1800c6e7b      0x1800c6e7b eflags         0x206    [ PF IF ] cs             0x33     51 ss             0x2b     43 ds             0x2b     43 es             0x2b     43 fs             0x53     83 gs             0x2b     43 (gdb) ni 78        tmp  = (((key_t) statbuf.st_dev) & 0x0000000000ff0000LL) << 40; (gdb) info registers rax            0xaf0000 11468800 rbx            0x53     83 rcx            0x7ffa7b5dac7a   140713788288122 rdx            0xb000000000000  3096224743817216 rsi            0x4      4 rdi            0x10040596e      4299184494 rbp            0x4b1201464      0x4b1201464 rsp            0xffffc930       0xffffc930 r8             0x700000001cc1d  1970324837092381 r9             0x4b1201464      20151538788 r10            0x0      0 r11            0x203    515 r12            0x4b11ef0c0      20151464128 r13            0x20     32 r14            0x0      0 r15            0x5      5 rip            0x1800c6e7f      0x1800c6e7f eflags         0x206    [ PF IF ] cs             0x33     51 ss             0x2b     43 ds             0x2b     43 es             0x2b     43 fs             0x53     83 gs             0x2b     43 (gdb) x/5i $pc => 0x1800c6e7f :     shl    $0x28,%rax    0x1800c6e83 :     or     %rdx,%rax    0x1800c6e86 :     movabs $0xffffc00000000000,%rdx    0x1800c6e90 :     and    %r8,%rdx    0x1800c6e93 :     and    $0x3fffff,%r8d (gdb) ni 83        tmp |= (((key_t) statbuf.st_ino) & 0xffffc00000000000LL) >> 16; (gdb) x/5i $pc => 0x1800c6e83 :     or     %rdx,%rax    0x1800c6e86 :     movabs $0xffffc00000000000,%rdx    0x1800c6e90 :     and    %r8,%rdx    0x1800c6e93 :     and    $0x3fffff,%r8d    0x1800c6e9a :     shr    $0x10,%rdx (gdb) info registers rax            0xaf00000000000000       -5836665117072162816 rbx            0x53     83 rcx            0x7ffa7b5dac7a   140713788288122 rdx            0xb000000000000  3096224743817216 rsi            0x4      4 rdi            0x10040596e      4299184494 rbp            0x4b1201464      0x4b1201464 rsp            0xffffc930       0xffffc930 r8             0x700000001cc1d  1970324837092381 r9             0x4b1201464      20151538788 r10            0x0      0 r11            0x203    515 r12            0x4b11ef0c0      20151464128 r13            0x20     32 r14            0x0      0 r15            0x5      5 rip            0x1800c6e83      0x1800c6e83 eflags         0x286    [ PF SF IF ] cs             0x33     51 ss             0x2b     43 ds             0x2b     43 es             0x2b     43 fs             0x53     83 gs             0x2b     43 (gdb) ni 0x00000001800c6e86      83        tmp |= (((key_t) statbuf.st_ino) & 0xffffc00000000000LL) >> 16; (gdb) x/5i $pc => 0x1800c6e86 :     movabs $0xffffc00000000000,%rdx    0x1800c6e90 :     and    %r8,%rdx    0x1800c6e93 :     and    $0x3fffff,%r8d    0x1800c6e9a :     shr    $0x10,%rdx    0x1800c6e9e :     shl    $0x8,%r8 (gdb) info registers rax            0xaf0b000000000000       -5833568892328345600 rbx            0x53     83 rcx            0x7ffa7b5dac7a   140713788288122 rdx            0xb000000000000  3096224743817216 rsi            0x4      4 rdi            0x10040596e      4299184494 rbp            0x4b1201464      0x4b1201464 rsp            0xffffc930       0xffffc930 r8             0x700000001cc1d  1970324837092381 r9             0x4b1201464      20151538788 r10            0x0      0 r11            0x203    515 r12            0x4b11ef0c0      20151464128 r13            0x20     32 r14            0x0      0 r15            0x5      5 rip            0x1800c6e86      0x1800c6e86 eflags         0x286    [ PF SF IF ] cs             0x33     51 ss             0x2b     43 ds             0x2b     43 es             0x2b     43 fs             0x53     83 gs             0x2b     43 (gdb) ni 0x00000001800c6e90      83        tmp |= (((key_t) statbuf.st_ino) & 0xffffc00000000000LL) >> 16; (gdb) info registers rax            0xaf0b000000000000       -5833568892328345600 rbx            0x53     83 rcx            0x7ffa7b5dac7a   140713788288122 rdx            0xffffc00000000000       -70368744177664 rsi            0x4      4 rdi            0x10040596e      4299184494 rbp            0x4b1201464      0x4b1201464 rsp            0xffffc930       0xffffc930 r8             0x700000001cc1d  1970324837092381 r9             0x4b1201464      20151538788 r10            0x0      0 r11            0x203    515 r12            0x4b11ef0c0      20151464128 r13            0x20     32 r14            0x0      0 r15            0x5      5 rip            0x1800c6e90      0x1800c6e90 eflags         0x286    [ PF SF IF ] cs             0x33     51 ss             0x2b     43 ds             0x2b     43 es             0x2b     43 fs             0x53     83 gs             0x2b     43 (gdb) ni 0x00000001800c6e93      83        tmp |= (((key_t) statbuf.st_ino) & 0xffffc00000000000LL) >> 16; (gdb) x/5i $pc => 0x1800c6e93 :     and    $0x3fffff,%r8d    0x1800c6e9a :     shr    $0x10,%rdx    0x1800c6e9e :     shl    $0x8,%r8    0x1800c6ea2 :     or     %rdx,%rax    0x1800c6ea5 :     mov    %rax,%rcx (gdb) info registers rax            0xaf0b000000000000       -5833568892328345600 rbx            0x53     83 rcx            0x7ffa7b5dac7a   140713788288122 rdx            0x7000000000000  1970324836974592 rsi            0x4      4 rdi            0x10040596e      4299184494 rbp            0x4b1201464      0x4b1201464 rsp            0xffffc930       0xffffc930 r8             0x700000001cc1d  1970324837092381 r9             0x4b1201464      20151538788 r10            0x0      0 r11            0x203    515 r12            0x4b11ef0c0      20151464128 r13            0x20     32 r14            0x0      0 r15            0x5      5 rip            0x1800c6e93      0x1800c6e93 eflags         0x206    [ PF IF ] cs             0x33     51 ss             0x2b     43 ds             0x2b     43 es             0x2b     43 fs             0x53     83 gs             0x2b     43 (gdb) ni 0x00000001800c6e9a      83        tmp |= (((key_t) statbuf.st_ino) & 0xffffc00000000000LL) >> 16; (gdb) ni 0x00000001800c6e9e      83        tmp |= (((key_t) statbuf.st_ino) & 0xffffc00000000000LL) >> 16; (gdb) info registers rax            0xaf0b000000000000       -5833568892328345600 rbx            0x53     83 rcx            0x7ffa7b5dac7a   140713788288122 rdx            0x700000000      30064771072 rsi            0x4      4 rdi            0x10040596e      4299184494 rbp            0x4b1201464      0x4b1201464 rsp            0xffffc930       0xffffc930 r8             0x1cc1d  117789 r9             0x4b1201464      20151538788 r10            0x0      0 r11            0x203    515 r12            0x4b11ef0c0      20151464128 r13            0x20     32 r14            0x0      0 r15            0x5      5 rip            0x1800c6e9e      0x1800c6e9e eflags         0x206    [ PF IF ] cs             0x33     51 ss             0x2b     43 ds             0x2b     43 es             0x2b     43 fs             0x53     83 gs             0x2b     43 (gdb) ni 0x00000001800c6ea2      83        tmp |= (((key_t) statbuf.st_ino) & 0xffffc00000000000LL) >> 16; (gdb) ni 0x00000001800c6ea5      83        tmp |= (((key_t) statbuf.st_ino) & 0xffffc00000000000LL) >> 16; (gdb) info registers rax            0xaf0b000700000000       -5833568862263574528 rbx            0x53     83 rcx            0x7ffa7b5dac7a   140713788288122 rdx            0x700000000      30064771072 rsi            0x4      4 rdi            0x10040596e      4299184494 rbp            0x4b1201464      0x4b1201464 rsp            0xffffc930       0xffffc930 r8             0x1cc1d00        30153984 r9             0x4b1201464      20151538788 r10            0x0      0 r11            0x203    515 r12            0x4b11ef0c0      20151464128 r13            0x20     32 r14            0x0      0 r15            0x5      5 rip            0x1800c6ea5      0x1800c6ea5 eflags         0x286    [ PF SF IF ] cs             0x33     51 ss             0x2b     43 ds             0x2b     43 es             0x2b     43 fs             0x53     83 gs             0x2b     43 (gdb) x/5i $pc => 0x1800c6ea5 :     mov    %rax,%rcx    0x1800c6ea8 :     movzbl %bl,%eax    0x1800c6eab :     or     %r8,%rax    0x1800c6eae :     or     %rcx,%rax    0x1800c6eb1 :     add    $0xa0,%rsp (gdb) ni 0x00000001800c6ea8      83        tmp |= (((key_t) statbuf.st_ino) & 0xffffc00000000000LL) >> 16; (gdb) x/5i $pc => 0x1800c6ea8 :     movzbl %bl,%eax    0x1800c6eab :     or     %r8,%rax    0x1800c6eae :     or     %rcx,%rax    0x1800c6eb1 :     add    $0xa0,%rsp    0x1800c6eb8 :    pop    %rbx (gdb) info registers rax            0xaf0b000700000000       -5833568862263574528 rbx            0x53     83 rcx            0xaf0b000700000000       -5833568862263574528 rdx            0x700000000      30064771072 rsi            0x4      4 rdi            0x10040596e      4299184494 rbp            0x4b1201464      0x4b1201464 rsp            0xffffc930       0xffffc930 r8             0x1cc1d00        30153984 r9             0x4b1201464      20151538788 r10            0x0      0 r11            0x203    515 r12            0x4b11ef0c0      20151464128 r13            0x20     32 r14            0x0      0 r15            0x5      5 rip            0x1800c6ea8      0x1800c6ea8 eflags         0x286    [ PF SF IF ] cs             0x33     51 ss             0x2b     43 ds             0x2b     43 es             0x2b     43 fs             0x53     83 gs             0x2b     43 (gdb) ni 0x00000001800c6eab      83        tmp |= (((key_t) statbuf.st_ino) & 0xffffc00000000000LL) >> 16; (gdb) info registers rax            0x53     83 rbx            0x53     83 rcx            0xaf0b000700000000       -5833568862263574528 rdx            0x700000000      30064771072 rsi            0x4      4 rdi            0x10040596e      4299184494 rbp            0x4b1201464      0x4b1201464 rsp            0xffffc930       0xffffc930 r8             0x1cc1d00        30153984 r9             0x4b1201464      20151538788 r10            0x0      0 r11            0x203    515 r12            0x4b11ef0c0      20151464128 r13            0x20     32 r14            0x0      0 r15            0x5      5 rip            0x1800c6eab      0x1800c6eab eflags         0x286    [ PF SF IF ] cs             0x33     51 ss             0x2b     43 ds             0x2b     43 es             0x2b     43 fs             0x53     83 gs             0x2b     43 (gdb) ni 0x00000001800c6eae      83        tmp |= (((key_t) statbuf.st_ino) & 0xffffc00000000000LL) >> 16; (gdb) info registers rax            0x1cc1d53        30154067 rbx            0x53     83 rcx            0xaf0b000700000000       -5833568862263574528 rdx            0x700000000      30064771072 rsi            0x4      4 rdi            0x10040596e      4299184494 rbp            0x4b1201464      0x4b1201464 rsp            0xffffc930       0xffffc930 r8             0x1cc1d00        30153984 r9             0x4b1201464      20151538788 r10            0x0      0 r11            0x203    515 r12            0x4b11ef0c0      20151464128 r13            0x20     32 r14            0x0      0 r15            0x5      5 rip            0x1800c6eae      0x1800c6eae eflags         0x206    [ PF IF ] cs             0x33     51 ss             0x2b     43 ds             0x2b     43 es             0x2b     43 fs             0x53     83 gs             0x2b     43 (gdb) x/5i $pc => 0x1800c6eae :     or     %rcx,%rax    0x1800c6eb1 :     add    $0xa0,%rsp    0x1800c6eb8 :    pop    %rbx    0x1800c6eb9 :    retq    0x1800c6eba :    nopw   0x0(%rax,%rax,1) (gdb) info registers rax            0x1cc1d53        30154067 rbx            0x53     83 rcx            0xaf0b000700000000       -5833568862263574528 rdx            0x700000000      30064771072 rsi            0x4      4 rdi            0x10040596e      4299184494 rbp            0x4b1201464      0x4b1201464 rsp            0xffffc930       0xffffc930 r8             0x1cc1d00        30153984 r9             0x4b1201464      20151538788 r10            0x0      0 r11            0x203    515 r12            0x4b11ef0c0      20151464128 r13            0x20     32 r14            0x0      0 r15            0x5      5 rip            0x1800c6eae      0x1800c6eae eflags         0x206    [ PF IF ] cs             0x33     51 ss             0x2b     43 ds             0x2b     43 es             0x2b     43 fs             0x53     83 gs             0x2b     43 (gdb) ni 89      } (gdb) info registers rax            0xaf0b000701cc1d53       -5833568862233420461 rbx            0x53     83 rcx            0xaf0b000700000000       -5833568862263574528 rdx            0x700000000      30064771072 rsi            0x4      4 rdi            0x10040596e      4299184494 rbp            0x4b1201464      0x4b1201464 rsp            0xffffc930       0xffffc930 r8             0x1cc1d00        30153984 r9             0x4b1201464      20151538788 r10            0x0      0 r11            0x203    515 r12            0x4b11ef0c0      20151464128 r13            0x20     32 r14            0x0      0 r15            0x5      5 rip            0x1800c6eb1      0x1800c6eb1 eflags         0x286    [ PF SF IF ] cs             0x33     51 ss             0x2b     43 ds             0x2b     43 es             0x2b     43 fs             0x53     83 gs             0x2b     43 (gdb) ni 0x00000001800c6eb8      89      } (gdb) x/5i $pc => 0x1800c6eb8 :    pop    %rbx    0x1800c6eb9 :    retq    0x1800c6eba :    nopw   0x0(%rax,%rax,1)    0x1800c6ec0 :    mov    $0xffffffffffffffff,%rax    0x1800c6ec7 :    jmp    0x1800c6eb1 (gdb) ni 0x00000001800c6eb9      89      } (gdb) n   ############################################################## # ftok() C source from debugger ##############################################################     /* ipc.cc: Single unix specification IPC interface for Cygwin      Originally written by Robert Collins    Updated to 64 bit key_t by Charles Wilson      This file is part of Cygwin.      This software is a copyrighted work licensed under the terms of the    Cygwin license.  Please consult the file "CYGWIN_LICENSE" for    details. */   #include "winsup.h" #include   /* Notes: we return a valid key even if id's low order 8 bits are 0. */ extern "C" key_t ftok (const char *path, int id) {   struct stat statbuf;   key_t tmp;   if (stat64 (path, &statbuf))     {       /* stat set the appropriate errno for us */       return (key_t) -1;     }     /* Since Cygwin 1.5      dev_t is 32bits for cygwin      ino_t is 64bits for cygwin      and we need 8 bits for the id.      thus key_t needs 104 bits total -- but we only have 64 (long long)      We will have to alias; leaving open the possibility that the same      key will be returned for multiple files.  This possibility exists      also on Linux; the question is, how to minimize this possibility.        How to solve?  Well, based on C. Vinschen's research, the nFileIndex*      words vary as follows, on a partition with > 110,000 files      nFileIndexHigh:    564 values between 0x00010000 -- 0xffff0000      nFileIndexLow : 103812 values between 0x00000000 -- 0x0003ffff      R. Collins suggests that these may represent a tree path,      and that it would require ~2.9M files to force the tree depth      to increase and reveal more bit usage.        Implementation details: dev_t is 32bits, but is formed by                 device(32bits) << 16 | unit(32bits)      But device is ACTUALLY == status & FH_DEVMASK, where FH_DEVMASK      is 0x00000fff --> 12 bits        As it happens, the maximum number of devices is actually      FH_NDEV, not FH_DEVMASK, where FH_NDEV is currently 0x0000001d.      However, FH_NDEV grows as new device types are added.  So      currently the device number needs 5 bits, but later?  Let's      take a cue from Linux, and use the lower 8 bits (instead of the      lower 12 or 16) for the device (major?) number.        Similarly, while 'units' is an int (32bits), it is unclear      how many of these are significant. For most devices, it seems that      'units' is equivalent to 'minor'.  For FH_TAPE, it's obvious that      only 8 bits are important.  However, for FH_SOCKET...it might be      as high as 16 significant bits.        Let's assume that we only need 8 bits from device (major) and      only 8 bits from unit (minor). (On linux, only 8 bits of minor      are used, and none from major).      ---> so, we only need 0x00ff00ff (16 bits) of dev_t        ---> we MUST have all 8 bits of id.        ---> So, we only have 64 - 8 - 16 = 40 bits for ino_t.  But, we      need 0xffff0000 for nFileIndexHigh and 0x0003ffff for nFileIndexLow      minimum, or 16 + 18 = 34 bits.  Lucky us - we have 6 more bits      to distribute.        For lack of a better idea, we'll allocate 2 of the extra bits to      nFileIndexHigh and 4 to nFileIndexLow.  */     /* get 8 bits from dev_t (major), put into 0xff00000000000000L */   tmp  = (((key_t) statbuf.st_dev) & 0x0000000000ff0000LL) << 40;   /* get 8 bits from dev_t (minor), put into 0x00ff000000000000L */   tmp |= (((key_t) statbuf.st_dev) & 0x00000000000000ffLL) << 48;   /* get upper 16+2 bits from nFileInfoHigh, put into 0x0000ffffc0000000L      shift down first, then mask, to avoid sign extension on rightshift  */   tmp |= (((key_t) statbuf.st_ino) & 0xffffc00000000000LL) >> 16;   /* get lower 18+4 bits from nFileInfoLow, put into  0x000000003fffff00L  */   tmp |= (((key_t) statbuf.st_ino) & 0x00000000003fffffLL) << 8;   /* use all 8 bits of id, and put into 0x00000000000000ffL */   tmp |= (id & 0x00ff);   return tmp; }