Subject: bug#6126: 24.0.50; Segmentation fault when w32-shell-execute try to open an unassociated file

From: Eli Zaretskii <[email-masked]>
Date: Fri, 07 May 2010 18:12:07 +0300

> From: Chunyu Wang <[email-masked]>
> Date: Fri, 7 May 2010 22:21:39 +0800
> Cc: [email-masked]
> 
> 2010/5/7 Eli Zaretskii <[email-masked]>:
> > Does this problem happen in an unoptimized build as well?  If so,
> > could you please find out what is the table it is using (the `tbl'
> > variable in frame #0), and also what is `val' (by using the xtype
> > command and a command to show the Lisp type printed by xtype, probably
> > xchartable)?
> Crashed as before for an unoptimized build one. The following is my tracing and
> information about `tbl' and `val'. If need some other thing, just tell
> me how to get it.

Can you try the following patch, and see if it resolves the problem?

=== modified file 'src/w32fns.c'
--- src/w32fns.c	2010-03-31 09:08:40 +0000
+++ src/w32fns.c	2010-05-07 15:07:43 +0000
@@ -47,6 +47,7 @@ along with GNU Emacs.  If not, see <http
 #include "systime.h"
 #include "termhooks.h"
 #include "w32heap.h"
+#include "w32.h"
 
 #include "bitmaps/gray.xbm"
 
@@ -6333,6 +6334,7 @@ an integer representing a ShowWindow fla
      Lisp_Object operation, document, parameters, show_flag;
 {
   Lisp_Object current_dir;
+  char *errstr;
 
   CHECK_STRING (document);
 
@@ -6353,7 +6355,17 @@ an integer representing a ShowWindow fla
 			   XINT (show_flag) : SW_SHOWDEFAULT))
       > 32)
     return Qt;
-  error ("ShellExecute failed: %s", w32_strerror (0));
+  errstr = w32_strerror (0);
+  /* The error string might be encoded in the locale's encoding.  */
+  if (!NILP (Vlocale_coding_system))
+    {
+      Lisp_Object decoded =
+	code_convert_string_norecord (make_unibyte_string (errstr,
+							   strlen (errstr)),
+				      Vlocale_coding_system, 0);
+      errstr = (char *)SDATA (decoded);
+    }
+  error ("ShellExecute failed: %s", errstr);
 }
 
 /* Lookup virtual keycode from string representing the name of a