Bugs: Browse | Submit New | Admin

[#21223] bus error after OSA.app()

Date:
2008-07-14 22:13
Priority:
3
Submitted By:
Nobody
Assigned To:
Nobody (None)
Category:
None
State:
Open
Summary:
bus error after OSA.app()

Detailed description
ruby crashes after running the following code (default Leopard 10.5.4 on intel):

>> require 'rbosa'
>> app = OSA.app('iTunes')

/Library/Ruby/Gems/1.8/gems/rubyosa-0.4.0/lib/rbosa.rb:530: [BUG] Bus Error
ruby 1.8.6 (2008-03-03) [universal-darwin9.0]

Seems to be a problem with libxml-ruby-0.7.0 because the problem does not show when I revert to libxml-ruby-0.5.4

gdb data:

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x0000005b
0x96e70c29 in xmlStrEqual ()


Add A Comment: Notepad

Please login


Followup

Message
Date: 2009-07-26 21:33
Sender: Ryan Davis

(this is mostly for the other people on this ticket)

This projects seems dead for all intents and purposes. FWIW,
I've switched to rb-appscript and it works wonderfully. Be sure
to download ASTranslate, it helps convert applescript to
rb-appscript.

I'll be publishing my omnifocus gem in the next day or so if
you'd like to use it as an example.
Date: 2009-07-23 09:58
Sender: Ryan Davis

Is there any intention of fixing this? Should I find an alternative
to rubyosa? Why isn't this assigned to anyone?

% ruby -v
ruby 1.8.6 (2008-08-11 patchlevel 287) [universal-darwin9.0]
% gdb --args `type ruby` -rubygems -e "require 'rbosa';
OSA.app 'iTunes'"
(gdb) r
Starting program: /usr/bin/ruby -rubygems -e require\ \'rbosa\'\;\
OSA.app\ \'iTunes\'
Reading symbols for shared libraries +++. done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries
.................................................................
............ done
Reading symbols for shared libraries .. done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x0000005b
0x928a7bd5 in xmlStrEqual ()
(gdb) bt
bt
#0  0x928a7bd5 in xmlStrEqual ()
#1  0x928ba321 in xmlGetProp ()
#2  0x001b8712 in rxml_attr_value_get ()
#3  0x000e01cc in rb_eval_string_wrap ()
#4  0x000e0da7 in rb_eval_string_wrap ()
#5  0x000de108 in rb_eval_string_wrap ()
#6  0x000df123 in rb_eval_string_wrap ()
#7  0x000ddacf in rb_eval_string_wrap ()
#8  0x000e4199 in rb_thread_trap_eval ()
#9  0x000e5061 in rb_yield ()
#10 0x001ca3df in ruby_init_xml_xpath_object ()
#11 0x000e01cc in rb_eval_string_wrap ()
#12 0x000e0da7 in rb_eval_string_wrap ()
#13 0x000de108 in rb_eval_string_wrap ()
#14 0x000dd12a in rb_eval_string_wrap ()
#15 0x000e4199 in rb_thread_trap_eval ()
#16 0x000e5061 in rb_yield ()
#17 0x000c598f in rb_ary_each ()
#18 0x000e01cc in rb_eval_string_wrap ()
#19 0x000e0da7 in rb_eval_string_wrap ()
#20 0x000de108 in rb_eval_string_wrap ()
#21 0x000dd12a in rb_eval_string_wrap ()
#22 0x000e099f in rb_eval_string_wrap ()
#23 0x000e0da7 in rb_eval_string_wrap ()
#24 0x000de108 in rb_eval_string_wrap ()
#25 0x000ddacf in rb_eval_string_wrap ()
#26 0x000e099f in rb_eval_string_wrap ()
#27 0x000e0da7 in rb_eval_string_wrap ()
#28 0x000de108 in rb_eval_string_wrap ()
#29 0x000e099f in rb_eval_string_wrap ()
#30 0x000e0da7 in rb_eval_string_wrap ()
#31 0x000de108 in rb_eval_string_wrap ()
#32 0x000ed0a1 in rb_load_protect ()
#33 0x000ed0d2 in ruby_exec ()
#34 0x000ed0fe in ruby_run ()
#35 0x00001fff in main ()
Date: 2009-06-10 20:58
Sender: Pee Dee

I'm also getting this, with a clean XTools install from 10.5.6
disks (on a 10.5.7 Intel iMac). How do I move back
to libxml-ruby-0.5.4?
Date: 2009-01-08 01:32
Sender: Len Lattanzi

Test case attached in libxml radar
Date: 2009-01-08 00:52
Sender: Charlie Savage

Hi Len,

Thanks for the patch.  However, I'd much rather fix the base
rxml_attr_value_get method.

From the libxml documentation, xmlHasProp and xmlGetProp both
check DTD's, so that doesn't seem to be the issue.  The patch
as attached does what the code already does, with one difference:

current code:  xmlHasProp -> attribute -> xmlGetProp ->
value

patch: xmlGetProp -> value

The issue I have with the patch is that it would not fix:

attr = node.get_attribute('foo')
attr.value

Looking at the stack trace, best guess is that the attribute
returned by xmlHasProp has a NULL name.  Of course you have to
pass a name to xmlHasProp so that doesn't really make a lot of
sense - but the call to xmlStrEqual is suspicious.

Anyway, do you have a test case? If so, this will be easy to
fix.

Thanks - Charlie
Date: 2009-01-06 06:50
Sender: Gerrit Kaiser

http://www.dicianno.org/blog/2008/10/06/rubyosa-040-bus-error/
documents a workaround for this problem by requiring an older
version of libxml-ruby
Date: 2008-12-22 00:02
Sender: Len Lattanzi

Reported again in libxml-ruby
<http://rubyforge.org/tracker/index.php?func=detail&aid=23
306&group_id=494&atid=1971>
Date: 2008-12-21 23:51
Sender: Len Lattanzi

This is because rxml_attributes_attribute_get calls xmlGetProp
on an attribute 'access' from the sdef.dtd

Quick and dirty fix

diff -up -r /Library/Ruby/Gems/1.8/gems/libxml-ruby-0.9.7/ext/lib
xml/ruby_xml_attributes.c
libxml-ruby-0.9.7+/ext/libxml/ruby_xml_attributes.c
--- /Library/Ruby/Gems/1.8/gems/libxml-ruby-0.9.7/ext/libxml/ruby
_xml_attributes.c  2008-12-21 15:46:21.000000000 -0800
+++ libxml-ruby-0.9.7+/ext/libxml/ruby_xml_attributes.c 2008-12-21
15:38:16.000000000 -0800
@@ -132,11 +132,22 @@ static VALUE rxml_attributes_get_attribu
  */
 VALUE rxml_attributes_attribute_get(VALUE self, VALUE name)
 {
-  VALUE xattr = rxml_attributes_get_attribute(self, name);
-  if (NIL_P(xattr))
-    return(Qnil);
-  else
-    return rxml_attr_value_get(xattr);
+  xmlNodePtr xnode;
+  xmlChar *value;
+  VALUE result = Qnil;
+
+  name = check_string_or_symbol(name);
+
+  Data_Get_Struct(self, xmlNode, xnode);
+
+  value = xmlGetProp(xnode, (xmlChar*) StringValuePtr(name));
+
+  if (value != NULL)
+  {
+    result = rb_str_new2((const char *)value);
+    xmlFree(value);
+  }
+  return result;
 }

Date: 2008-10-11 11:51
Sender: Matt Okeson-Harlow

Still a problem with Ruby 1.8.6 on OS X 10.5.4

(gdb) run
Starting program: /usr/bin/ruby 
Reading symbols for shared libraries +++. done

require 'rubygems'
require 'rbosa'

app = OSA.app('iTunes')
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries
.................................................................
............ done
Reading symbols for shared libraries .. done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x0000005b
0x90990c29 in xmlStrEqual ()
(gdb) bt
#0  0x90990c29 in xmlStrEqual ()
#1  0x909a3409 in xmlGetProp ()
#2  0x00196ac1 in ruby_xml_attr_value_get ()
#3  0x000dc1d8 in rb_eval_string_wrap ()
#4  0x000dcdec in rb_eval_string_wrap ()
#5  0x000da06d in rb_eval_string_wrap ()
#6  0x000db139 in rb_eval_string_wrap ()
#7  0x000d992b in rb_eval_string_wrap ()
#8  0x000e01fc in rb_thread_trap_eval ()
#9  0x000e10aa in rb_yield ()
#10 0x001a2dab in ruby_xml_xpath_object_each ()
#11 0x000dc1d8 in rb_eval_string_wrap ()
#12 0x000dcdec in rb_eval_string_wrap ()
#13 0x000da06d in rb_eval_string_wrap ()
#14 0x000d8cfe in rb_eval_string_wrap ()
#15 0x000e01fc in rb_thread_trap_eval ()
#16 0x000e10aa in rb_yield ()
#17 0x000c18b9 in rb_ary_each ()
#18 0x000dc1d8 in rb_eval_string_wrap ()
#19 0x000dcdec in rb_eval_string_wrap ()
#20 0x000da06d in rb_eval_string_wrap ()
#21 0x000d8cfe in rb_eval_string_wrap ()
#22 0x000dc9de in rb_eval_string_wrap ()
#23 0x000dcdec in rb_eval_string_wrap ()
#24 0x000da06d in rb_eval_string_wrap ()
#25 0x000d992b in rb_eval_string_wrap ()
#26 0x000dc9de in rb_eval_string_wrap ()
#27 0x000dcdec in rb_eval_string_wrap ()
#28 0x000da06d in rb_eval_string_wrap ()
#29 0x000dc9de in rb_eval_string_wrap ()
#30 0x000dcdec in rb_eval_string_wrap ()
#31 0x000da06d in rb_eval_string_wrap ()
#32 0x000daa3a in rb_eval_string_wrap ()
#33 0x000e8f62 in rb_load_protect ()
#34 0x000e8f93 in ruby_exec ()
#35 0x000e8fbf in ruby_run ()
#36 0x00001fff in main ()

Date: 2008-09-08 15:20
Sender: Andy Morrow

I too see this problem. I'm running 10.5.4 on an iBook G4 (PPC.)
The stack trace appears meaningless - it's in the middle of garbage
collection. I've been able to replicate the problem every time
I run the following code in IRB:
require 'rbosa'
keynote = OSA.app('keynote')

 Here's what crashreporter gives:

Process:         ruby [3082]
Path:            /usr/bin/irb
Identifier:      ruby
Version:         ??? (???)
Code Type:       PPC (Native)
Parent Process:  bash [3070]

Date/Time:       2008-09-08 09:14:53.471 -0600
OS Version:      Mac OS X 10.5.4 (9E17)
Report Version:  6

Exception Type:  EXC_BAD_ACCESS (SIGABRT)
Exception Codes: KERN_PROTECTION_FAILURE at 0x000000000000005b
Crashed Thread:  0

Thread 0 Crashed:
0   libSystem.B.dylib             	0x93fda798 __kill + 12
1   libSystem.B.dylib             	0x9407f2b4 abort + 84
2   libruby.1.dylib               	0x0014a3b0 rb_gc_mark_trap_list
+ 600

Thread 0 crashed with PPC Thread State 32:
  srr0: 0x93fda798  srr1: 0x0000d030   dar: 0x0000005b dsisr:
0x40000000
    r0: 0x00000025    r1: 0xbffed6f0    r2: 0x00000000    r3:
0x00000000
    r4: 0x00000000    r5: 0x00000001    r6: 0x0000000a    r7:
0x00000030
    r8: 0x00000008    r9: 0x00000008   r10: 0x93fa3774   r11:
0xa0818490
   r12: 0x93fda784   r13: 0x00000000   r14: 0x00000000   r15:
0x00000000
   r16: 0x00000000   r17: 0x00000000   r18: 0x00000000   r19:
0x00000000
   r20: 0x00000000   r21: 0x00000000   r22: 0x00000000   r23:
0x0000014c
   r24: 0x00000000   r25: 0x00000000   r26: 0x0113b838   r27:
0x001680d0
   r28: 0xbffed78c   r29: 0xa0816424   r30: 0x0000003c   r31:
0x9407f26c
    cr: 0x42000422   xer: 0x00000004    lr: 0x9407f2b8   ctr:
0x93fda784
vrsave: 0x00000000
Date: 2008-08-22 09:40
Sender: Philip Trauring

I have the exact same problem.

Attached Files:

Name Description Download
crashreport.txt Crashreporter log Download

Changes:

Field Old Value Date By
File Added3903: crashreport.txt2008-07-14 22:13None