Sorry for long delay, <br><br>The problem was:<br>I export a class with a std::string field and assinging its string field longer than 15chars crashed my application on one client computer using vista as os.<br><br>I wrote small test case and used previous project configurations to build and it worked (The codes are below the message)<br>
<br>Then I changed my code as small as the test code but still it was not working (what I mean by not working is that application crashed at same code line):<br><br>The only difference with my pyd and test pyd was that test pyd was near the main executable but my pyd was under a directory (module)<br>
<br>I put test pyd file in a directory and an __init__.py file and trying to import it and It also crashed just on the long (>15chars) string assignment line.<br><br>Putting all the pyd s and dlls from the module directory to the main applications directory, and arranging python import statements accordingly solved my problem in a dirty way.<br>
<br>Now the main folder contains too many dlls which is annoying. I still do not know if it is boost-related or just python related. <br>Is space allocation done automatically during std::string assignment?<br><br>When I put pyd file and an __init__.py to a folder and import it from its parent folder it crashes the application. Does the way of memory allocation change if it is in a different folder or next to the main file? <br>
<br>Thanks for your help,<br><br><br><br>Here is the test part: <br><br>a main application embed python<br>a boost python dll module loaded by python script<br>a script called by main application<br><br><br>for TestPython.pyd file:<br>
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">#include <iostream></span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">#include <string></span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">#include <boost/python.hpp></span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">class DataPack</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">{</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">public:</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> std::string name;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> void getString(const std::string& str)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> std::cout << "String Parameter: " << str << std::endl;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">};</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">using namespace boost::python;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">BOOST_PYTHON_MODULE( TestPython )</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">{ </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> class_<DataPack>("DataPack")</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> .def_readwrite("name", &DataPack::name)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> .def("getString",&DataPack::getString);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">}</span><br>
<br><br>TestApplication:<br><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">#include <boost/python.hpp></span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">int main(int argc, char **argv)</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">{ </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> Py_Initialize();</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> try {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> boost::python::import("Test");</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> catch(boost::python::error_already_set const &) {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> PyErr_Print();</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> Py_Finalize();</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> return 0;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">}</span><br style="font-family: courier new,monospace;"><br>Test.py file:<br><br><span style="font-family: courier new,monospace;">from TestPython import DataPack</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">print "Instance"</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">d = DataPack()</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">print "Instance string field assignment SHORT"</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"><a href="http://d.name">d.name</a> = "abc"</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">print "Instance string field assignment LONG"</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"><a href="http://d.name">d.name</a> = "123456789012345678901234567890"</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">print "Instance function call with short string"</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">d.getString("abc")</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">print "Instance function call with long string"</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">d.getString("123456789012345678901234567890")</span><br>
<br><div class="gmail_quote">On Fri, Oct 17, 2008 at 7:17 PM, David Abrahams <span dir="ltr"><<a href="mailto:dave@boostpro.com">dave@boostpro.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div></div><div class="Wj3C7c"><br>
on Fri Oct 17 2008, "Furkan Kuru" <furkankuru-AT-gmail.com> wrote:<br>
<br>
> Yes, that seems very likely; this looks a bit like the small string<br>
> optimization gone awry. Perhaps you have mixed the MS runtime lib<br>
> headers with a different version of the binary library.<br>
><br>
> Is there any way to remove this string optimization. Or How can I trace and find<br>
> these mixed headers to fix the problem?<br>
<br>
</div></div>I don't know. There are many people in the world much better-qualified<br>
to help you with this problem than I am. I suggest take your question<br>
to a MSVC-specific group. As Stefan said, it's unlikely that it has<br>
anything to do with boost or python.<br>
<div><div></div><div class="Wj3C7c"><br>
--<br>
Dave Abrahams<br>
BoostPro Computing<br>
<a href="http://www.boostpro.com" target="_blank">http://www.boostpro.com</a><br>
_______________________________________________<br>
Cplusplus-sig mailing list<br>
<a href="mailto:Cplusplus-sig@python.org">Cplusplus-sig@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/cplusplus-sig" target="_blank">http://mail.python.org/mailman/listinfo/cplusplus-sig</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Furkan Kuru<br>