zsh-workers
 help / color / mirror / code / Atom feed
* Solaris 10 64bit build of zsh 4.3.17 crashes on cursor right
@ 2012-06-18 15:16 Clemens Huebner
  2012-06-20 15:26 ` Peter Stephenson
  0 siblings, 1 reply; 2+ messages in thread
From: Clemens Huebner @ 2012-06-18 15:16 UTC (permalink / raw)
  To: zsh-workers

Hi,

i tried sending this on my private mail account, which seems to fail, so 
i hope you den't get this triplicate.

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.

tgoto() is used only once in Src/Zle/zle_refresh.c:

static void
tcoutarg(int cap, int arg)
{
     char *result;

     result = tgoto(tcstr[cap], arg, arg);

When tgoto() is manually declared in Src/Zle/zle_refresh.c, the code 
works as expected.

I am not sufficiently versed in autoconf to write a patch, though.

Regards,
Clemens


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Solaris 10 64bit build of zsh 4.3.17 crashes on cursor right
  2012-06-18 15:16 Solaris 10 64bit build of zsh 4.3.17 crashes on cursor right Clemens Huebner
@ 2012-06-20 15:26 ` Peter Stephenson
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Stephenson @ 2012-06-20 15:26 UTC (permalink / raw)
  To: zsh-workers

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-06-20 15:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-18 15:16 Solaris 10 64bit build of zsh 4.3.17 crashes on cursor right Clemens Huebner
2012-06-20 15:26 ` Peter Stephenson

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