On Sep 2, 2009, at 1:51 PM, Daniel Berger wrote:

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

It can't seem to load a few of its dependencies like "windows/com".

1. The gem doesn't have a dependency on the windows-api gem.

2. The windows-api gem, after installation, doesn't have a lot of the  
files that pr-win32ole wants to load.

#2 leads me to believe that you have a super-secret version of the  
windows-api gem containing all this cool new stuff but it hasn't been  
released yet.

Where can I find this super-secret code? Alternately, email me the gem  
at the above address. :)

cr