On Sep 2, 11:48=A0am, Chuck Remes <cremes.devl... / mac.com> wrote:
> Sorry for the long subject. I wanted to make sure folks interested in =A0
> WIN32OLE stuff saw it.
>
> Anyway, I am doing some application automation on Windows using the =A0
> WIN32OLE classes. In this particular case, I have registered event =A0
> handlers for a bunch of possible events that may be generated by =A0
> another Windows application. I have tested about a dozen of these =A0
> handlers and all is well. However, I added one more and now when I =A0
> trigger the event that calls it, ruby crashes.
>
> If I am using ruby 1.8.6 patch level 287, it generates a segfault and =A0
> writes the usual message:
>
> >> This application has requested the Runtime to terminate it in an =A0
> >> unusual
> >> way.
> >> Please contact the application's support team for more information.
>
> It also gives me a line number in my code. This line corresponds to =A0
> this code:
>
> WIN32OLE_EVENT.message_loop
>
> I took the error message at face value and decided this was a ruby bug =
=A0
> so I upgraded to patch level 383. (For this installation I used the =A0
> one-click installer available from rubyinstaller.org, preview 2).
>
> It still crashes but now it doesn't give me any code line or write any =
=A0
> message at all.
>
> I'm not well versed in Windows programming so I don't really know how =A0
> to debug this. Here is what I have tried:
>
> 1. I've narrowed the "cause" down to the line of code that generates =A0
> the event that the handler will get on the next call to =A0
> WIN32OLE_EVENT.message_loop. If I comment it out, the program =A0
> continues to run. With it in, the program crashes.
>
> The line in question is calling a method on a WIN32OLE COM object that =
=A0
> was previously retrieved via WIN32OLE.new. The method called generates =
=A0
> a callback event after it finishes processing. This same COM object is =
=A0
> also used for making other method calls that are all succeeding just =A0
> fine.
>
> 2. I thought that perhaps I had a bug in my event handler code. I =A0
> commented it out. The crash still occurs.
>
> This leads me to believe that the event being received is causing the =A0
> crash. I have *no idea* how to get deeper on this without getting the =A0
> ruby C source and mucking about inside the #message_loop code.
>
> Anyone have any ideas on how I can solve this? If you need more =A0
> information, let me know. At this point this crash is a showstopper =A0
> for me because I *need* to be able to process the event that is =A0
> causing the crash.

I know we discussed this a bit offline, but I'm curious if you see the
same behavior with pr-win32ole. You can checkout the code at:

svn checkout http://pure.rubyforge.org/svn/pr-win32ole

I'm curious if it exhibits the same behavior. If it does, we can
probably figure out what's wrong with the C code, too. With pr-
win32ole, you can at least use the debugger. :)

Regards,

Dan

PS - No folks, pr-win32ole has not been officially released yet.