unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: master a9b393c: Include development data in --version output
@ 2022-06-01 19:10 Eli Zaretskii
  2022-06-02  7:55 ` Eli Zaretskii
  0 siblings, 1 reply; 2+ messages in thread
From: Eli Zaretskii @ 2022-06-01 19:10 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: emacs-devel

> commit a9b393c77350cc177952008707781dd97341a83a
> Author:     Lars Ingebrigtsen <larsi@gnus.org>
> AuthorDate: Mon May 23 11:58:22 2022 +0200
> Commit:     Lars Ingebrigtsen <larsi@gnus.org>
> CommitDate: Mon May 23 11:58:22 2022 +0200
> 
>     Include development data in --version output
>     
>     * src/emacs.c (main): Include development into in --version output
>     (bug#38657).
> 
> diff --git a/src/emacs.c b/src/emacs.c
> index 056cebb..fed525f 100644
> --- a/src/emacs.c
> +++ b/src/emacs.c
> @@ -1449,14 +1449,29 @@ main (int argc, char **argv)
>  	  version = emacs_version;
>  	  copyright = emacs_copyright;
>  	}
> -      printf (("%s %s\n"
> -	       "%s\n"
> +      printf ("%s %s\n", PACKAGE_NAME, version);
> +      {
> +	Lisp_Object rversion =
> +	  Fsymbol_value (intern_c_string ("emacs-repository-version"));
> +	Lisp_Object rbranch =
> +	  Fsymbol_value (intern_c_string ("emacs-repository-branch"));
> +	Lisp_Object rtime =
> +	  Fsymbol_value (intern_c_string ("emacs-build-time"));
> +	if (!NILP (rversion) && !NILP (rbranch) && !NILP (rtime))
> +	  printf ("Development version %s on %s branch; build date %s.\n",
> +		  SSDATA (Fsubstring (rversion, make_fixnum (0),
> +				      make_fixnum (12))),
> +		  SSDATA (rbranch),
> +		  SSDATA (Fformat_time_string (build_string ("%Y-%m-%d"),
> +					       rtime, Qnil)));
> +      }
> +      printf (("%s\n"
>  	       "%s comes with ABSOLUTELY NO WARRANTY.\n"
>  	       "You may redistribute copies of %s\n"
>  	       "under the terms of the GNU General Public License.\n"
>  	       "For more information about these matters, "
>  	       "see the file named COPYING.\n"),
> -	      PACKAGE_NAME, version, copyright, PACKAGE_NAME, PACKAGE_NAME);
> +	      copyright, PACKAGE_NAME, PACKAGE_NAME);
>        exit (0);
>      }
 
This change caused Emacs to crash when invoked with --version on
MS-Windows.  The reason was that it calls format-time-string, which
calls GMP functions, and that cannot be safely done before invoking
init_bignum.

I fixed the crash, but I cannot say that I'm happy with how this is
implemented: it is not safe to call Lisp functions so early into the
startup, before all the gazillion of init_FOO initializations were
called and did their things.  Look how the next Lisp function call is
waaaay down the 'main', _after_ the initializations.

I think this code fragment is a bomb waiting to go off.  We should IMO
instead raise a flag and then test it and act on it much later in the
code.



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

* Re: master a9b393c: Include development data in --version output
  2022-06-01 19:10 master a9b393c: Include development data in --version output Eli Zaretskii
@ 2022-06-02  7:55 ` Eli Zaretskii
  0 siblings, 0 replies; 2+ messages in thread
From: Eli Zaretskii @ 2022-06-02  7:55 UTC (permalink / raw)
  To: larsi; +Cc: emacs-devel

> Date: Wed, 01 Jun 2022 22:10:23 +0300
> From: Eli Zaretskii <eliz@gnu.org>
> CC: emacs-devel@gnu.org
> 
> I fixed the crash, but I cannot say that I'm happy with how this is
> implemented: it is not safe to call Lisp functions so early into the
> startup, before all the gazillion of init_FOO initializations were
> called and did their things.  Look how the next Lisp function call is
> waaaay down the 'main', _after_ the initializations.
> 
> I think this code fragment is a bomb waiting to go off.

And here it is, going off (on GNU/Linux):

 $ make
 $ ./src/temacs -version
 GNU Emacs 29.0.50
 Segmentation fault

> We should IMO instead raise a flag and then test it and act on it
> much later in the code.

Now done.



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

end of thread, other threads:[~2022-06-02  7:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-01 19:10 master a9b393c: Include development data in --version output Eli Zaretskii
2022-06-02  7:55 ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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