[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fix for Emacs Crash - revisited

From: Ben Key
Subject: Fix for Emacs Crash - revisited
Date: Sun, 10 Nov 2002 03:45:34 -0500

  The patch attached to this message fixes to following entry in

 * Emacs built on Windows 9x/ME crashes at startup on Windows XP,
 or Emacs built on XP crashes at startup on Windows 9x/ME.

The following changes are made by this patch:

1.  init_user_info in w32.c has been modified so that OpenProcessToken
    is no longer called on systems running Windows 9x.  Although
    OpenProcessToken exists in the version of advapi32.dll that is
    found in Windows 9x, it apparently generates an exception if
    called on Windows 9x.  This exception, if not handled causes Emacs
    to crash.

2.  I modified w32_wnd_proc in w32fns.c so that the function pointer
    track_mouse_event_fn is reinitialized in the WM_SETFOCUS
    handler.  I found that even though track_mouse_event_fn was being
    initialized in syms_of_w32fns which is called from main, the
    function pointer obtained in syms_of_w32fns was invalid.  Because
    of this, Emacs was crashing the first time a WM_MOUSEMOVE message
    was received.  I did not want to reinitialize this function
    pointer every time a WM_MOUSEMOVE message is received but I
    wanted to make certain that the function pointer got
    reinitialized as soon after the creation of the Emacs window as
    possible.  That is why I chose WM_SETFOCUS.

3.  I modified initialize_frame_menubar in w32menu.c to reinitialize
    the function pointers get_menu_item_info and set_menu_item_info.
    I found that even though these function pointers were being
    initialized in syms_of_w32menu which is called from main, the
    function pointers obtained in syms_of_w32menu were invalid.  This
    was causing Emacs to crash the first time either of these
    function pointers were used.  This happened to be in add_menu_item
    (which is why I initially came to my earlier conclusions,
    discussed in my earlier message "Fix for Emacs Crash").  I chose
    to reinitialize these function pointers here because I did not
    want to have to do it every time the function pointers were used
    and it seemed that initialize_frame_menubar was the entry point
    for all menu creation.

I have been trying to determine why these function pointers needed to
be reinitialized.  At first I thought that it might have something to
do will DLL relocation, but I no longer think that after discussing
my ideas with Glen Gordan, one of my coworkers.  He told me that when
Windows determine that DLL relocation needs to occur, it happens
before main gets called, not after.  I am uncomfortable in situations
where I cannot determine why a change that fixes a problem is
necessary.  For this reason I have tested my fix very throughly.  I
tested a build done on Windows XP using MSVC 6.0 both on Windows 98
and on Windows ME.  I also tested a build done on Windows XP using
MinGW 2.0 / MSYS 1.08 on Windows ME.  And just to make certain I was
covering all of my bases, I tested a build done on Windows ME using
MinGW 2.0 / MSYS 1.08 on Windows XP.  In all of these test
situations, Emacs worked without a problem.

Attachment: dopatch21_3.sh
Description: Binary data

Attachment: emacs-21.3.50-windows-crash-fix.diff
Description: Binary data

reply via email to

[Prev in Thread] Current Thread [Next in Thread]