[Win32utils-devel] Bug in new_work_item

win32utils-devel at rubyforge.org win32utils-devel at rubyforge.org
Sat Jul 31 20:56:54 EDT 2004

Hi all,

Windows 2000
Ruby 1.8.2 R7
VC++ 6.0

I noticed that if I try to call new_work_item and give
the task a name that already exists, I get a segfault:

C:\eclipse\workspace\win32-taskscheduler>ruby test.rb
test.rb:22:in `new_work_item': NewWorkItem() function
failed (Win32::TaskSchedul
        from test.rb:22
test.rb:22: [BUG] Segmentation fault
ruby 1.8.2 (2004-07-29) [i386-mswin32]

abnormal program termination

Here's test.rb:

require "win32/taskscheduler"
include Win32

p TaskScheduler::VERSION

trigger = {
   "start_year" 	=> 2009,
   "start_month" 	=> 4,
   "start_day"   	=> 11,
   "start_hour"	    => 7,
   "start_minute"	=> 14,
   "trigger_type"	=> TaskScheduler::DAILY,
   "type"			=> { "days_interval" => 1 }

ts = TaskScheduler.new

I did find two things that I thought might solve the
problem but didn't seem to help.  The first is to call
ptr->pITS->Release() after the NewWorkItem() call. 
I'm not sure if that's necessary or not, but they do
that in their sample program on MSDN.  The second
thing I tried was adding CoUninitialize() if the call
to NewWorkItem() failed before raising an exception. 
Neither helped.

I also tried calling ts_free() explicitly before an
exception was raised - still no luck.

I've checked in some updated code, so take a look at
what I've got in CVS and see if you can duplicate the
problem and, if possible, figure out why it's
segfaulting. :)



PS - I'll submit a bug report for the Tracker

Do you Yahoo!?
Yahoo! Mail - You care about security. So do we.

More information about the win32utils-devel mailing list