<div><font face="Courier">Hi,</font></div>
<div><font face="Courier"></font> </div>
<div><font face="">Instead of:</font></div>
<div><font face="Courier">>>> from Sword import *</font></div>
<div><font face="Courier">>>> mf = MarkupFilterMgr(FMT_WEBIF)</font></div>
<div><font face="Courier">>>> mgr = SWMgr(mf)</font></div><font face="Courier">
<div><br><font face="">Try</font></div></font>
<div>
<div><font face="Courier">>>> from Sword import *</font></div>
<div><font face="Courier">>>> mf = MarkupFilterMgr(FMT_WEBIF)</font></div>
<div><font face="Courier">>>> mf.thisown = False</font></div>
<div><font face="Courier">>>> mgr = SWMgr(mf)</font></div></div>
<div> </div>
<div><font face="Courier">mf.thisown = False </font><font face="">tells swig not to GC the sword object.</font></div>
<div> </div>
<div>This may or may not help. I have had problems with it crashing before with modmaps (static linking seemed to help). Generally, if you create a Sword object, and then pass it in as a parameter, you need to do this so that it doesn't get GC'ed
</div>
<div> </div>
<div>As well as this, you can iterate through using the more pythonic:</div>
<div><font face="courier new,monospace">for mod in mods:</font></div>
<div><font face="courier new,monospace"> print mod.c_str()<br></font></div>
<div><br><font face="">-- <br>God Bless,<br>Ben<br>-------------------------------------------------------------------------------------------<br>The Lord is not slow to fulfill his promise as some count slowness,<br>but is patient toward you, not wishing that any should perish,
<br>but that all should reach repentance.<br>2 Peter 3:9 (ESV) </font></div>
<div><font face="courier new,monospace"> </font></div>
<div><span class="gmail_quote">On 12/20/07, <b class="gmail_sendername">Jon Brisbin</b> <<a href="mailto:jon@jbrisbin.com">jon@jbrisbin.com</a>> wrote:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div style="WORD-WRAP: break-word">I've got my _Sword.so module to compile and I statically linked libsword.a and libclucene.a into it. So far, I'm able to create the objects fine, but when I try to get my modules, Python crashes with the following trace:
<div><br> </div>
<div>
<div><font face="Courier">Process: Python [3639]</font></div>
<div><font face="Courier">Path: /System/Library/Frameworks/Python.framework/Versions/2.5/Resources/Python.app/Contents/MacOS/Python</font></div>
<div><font face="Courier">Identifier: Python</font></div>
<div><font face="Courier">Version: ??? (???)</font></div>
<div><font face="Courier">Code Type: X86 (Native)</font></div>
<div><font face="Courier">Parent Process: bash [3571]</font></div>
<div><font face="Courier"><br></font></div>
<div><font face="Courier">Date/Time: 2007-12-19 09:17:11.661 -0600</font></div>
<div><font face="Courier">OS Version: Mac OS X 10.5.1 (9B18)</font></div>
<div><font face="Courier">Report Version: 6</font></div>
<div><font face="Courier"><br></font></div>
<div><font face="Courier">Exception Type: EXC_BAD_ACCESS (SIGBUS)</font></div>
<div><font face="Courier">Exception Codes: KERN_PROTECTION_FAILURE at 0x0000000000000000</font></div>
<div><font face="Courier">Crashed Thread: 0</font></div>
<div><font face="Courier"><br></font></div>
<div><font face="Courier">Thread 0 Crashed:</font></div>
<div><font face="Courier">0 libSystem.B.dylib </font><span style="WHITE-SPACE: pre"><font face="Courier"></font></span><font face="Courier">0xffff07d4 __memcpy + 52</font></div>
<div><font face="Courier">1 _Sword.so </font><span style="WHITE-SPACE: pre"><font face="Courier"></font></span><font face="Courier">0x004a71da <a>sword::SWBuf::SWBuf(sword::SWBuf</a> const&, unsigned long) + 170
</font></div>
<div><font face="Courier">2 _Sword.so </font><span style="WHITE-SPACE: pre"><font face="Courier"></font></span><font face="Courier">0x0048fc27 swig::traits_from<<a>sword::SWBuf</a>>::from(<a>sword::SWBuf
</a> const&) + 49 (Sword.cxx:3485)</font></div>
<div><font face="Courier">3 _Sword.so </font><span style="WHITE-SPACE: pre"><font face="Courier"></font></span><font face="Courier">0x0048ffc1 swig::traits_from<std::pair<<a>sword::SWBuf</a> const,
<a>sword::SWModule*</a>> >::from(std::pair<<a>sword::SWBuf</a> const, <a>sword::SWModule*</a>> const&) + 33 (Sword.cxx:4393)</font></div>
<div><font face="Courier">4 _Sword.so </font><span style="WHITE-SPACE: pre"><font face="Courier"></font></span><font face="Courier">0x004882c7 swig::PySwigIterator::next() + 23 (Sword.cxx:2726)</font>
</div>
<div><font face="Courier">5 _Sword.so </font><span style="WHITE-SPACE: pre"><font face="Courier"></font></span><font face="Courier">0x00415c33 _wrap_PySwigIterator_next + 297 (Sword.cxx:5700)</font>
</div>
<div><font face="Courier">6 org.python.python </font><span style="WHITE-SPACE: pre"><font face="Courier"></font></span><font face="Courier">0x0011fd5d PyObject_Call + 50</font></div>
<div><font face="Courier">7 org.python.python </font><span style="WHITE-SPACE: pre"><font face="Courier"></font></span><font face="Courier">0x0018dfd8 PyEval_EvalFrameEx + 19086</font></div>
<div><font face="Courier">8 org.python.python </font><span style="WHITE-SPACE: pre"><font face="Courier"></font></span><font face="Courier">0x0018f47b PyEval_EvalCodeEx + 1638</font></div>
<div><font face="Courier">9 org.python.python </font><span style="WHITE-SPACE: pre"><font face="Courier"></font></span><font face="Courier">0x0018daa5 PyEval_EvalFrameEx + 17755</font></div>
<div><font face="Courier">10 org.python.python </font><span style="WHITE-SPACE: pre"><font face="Courier"></font></span><font face="Courier">0x0018f47b PyEval_EvalCodeEx + 1638</font></div>
<div><font face="Courier">11 org.python.python </font><span style="WHITE-SPACE: pre"><font face="Courier"></font></span><font face="Courier">0x0018f568 PyEval_EvalCode + 87</font></div>
<div><font face="Courier">12 org.python.python </font><span style="WHITE-SPACE: pre"><font face="Courier"></font></span><font face="Courier">0x001a6a0c PyErr_Display + 1896</font></div>
<div><font face="Courier">13 org.python.python </font><span style="WHITE-SPACE: pre"><font face="Courier"></font></span><font face="Courier">0x001a867b PyRun_InteractiveOneFlags + 523</font></div>
<div><font face="Courier">14 org.python.python </font><span style="WHITE-SPACE: pre"><font face="Courier"></font></span><font face="Courier">0x001a87c9 PyRun_InteractiveLoopFlags + 216</font></div>
<div><font face="Courier">15 org.python.python </font><span style="WHITE-SPACE: pre"><font face="Courier"></font></span><font face="Courier">0x001a8bfb PyRun_AnyFileExFlags + 85</font></div>
<div><font face="Courier">16 org.python.python </font><span style="WHITE-SPACE: pre"><font face="Courier"></font></span><font face="Courier">0x001b3c23 Py_Main + 3095</font></div>
<div><font face="Courier">17 org.python.pythonapp </font><span style="WHITE-SPACE: pre"><font face="Courier"> </font></span><font face="Courier">0x00001fca 0x1000 + 4042</font></div>
<div><font face="Courier"><br></font></div>
<div><font face="Courier">Thread 0 crashed with X86 Thread State (32-bit):</font></div>
<div><font face="Courier"> eax: 0xffff07a0 ebx: 0x004a713b ecx: 0x00000000 edx: 0x00000002</font></div>
<div><font face="Courier"> edi: 0x0032d860 esi: 0x00000000 ebp: 0xbfffeca8 esp: 0xbfffeca0</font></div>
<div><font face="Courier"> ss: 0x0000001f efl: 0x00010202 eip: 0xffff07d4 cs: 0x00000017</font></div>
<div><font face="Courier"> ds: 0x0000001f es: 0x0000001f fs: 0x00000000 gs: 0x00000037</font></div>
<div><font face="Courier"> cr2: 0x00000000</font></div>
<div><font face="Courier"><br></font></div>
<div><font face="Courier">Binary Images:</font></div>
<div><font face="Courier"> 0x1000 - 0x1ffe org.python.pythonapp 2.5.0 (2.5.0a0) <fccdb19d43071ba163b93b4fddd2a7d0> /System/Library/Frameworks/Python.framework/Versions/2.5/Resources/Python.app/Contents/MacOS/Python
</font></div>
<div><font face="Courier"> 0x49000 - 0x4afff readline.so ??? (???) <64946ffe456c7bf202eb236c1afaa0c4> /System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib-dynload/readline.so</font></div>
<div><font face="Courier"> 0x118000 - 0x1e3ffb org.python.python 2.5 (2.5) <ce7182a9e975861a321dfeeca76f54db> /System/Library/Frameworks/Python.framework/Versions/2.5/Python</font></div>
<div><font face="Courier"> 0x2b0000 - 0x2c6fea libedit.2.dylib ??? (???) <be5a6f391887bb96bdeeafd443cf19fb> /usr/lib/libedit.2.dylib</font></div>
<div><font face="Courier"> 0x400000 - 0x613fe7 +_Sword.so ??? (???) <cb87ac42234856be59203679fcefd578> /Users/jbrisbin/scratch/_Sword.so</font></div>
<div><font face="Courier">0x8fe00000 - 0x8fe2d883 dyld 95.3 (???) <3896c718b33f3e065e199a659baf1a2b> /usr/lib/dyld</font></div>
<div><font face="Courier">0x90780000 - 0x907ddffb libstdc++.6.dylib ??? (???) <04b812dcec670daa8b7d2852ab14be60> /usr/lib/libstdc++.6.dylib</font></div>
<div><font face="Courier">0x90b58000 - 0x90b5ffe9 libgcc_s.1.dylib ??? (???) <a9ab135a5f81f6e345527df87f51bfc9> /usr/lib/libgcc_s.1.dylib</font></div>
<div><font face="Courier">0x91da1000 - 0x91dafffd libz.1.dylib ??? (???) <5ddd8539ae2ebfd8e7cc1c57525385c7> /usr/lib/libz.1.dylib</font></div>
<div><font face="Courier">0x92592000 - 0x92593fef libmathCommon.A.dylib ??? (???) /usr/lib/system/libmathCommon.A.dylib</font></div>
<div><font face="Courier">0x9431d000 - 0x9434cff7 libncurses.5.4.dylib ??? (???) <3b2ac2ca8190942b6b81d2a7012ea859> /usr/lib/libncurses.5.4.dylib</font></div>
<div><font face="Courier">0x963ba000 - 0x96514fe3 libSystem.B.dylib ??? (???) <08d9ec2f36455fc197b9b44adf62f304> /usr/lib/libSystem.B.dylib</font></div>
<div><font face="Courier">0xffff0000 - 0xffff1780 libSystem.B.dylib ??? (???) /usr/lib/libSystem.B.dylib</font></div>
<div><br> </div>
<div>I'm just playing around, reading the example C++ files and trying to translate that into python. Here's what I did to cause the error:</div>
<div><br> </div>
<div>
<div><font face="Courier">+-( ~/scratch ):> python</font></div>
<div><font face="Courier">Python 2.5.1 (r251:54863, Oct 9 2007, 20:39:46) </font></div>
<div><font face="Courier">[GCC 4.0.1 (Apple Inc. build 5465)] on darwin</font></div>
<div><font face="Courier">Type "help", "copyright", "credits" or "license" for more information.</font></div>
<div><font face="Courier">>>> from Sword import *</font></div>
<div><font face="Courier">>>> mf = MarkupFilterMgr(FMT_WEBIF)</font></div>
<div><font face="Courier">>>> mgr = SWMgr(mf)</font></div>
<div><font face="Courier">>>> mods = mgr.getModules()</font></div>
<div><font face="Courier">>>> mods</font></div>
<div><font face="Courier"><Sword.ModuleMap; proxy of <Swig Object of type 'std::map<<a>sword::SWBuf,sword::SWModule</a> *,std::less<<a>sword::SWBuf</a> >,std::allocator<std::pair<<a>sword::SWBuf</a>
const,<a>sword::SWModule</a> * > > > *' at 0x3282e8> ></font></div>
<div><font face="Courier">>>> mod = mods.begin()</font></div>
<div><font face="Courier">>>> mod</font></div>
<div><font face="Courier"><Sword.PySwigIterator; proxy of <Swig Object of type 'swig::PySwigIterator *' at 0x315db0> ></font></div>
<div><font face="Courier">>>> mod.next()</font></div>
<div><font face="Courier">Bus error</font></div>
<div><br> </div>
<div>Same thing happens with I try and read anything from the iterator. It just crashes python.</div>
<div><br> </div>
<div>Any ideas?</div></div>
<div><span style="FONT-WEIGHT: normal; FONT-SIZE: 12px; WORD-SPACING: 0px; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; LINE-HEIGHT: normal; FONT-STYLE: normal; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate; FONT-VARIANT: normal">
<div><br>Thanks!</div>
<div><br> </div>
<div>Jon Brisbin</div>
<div><a onclick="return top.js.OpenExtLink(window,event,this)" href="http://jbrisbin.com/" target="_blank">http://jbrisbin.com</a></div>
<div><br> </div></span><br> </div><br> </div></div><br>_______________________________________________<br>sword-devel mailing list: <a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:sword-devel@crosswire.org">
sword-devel@crosswire.org</a><br><a onclick="return top.js.OpenExtLink(window,event,this)" href="http://www.crosswire.org/mailman/listinfo/sword-devel" target="_blank">http://www.crosswire.org/mailman/listinfo/sword-devel
</a><br>Instructions to unsubscribe/change your settings at above page<br></blockquote></div><br><br clear="all">