Bug #6829

Failure using Win32ole (happens in 1.8.7 and 1.9

Added by Mitch VanDuyn over 1 year ago. Updated about 1 year ago.

[ruby-core:46973]
Status:Rejected
Priority:Normal
Assignee:Masaki Suketa
Category:ext
Target version:-
ruby -v:1.9.1 and 1.8.7 Backport:

Description

The following code:

require 'rubygems'
require 'win32ole'
pdk = WIN32OLE.new("StampsDotCom.PDK5")
internetpostage = pdk.InternetPostage3
print
job = pdk.CreatePrintJob5
printjob.MailClass = 0 # first class
print
job.MailpieceFormFactor = 1 # envelope
printjob.MediaID = 2 ##10 envelope
print
job.PrinterName = "\\stamps1\Dev1"
printjob.MailpieceWeight = 1
print
job.AddRecipient("Stamps.com\r\n3420 Ocean Park Blvd Ste 1040\r\nSanta Monica, CA 90405")
internetpostage.PrintPostage("Stamps.com\r\n3420 Ocean Park Blvd Ste 1040\r\nSanta Monica, CA 90405") # this call works
internet
postage.PrintPostageEx(1, print_job) # this call fails

when run IRB causes the below error.

To fully reproduce this problem you will have to load stamps.com exe which is available from stamps.com (although you will have to get a trial account to get the exe, I can store the exe if needed, but its too large to upload here.

This code is from the stamps.com documentation, and is very similar to other code I have run in .NET, so I am sure it is correct.

A couple of notes:

1) The last 2 lines above have very similar functions. The second to last line executes perfectly, but the last line causes the failure. So this demonstrates that the basic com communication is working fine.

2) The last line is a bit different because it is being passed back an number (fine) PLUS a pointer to an object that is coming from the com object. Could this be the problem?

There is the dump!

(irb):12: [BUG] Segmentation fault
ruby 1.9.3p194 (2012-04-20) [i386-mingw32]

-- Control frame information -----------------------------------------------
c:0024 p:---- s:0084 b:0084 l:000083 d:000083 CFUNC :method_missing
c:0023 p:0016 s:0082 b:0082 l:0021ac d:000081 EVAL (irb):12
c:0022 p:---- s:0080 b:0080 l:000079 d:000079 FINISH
c:0021 p:---- s:0078 b:0078 l:000077 d:000077 CFUNC :eval
c:0020 p:0028 s:0071 b:0071 l:000070 d:000070 METHOD C:/Ruby193/lib/ruby/1.9.1/i
rb/workspace.rb:80
c:0019 p:0033 s:0064 b:0063 l:000062 d:000062 METHOD C:/Ruby193/lib/ruby/1.9.1/i
rb/context.rb:254
c:0018 p:0031 s:0058 b:0058 l:00241c d:000057 BLOCK C:/Ruby193/lib/ruby/1.9.1/i
rb.rb:159
c:0017 p:0042 s:0050 b:0050 l:000049 d:000049 METHOD C:/Ruby193/lib/ruby/1.9.1/i
rb.rb:273
c:0016 p:0011 s:0045 b:0045 l:00241c d:000044 BLOCK C:/Ruby193/lib/ruby/1.9.1/i
rb.rb:156
c:0015 p:0144 s:0041 b:0041 l:000024 d:000040 BLOCK C:/Ruby193/lib/ruby/1.9.1/i
rb/ruby-lex.rb:243
c:0014 p:---- s:0038 b:0038 l:000037 d:000037 FINISH
c:0013 p:---- s:0036 b:0036 l:000035 d:000035 CFUNC :loop
c:0012 p:0009 s:0033 b:0033 l:000024 d:000032 BLOCK C:/Ruby193/lib/ruby/1.9.1/i
rb/ruby-lex.rb:229
c:0011 p:---- s:0031 b:0031 l:000030 d:000030 FINISH
c:0010 p:---- s:0029 b:0029 l:000028 d:000028 CFUNC :catch
c:0009 p:0023 s:0025 b:0025 l:000024 d:000024 METHOD C:/Ruby193/lib/ruby/1.9.1/i
rb/ruby-lex.rb:228
c:0008 p:0046 s:0022 b:0022 l:00241c d:00241c METHOD C:/Ruby193/lib/ruby/1.9.1/i
rb.rb:155
c:0007 p:0011 s:0019 b:0019 l:001394 d:000018 BLOCK C:/Ruby193/lib/ruby/1.9.1/i
rb.rb:70
c:0006 p:---- s:0017 b:0017 l:000016 d:000016 FINISH
c:0005 p:---- s:0015 b:0015 l:000014 d:000014 CFUNC :catch
c:0004 p:0183 s:0011 b:0011 l:001394 d:001394 METHOD C:/Ruby193/lib/ruby/1.9.1/i
rb.rb:69
c:0003 p:0039 s:0006 b:0006 l:0001e4 d:001f4c EVAL C:/Ruby193/bin/irb:12
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:0000 s:0002 b:0002 l:0001e4 d:0001e4 TOP

-- Ruby level backtrace information ----------------------------------------
C:/Ruby193/bin/irb:12:in <main>'
C:/Ruby193/lib/ruby/1.9.1/irb.rb:69:in
start'
C:/Ruby193/lib/ruby/1.9.1/irb.rb:69:in catch'
C:/Ruby193/lib/ruby/1.9.1/irb.rb:70:in
block in start'
C:/Ruby193/lib/ruby/1.9.1/irb.rb:155:in eval_input'
C:/Ruby193/lib/ruby/1.9.1/irb/ruby-lex.rb:228:in
eachtoplevelstatement'
C:/Ruby193/lib/ruby/1.9.1/irb/ruby-lex.rb:228:in catch'
C:/Ruby193/lib/ruby/1.9.1/irb/ruby-lex.rb:229:in
block in each
toplevelstatem
ent'
C:/Ruby193/lib/ruby/1.9.1/irb/ruby-lex.rb:229:in loop'
C:/Ruby193/lib/ruby/1.9.1/irb/ruby-lex.rb:243:in
block (2 levels) in eachtopl
evelstatement'
C:/Ruby193/lib/ruby/1.9.1/irb.rb:156:in block in eval_input'
C:/Ruby193/lib/ruby/1.9.1/irb.rb:273:in
signal
status'
C:/Ruby193/lib/ruby/1.9.1/irb.rb:159:in block (2 levels) in eval_input'
C:/Ruby193/lib/ruby/1.9.1/irb/context.rb:254:in
evaluate'
C:/Ruby193/lib/ruby/1.9.1/irb/workspace.rb:80:in evaluate'
C:/Ruby193/lib/ruby/1.9.1/irb/workspace.rb:80:in
eval'
(irb):12:in irb_binding'
(irb):12:in
method_missing'

-- C level backtrace information -------------------------------------------
C:\Windows\SysWOW64\ntdll.dll(ZwWaitForSingleObject+0x15) [0x76eff8b1]
C:\Windows\syswow64\kernel32.dll(WaitForSingleObjectEx+0x43) [0x763b1194]
C:\Windows\syswow64\kernel32.dll(WaitForSingleObject+0x12) [0x763b1148]
C:\Ruby193\bin\msvcrt-ruby191.dll(rbvmbugreport+0xf9) [0x62e5c589]
C:\Ruby193\bin\msvcrt-ruby191.dll(rbnameerrmesgnew+0x17a) [0x62d3a7e2]
C:\Ruby193\bin\msvcrt-ruby191.dll(rbbug+0x2f) [0x62d3b4fb]
C:\Ruby193\bin\msvcrt-ruby191.dll(rb
checksafestr+0x1a4) [0x62dee168]
[0x004011e6]
C:\Windows\syswow64\kernel32.dll(GetProfileStringW+0x12aa3) [0x763f003f]
C:\Windows\SysWOW64\ntdll.dll(RtlKnownExceptionFilter+0xb7) [0x76f574df]

-- Other runtime information -----------------------------------------------

  • Loaded script: irb

  • Loaded features:

    0 enumerator.so
    1 C:/Ruby193/lib/ruby/1.9.1/i386-mingw32/enc/encdb.so
    2 C:/Ruby193/lib/ruby/1.9.1/i386-mingw32/enc/iso88591.so
    3 C:/Ruby193/lib/ruby/1.9.1/i386-mingw32/enc/trans/transdb.so
    4 C:/Ruby193/lib/ruby/siteruby/1.9.1/rubygems/defaults.rb
    5 C:/Ruby193/lib/ruby/1.9.1/i386-mingw32/rbconfig.rb
    6 C:/Ruby193/lib/ruby/site
    ruby/1.9.1/rubygems/deprecate.rb
    7 C:/Ruby193/lib/ruby/siteruby/1.9.1/rubygems/exceptions.rb
    8 C:/Ruby193/lib/ruby/site
    ruby/1.9.1/rubygems/defaults/operatingsystem.rb
    9 C:/Ruby193/lib/ruby/site
    ruby/1.9.1/rubygems/customrequire.rb
    10 C:/Ruby193/lib/ruby/site
    ruby/1.9.1/rubygems.rb
    11 C:/Ruby193/lib/ruby/1.9.1/e2mmap.rb
    12 C:/Ruby193/lib/ruby/1.9.1/irb/init.rb
    13 C:/Ruby193/lib/ruby/1.9.1/irb/workspace.rb
    14 C:/Ruby193/lib/ruby/1.9.1/irb/inspector.rb
    15 C:/Ruby193/lib/ruby/1.9.1/irb/context.rb
    16 C:/Ruby193/lib/ruby/1.9.1/irb/extend-command.rb
    17 C:/Ruby193/lib/ruby/1.9.1/irb/output-method.rb
    18 C:/Ruby193/lib/ruby/1.9.1/irb/notifier.rb
    19 C:/Ruby193/lib/ruby/1.9.1/irb/slex.rb
    20 C:/Ruby193/lib/ruby/1.9.1/irb/ruby-token.rb
    21 C:/Ruby193/lib/ruby/1.9.1/irb/ruby-lex.rb
    22 C:/Ruby193/lib/ruby/1.9.1/irb/srcencoding.rb
    23 C:/Ruby193/lib/ruby/1.9.1/irb/magic-file.rb
    24 C:/Ruby193/lib/ruby/1.9.1/i386-mingw32/enc/euc
    jp.so
    25 C:/Ruby193/lib/ruby/1.9.1/i386-mingw32/enc/shiftjis.so
    26 C:/Ruby193/lib/ruby/1.9.1/i386-mingw32/etc.so
    27 C:/Ruby193/lib/ruby/1.9.1/i386-mingw32/dl.so
    28 C:/Ruby193/lib/ruby/1.9.1/i386-mingw32/fiddle.so
    29 C:/Ruby193/lib/ruby/1.9.1/fiddle/function.rb
    30 C:/Ruby193/lib/ruby/1.9.1/fiddle/closure.rb
    31 C:/Ruby193/lib/ruby/1.9.1/fiddle.rb
    32 C:/Ruby193/lib/ruby/1.9.1/dl.rb
    33 C:/Ruby193/lib/ruby/site
    ruby/1.9.1/rbreadline.rb
    34 C:/Ruby193/lib/ruby/siteruby/1.9.1/readline.rb
    35 C:/Ruby193/lib/ruby/1.9.1/irb/input-method.rb
    36 C:/Ruby193/lib/ruby/1.9.1/irb/locale.rb
    37 C:/Ruby193/lib/ruby/1.9.1/irb.rb
    38 C:/Ruby193/lib/ruby/1.9.1/i386-mingw32/enc/utf
    16le.so
    39 C:/Ruby193/lib/ruby/1.9.1/i386-mingw32/enc/trans/singlebyte.so
    40 C:/Ruby193/lib/ruby/1.9.1/i386-mingw32/enc/trans/utf
    16_32.so
    41 C:/Ruby193/lib/ruby/1.9.1/i386-mingw32/win32ole.so
    42 C:/Ruby193/lib/ruby/1.9.1/win32ole.rb

[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

History

#1 Updated by Luis Lavena over 1 year ago

  • Category set to ext
  • Status changed from Open to Feedback
  • Assignee set to Masaki Suketa
  • Priority changed from High to Normal

can you try Ruby 1.9.3 and see if it reproduces?

I don't have Stamps software installed or a Stamps printer to test, neither I think the extension maintainer (suke) will do.

If we can reproduce this issue with simple WIN32OLE (no depending on Stamps installed) it will be great.

#2 Updated by Masaki Suketa over 1 year ago

Thank you for your reporting.
I'm not sure, but maybe you must specify variant type information
of arguments when you call PrintPostageEx.
I'd like to know what variant type of arguments is needed
to call PrintPostageEx.
What is the result of the following code in Ruby 1.9?

method = internetpostage.olemethod("PrintPostageEx")
method.params.each do |param|
puts param.name + ":" + param.oletypedetail.join(',')
end

Best Regards,
Masaki Suketa

#3 Updated by Mitch VanDuyn over 1 year ago

Thanks for looking into this.

Here is what I get.

irb(main):005:0> method = internetpostage.olemethod("PrintPostageEx")
RuntimeError: failed to GetTypeInfo
HRESULT error code:0x80029c4a
Error loading type library/DLL.
from (irb):5:in ole_method'
from (irb):5
from C:/Ruby193/bin/irb:12:in
'
irb(main):006:0>

I tried the same thing on other things and the result is the same i.e. pdk.ole_method("InternetPostage3") raises the same error.

Could the following note from the stamps.com documentation have anything to do with it?

SMUI.TLB (Type-Library File) - The SDK provides Stamps.com client functionality in the form of an ActiveX object (SMUI.DLL). Although any COM-compatible language can access it, some languages, such as Visual Basic (when using early binding) and Visual C++, will require the type-library file in order to access them. Have attached this file in case it is of any help.

I have also attached the DLL in case that is of any help.

#4 Updated by Masaki Suketa over 1 year ago

Thank you for your reporting of the result and more information.

Could you try the following script using Ruby 1.9?

tlib = WIN32OLETYPELIB.new("(The folder of SMUI.TLIB)\SMUI.TLIB")
(or tlib = WIN32OLE
TYPELIB.new("(The folder of SMUI.DLL)\SMUI.DLL") )
method = tlib.oletypes.map{|t|
t.ole
methods
}.flatten.find{|m|
/PrintPostageEx/i =~ m.name
}
method.params.each do |param|
puts param.name + ":" + param.oletypedetail.join(',')
end

And can you call PrintPostageEx from VBScript(neither VB nor VB.NET)?
If you can't call PrintPostageEx from VBScript, then you can't
call PrintPostageEx from Win32OLE.
Win32OLE supports only late binding, not early binding.

Best Regards,
Masaki Suketa

#5 Updated by Eric Hodel about 1 year ago

  • Status changed from Feedback to Rejected

Marking this as rejected due to lack of feedback by the submitter.

Also available in: Atom PDF