public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Shaddy Baddah <lithium-cygwin@shaddybaddah.name>
To: cygwin@cygwin.com
Subject: Re: screen on 64-bit mangles mintty/buffer
Date: Thu, 15 May 2014 12:54:00 -0000	[thread overview]
Message-ID: <5374B5C2.8010402@shaddybaddah.name> (raw)
In-Reply-To: <4jc7n9hsfrkh57dc5hlgb3tlrrasgo2v3m@4ax.com>

[-- Attachment #1: Type: text/plain, Size: 1991 bytes --]

Hi,

On 2014-05-15 04:15+1000, Andrew Schulman wrote:
> <snip>
<snip>
>>
>> I can't understand why the ./conftest.exe differ. Trying to emulate by
>> hand, I cannot reproduce it. But it is now very late here, and I can't
>> debug anymore.
>>
>> I'm hoping that I've provided enough of a lead for someone of authority
>> to decide where things are right, and where things are wrong.
>
> Yes, I think so!
>
> Thanks a lot, Shaddy.  That takes us a long way to a solution.  I'll look
> at it from there as soon as I can.

No problem. I am always happy when I can contribute to my favourite Open
Source project and community.

With regards to the conftest difference on 32-bit vs. 64-bit, I believe
I understand it now.

It seems the code configure generates for that little test fails to
#include definitions for tgoto() (amongst others).

In trying to emulate it, I had actually put them in my code. My method
wasn't exact.

If I understand correctly (and a subsequent gdb run seems to confirm it;
Value returned is $1 = 0x600096230 "1" becomes a pointer to 0x96230)
the difference comes about because without the prototype, gcc pins an
int as the return type of tgoto(). But being a pointer, char *, on
64-bit the size mismatch (8 byte pointers, vs 4 byte int) means that
the pointer passed into strcmp() (as return from tgoto()) has 4 random
bytes copied in, and points to a random location.

Does that sound plausible? I am not 100% sure, because considering this
I thought that a 64-bit Linux should be afflicted in the same way.

However despite gcc complaining as well over missing prototypes,
strcmp() is being passed the correct (char *) pointer from tgoto(). Is
this down to the difference in gcc (4.8 on cygwin, 4.7 on debian)? Or
just the difference in architecture?

In any case, I've tested the patch below, and it solves the immediate
problem with screen. It probably needs to go upstream too... I'd put
my hand up, but I'm unsure where upstream is exactly.

-- 
Regards,
Shaddy

[-- Attachment #2: screen-terminfo-autoconf.diff --]
[-- Type: text/x-patch, Size: 348 bytes --]

--- origsrc/screen/src/configure.in	2013-06-17 20:48:45.000000000 +1000
+++ src/screen/src/configure.in	2014-05-15 21:42:36.949278900 +1000
@@ -680,6 +680,9 @@
 AC_MSG_ERROR(!!! no tgetent - no screen)))))))
 
 AC_TRY_RUN([
+#include <term.h>
+#include <string.h>
+#include <stdlib.h>
 main()
 {
  exit(strcmp(tgoto("%p1%d", 0, 1), "1") ? 0 : 1);


[-- Attachment #3: Type: text/plain, Size: 218 bytes --]

--
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

  parent reply	other threads:[~2014-05-15 12:41 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-12 15:57 Shaddy Baddah
2014-05-12 16:38 ` Corinna Vinschen
2014-05-12 16:51 ` Andrew Schulman
2014-05-14 18:16   ` Shaddy Baddah
2014-05-14 21:15     ` Andrew Schulman
2014-05-14 23:22       ` Christopher Faylor
2014-05-15  2:18         ` Andrew Schulman
2014-05-15 12:54       ` Shaddy Baddah [this message]
2014-05-15 17:44         ` Andrew Schulman
2014-05-15  7:32     ` Corinna Vinschen
2014-05-15 13:11       ` Shaddy Baddah
2014-05-15 14:10         ` Corinna Vinschen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5374B5C2.8010402@shaddybaddah.name \
    --to=lithium-cygwin@shaddybaddah.name \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).