zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <Peter.Stephenson@csr.com>
To: <zsh-workers@zsh.org>
Subject: Re: Solaris 10 64bit build of zsh 4.3.17 crashes on cursor right
Date: Wed, 20 Jun 2012 16:26:11 +0100	[thread overview]
Message-ID: <20120620162611.49e5355e@pwslap01u.europe.root.pri> (raw)
In-Reply-To: <4FDF465B.4020906@oracle.com>

On Mon, 18 Jun 2012 17:16:43 +0200
Clemens Huebner <clemens.huebner@oracle.com> wrote:
> When compiled on Solaris 10 (or earlier) as 64bit, zsh will crash every 
> time cursor right is pressed.
> 
> This is due to Solaris Bug 1240072. The bug causes tgoto() not to be 
> declared in term.h, if __STDC__ is set. The bug is fixed in Solaris 11, 
> but not in Solaris 10 or earlier.
> 
> Due to the missing prototype, the char pointer returned by tgoto() will 
> be cast to int. This works on 32bit builds, but will truncate the 
> pointer on 64bit builds, as the 64 bit pointer will be cast to a 32 bit int.

Well, we can detect a missing prototype in autoconf by looking for a
conflict.  The big danger here is that we pick up the correct prototype
by some other headers we're not including at this point, and that
prototype conflicts slightly with the one we use.  It should be a small
risk since at this point we're using the full power of our 20-year
experience of finding terminal library headers.  Hmm.

Index: configure.ac
===================================================================
RCS file: /cvsroot/zsh/zsh/configure.ac,v
retrieving revision 1.138
diff -p -u -r1.138 configure.ac
--- configure.ac	5 Mar 2012 10:06:28 -0000	1.138
+++ configure.ac	20 Jun 2012 15:22:14 -0000
@@ -1603,6 +1603,8 @@ AH_TEMPLATE([HAVE_NUMNAMES],
 [Define if you have the terminfo numnames symbol.])
 AH_TEMPLATE([HAVE_STRNAMES],
 [Define if you have the terminfo strnames symbol.])
+AH_TEMPLATE([TGOTO_PROTO_MISSING],
+[Define if there is no prototype for the tgoto() terminal function.])
 
 if test x$zsh_cv_path_term_header != xnone; then
   AC_DEFINE(ZSH_HAVE_TERM_H)
@@ -1618,26 +1620,42 @@ if test x$zsh_cv_path_term_header != xno
   AC_TRY_LINK($term_includes, [char **test = boolcodes; puts(*test);],
   AC_DEFINE(HAVE_BOOLCODES) boolcodes=yes, boolcodes=no)
   AC_MSG_RESULT($boolcodes)
+
   AC_MSG_CHECKING(if numcodes is available)
   AC_TRY_LINK($term_includes, [char **test = numcodes; puts(*test);],
   AC_DEFINE(HAVE_NUMCODES) numcodes=yes, numcodes=no)
   AC_MSG_RESULT($numcodes)
+
   AC_MSG_CHECKING(if strcodes is available)
   AC_TRY_LINK($term_includes, [char **test = strcodes; puts(*test);],
   AC_DEFINE(HAVE_STRCODES) strcodes=yes, strcodes=no)
   AC_MSG_RESULT($strcodes)
+
   AC_MSG_CHECKING(if boolnames is available)
   AC_TRY_LINK($term_includes, [char **test = boolnames; puts(*test);],
   AC_DEFINE(HAVE_BOOLNAMES) boolnames=yes, boolnames=no)
   AC_MSG_RESULT($boolnames)
+
   AC_MSG_CHECKING(if numnames is available)
   AC_TRY_LINK($term_includes, [char **test = numnames; puts(*test);],
   AC_DEFINE(HAVE_NUMNAMES) numnames=yes, numnames=no)
   AC_MSG_RESULT($numnames)
+
   AC_MSG_CHECKING(if strnames is available)
   AC_TRY_LINK($term_includes, [char **test = strnames; puts(*test);],
   AC_DEFINE(HAVE_STRNAMES) strnames=yes, strnames=no)
   AC_MSG_RESULT($strnames)
+
+  dnl There are apparently defective terminal library headers on some
+  dnl versions of Solaris before 11.
+  AC_MSG_CHECKING(if tgoto prototype is missing)
+  tgoto_includes="$term_includes
+/* guaranteed to clash with any valid tgoto prototype */
+extern void tgoto(int **stuff, float **more_stuff);"
+  AC_TRY_LINK($tgoto_includes,
+  [int *stuff; float *more_stuff; tgoto(&stuff, &more_stuff);],
+  AC_DEFINE(TGOTO_PROTO_MISSING) tgotoprotomissing=yes, tgotoprotomissing=no)
+  AC_MSG_RESULT($tgotoprotomissing)
 else
   ZSH_TERM_H=
 fi
Index: Src/zsh_system.h
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/zsh_system.h,v
retrieving revision 1.1
diff -p -u -r1.1 zsh_system.h
--- Src/zsh_system.h	10 May 2011 16:44:39 -0000	1.1
+++ Src/zsh_system.h	20 Jun 2012 15:22:14 -0000
@@ -874,3 +874,7 @@ extern short ospeed;
 #  endif
 # endif
 #endif
+
+#ifdef TGOTO_PROTO_MISSING
+char *tgoto(const char *cap, int col, int row);
+#endif


-- 
Peter Stephenson <pws@csr.com>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog


      reply	other threads:[~2012-06-20 15:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-18 15:16 Clemens Huebner
2012-06-20 15:26 ` Peter Stephenson [this message]

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=20120620162611.49e5355e@pwslap01u.europe.root.pri \
    --to=peter.stephenson@csr.com \
    --cc=zsh-workers@zsh.org \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

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 NNTP newsgroup(s).