<html><head></head><body>Thanks Jaak. I also tested surrounding the symbols in an anonymous namespace but this alone did not fix the problem for me.<br>
<br>
Can you explain again why there is even a problem at all?<br>
<br>
Again, every one of those globals is in the same compile unit and in the correct order, top down. The initialization spec you cite does not seem to explain the issue, unless I'm daft.<br>
<br>
I would like to understand why we need the change, and document it.<br>
<br>
Thanks for the patch,<br>
<br>
Troy<br><br><div class="gmail_quote">Jaak Ristioja <jaak@ristioja.ee> wrote:<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre class="k9mail">On 11.09.2013 22:35, DM Smith wrote:<br /><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #729fcf; padding-left: 1ex;">The C++ standard does specify order w/in a file (top down), but not<br />across files.</blockquote><br />Yeah, something like that. It is explained in detail in 3.6.2 of the C++<br />03 standard. I've attached a patch which fixes the issue for these<br />globals (and as a side effect might also get rid of three exported<br />symbols). I just put these objects into local scope to ensure that they<br />get (dynamically) initialized on use.<br /><br />Blessings,<br />Jaak<br /><br />On 11.09.2013 22:35, DM Smith wrote:<br /><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #729fcf; padding-left: 1ex;">The C++ standard does specify order w/in a file (top down), but not<br />across files. This fact can be used to order across files by using a<br />global from one to initialize a global another. Don't recommend it, but<br />it is nice when it is a must.<br /><br />-- DM<br /><br />On Sep 11, 2013, at 12:56 PM, "Troy A. Griffitts" <scribe@crosswire.org<br /><mailto:scribe@crosswire.org>> wrote:<br /><br /><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #ad7fa8; padding-left: 1ex;">Jaak, I disagree that your comments have anything to do with this<br />problem. I have confirmed that the 3 file globals immediately<br />preceding the problem global have been initialized. I doubt you are<br />saying the c++ standard doesn't support initializing a global array<br />and then initializing a global std::list with the members of this<br />array, all in the same object file. I know the spec doesn't assure<br />global initialization order across object files, but within the same<br />object file, I find it hard to believe there is no specification to<br />the order.<br /><br />Jaak Ristioja <jaak@ristioja.ee <mailto:jaak@ristioja.ee>> wrote:</blockquote><br />It's not a compiler bug.<br /><br />Basically the C++ standard does not enforce an initialization order<br />for globals. So the compiler is free to initialize such stuff in any<br />order. I think your toolchain just happens to be lucky enough to do<br />that in an the order which doesn't yield in a crash.<br /><br />I don't have the time to look this up in the C++ standards myself, but<br />you can google such stuff:<br /><br /><a href="http://stackoverflow.com/questions/3746238/c-global-initialization-order-ignores-dependencies">http://stackoverflow.com/questions/3746238/c-global-initialization-order-ignores-dependencies</a><br /><br /><br />Blessings,<br />Jaak<br /><br />On 10.09.2013 18:12, Troy A. Griffitts wrote:<br /><br />Hey Jaak,<br /><br />Thank, yeah, but why? :)<br /><br />My investigation turns up:<br /><br />shared build works fine and valgrinds clean static build on g++<br />(GCC) 4.8.1 (F19) fails static build on g++ (GCC) 4.4.7 (RHEL 6.4)<br />works fine and valgrinds clean<br /><br />In the error case, it seems that std::list's c-tor(iterator<br />start,<br />iterator end) doesn't get called appropriately, though all the<br />other file globals get initialized just fine.<br /><br />I moved the global filter in the utility to a stack variable and<br />it alleviates the problem, but still wonder why the problem in the<br />first place.<br /><br />Any advice would be appreciated. If I'm doing something wrong, I'd<br />like to change it, but right now I'm going with "compiler bug" :)<br /><br />Troy<br /><br /><br /><br /><br /><br />On 09/10/2013 08:20 AM, Jaak Ristioja wrote: I'm pretty sure that<br />the crash is because the global<br /><br />const StringList oValues(&choices[0], &choices[2]);<br /><br />in ../src/modules/filters/utf8greekaccents.cpp:41 is not<br />initialized when it is used in<br />UTF8GreekAccents::UTF8GreekAccents()<br />to initialize the global<br /><br />UTF8GreekAccents greekAccentsFilter;<br /><br />instance in imp2gbs.cpp:62.<br /><br /><br />Blessings, Jaak<br /><br />On 10.09.2013 02:02, Peter von Kaehne wrote:<br /><br />I hate to bring this up, now, when we really all<br />want 1.7<br />out, but current svn head produces a segmentation<br />fault in<br />imp2gbs. The other utilities insofar as I tested<br />them seem to<br />be fine.<br /><br />Below the stacktrace. Tell me if you need more. I<br />basically<br />use <a href="http://usrinst.sh">usrinst.sh</a> <<a href="http://usrinst.sh">http://usrinst.sh</a>/> produced<br />binaries, with the only modification<br />that I changed the install directory to /usr/local/bin<br /><br /><br /><br />peter@peter-ThinkPad-Twist:~/Source/sword$ gdb<br />/usr/local/bin/imp2gbs GNU gdb (GDB) 7.5-ubuntu<br />Copyright (C)<br />2012 Free Software Foundation, Inc. License<br />GPLv3+: GNU GPL<br />version 3 or later<br /><<a href="http://gnu.org/licenses/gpl.html">http://gnu.org/licenses/gpl.html</a>> This is<br />free software: you are free to change and<br />redistribute it.<br />There is NO WARRANTY, to the extent permitted by<br />law. Type<br />"show copying" and "show warranty" for details.<br />This GDB was<br />configured as "i686-linux-gnu". For bug reporting<br />instructions, please see:<br /><<a href="http://www.gnu.org/software/gdb/bugs">http://www.gnu.org/software/gdb/bugs</a>/>... Reading<br />symbols<br />from /usr/local/bin/imp2gbs...done. (gdb) r Starting<br />program: /usr/local/bin/imp2gbs<br /><br />Program received signal SIGSEGV, Segmentation fault.<br />0x08050b7a in sword::SWBuf::c_str (this=0x8) at<br />../include/swbuf.h:141 141 inline const char<br />*c_str() const{<br />return buf; } (gdb) bt #0 0x08050b7a in<br />sword::SWBuf::c_str<br />(this=0x8) at ../include/swbuf.h:141 #1 0x0805a790 in<br />sword::SWOptionFilter::setOptionValue (this=0x8115b60<br /><greekAccentsFilter>, ival=0x80c715b "On") at<br />../src/modules/filters/swoptfilter.cpp:51 #2<br />0x0805aca2 in<br />sword::UTF8GreekAccents::UTF8GreekAccents<br />(this=0x8115b60<br /><greekAccentsFilter>, __in_chrg=<optimised out>,<br />__vtt_parm=<optimised out>) at<br />../src/modules/filters/utf8greekaccents.cpp:43 #3<br />0x0805099d<br />in __static_initialization_and_destruction_0<br />(__initialize_p=1, __priority=65535) at<br />imp2gbs.cpp:62 #4<br />0x080509df in _GLOBAL__sub_I_imp2gbs.cpp(void) () at<br />imp2gbs.cpp:273 #5 0x080c6ae2 in __libc_csu_init () #6<br />0xb77f046a in __libc_start_main () from<br />/lib/i386-linux-gnu/<a href="http://libc.so">libc.so</a> <<a href="http://libc.so">http://libc.so</a>/>.6 #7<br />0x0804f931 in _start ()<br />(gdb) #0 0x08050b7a in sword::SWBuf::c_str<br />(this=0x8) at<br />../include/swbuf.h:141 #1 0x0805a790 in<br />sword::SWOptionFilter::setOptionValue (this=0x8115b60<br /><greekAccentsFilter>, ival=0x80c715b "On") at<br />../src/modules/filters/swoptfilter.cpp:51 #2<br />0x0805aca2 in<br />sword::UTF8GreekAccents::UTF8GreekAccents<br />(this=0x8115b60<br /><greekAccentsFilter>, __in_chrg=<optimised out>,<br />__vtt_parm=<optimised out>) at<br />../src/modules/filters/utf8greekaccents.cpp:43 #3<br />0x0805099d<br />in __static_initialization_and_destruction_0<br />(__initialize_p=1, __priority=65535) at<br />imp2gbs.cpp:62 #4<br />0x080509df in _GLOBAL__sub_I_imp2gbs.cpp(void) () at<br />imp2gbs.cpp:273 #5 0x080c6ae2 in __libc_csu_init () #6<br />0xb77f046a in __libc_start_main () from<br />/lib/i386-linux-gnu/<a href="http://libc.so">libc.so</a> <<a href="http://libc.so">http://libc.so</a>/>.6 #7<br />0x0804f931 in _start ()<br />(gdb) #0 0x08050b7a in sword::SWBuf::c_str<br />(this=0x8) at<br />../include/swbuf.h:141 #1 0x0805a790 in<br />sword::SWOptionFilter::setOptionValue (this=0x8115b60<br /><greekAccentsFilter>, ival=0x80c715b "On") at<br />../src/modules/filters/swoptfilter.cpp:51 #2<br />0x0805aca2 in<br />sword::UTF8GreekAccents::UTF8GreekAccents<br />(this=0x8115b60<br /><greekAccentsFilter>, __in_chrg=<optimised out>,<br />__vtt_parm=<optimised out>) at<br />../src/modules/filters/utf8greekaccents.cpp:43 #3<br />0x0805099d<br />in __static_initialization_and_destruction_0<br />(__initialize_p=1, __priority=65535) at<br />imp2gbs.cpp:62 #4<br />0x080509df in _GLOBAL__sub_I_imp2gbs.cpp(void) () at<br />imp2gbs.cpp:273 #5 0x080c6ae2 in __libc_csu_init () #6<br />0xb77f046a in __libc_start_main () from<br />/lib/i386-linux-gnu/<a href="http://libc.so">libc.so</a> <<a href="http://libc.so">http://libc.so</a>/>.6 #7<br />0x0804f931 in _start ()<br />(gdb)<br /><br /><br /><br /><hr /><br />sword-devel<br />mailing list: sword-devel@crosswire.org<br /><mailto:sword-devel@crosswire.org><br /><a href="http://www.crosswire.org/mailman/listinfo/sword-devel">http://www.crosswire.org/mailman/listinfo/sword-devel</a><br />Instructions to unsubscribe/change your settings<br />at above<br />page<br /><br /><br /><br /><hr /><br />sword-devel<br />mailing list: sword-devel@crosswire.org<br /><mailto:sword-devel@crosswire.org><br /><a href="http://www.crosswire.org/mailman/listinfo/sword-devel">http://www.crosswire.org/mailman/listinfo/sword-devel</a><br />Instructions to unsubscribe/change your settings at above page<br /><br /><br /><br /><hr /><br />sword-devel mailing<br />list: sword-devel@crosswire.org<br /><mailto:sword-devel@crosswire.org><br /><a href="http://www.crosswire.org/mailman/listinfo/sword-devel">http://www.crosswire.org/mailman/listinfo/sword-devel</a> Instructions<br />to unsubscribe/change your settings at above page<br /><br /><br /><br /><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #ad7fa8; padding-left: 1ex;"><hr /><br /><br />sword-devel mailing list: sword-devel@crosswire.org <mailto:sword-devel@crosswire.org><br /><a href="http://www.crosswire.org/mailman/listinfo/sword-devel">http://www.crosswire.org/mailman/listinfo/sword-devel</a><br />Instructions to unsubscribe/change your settings at above page<br /><br /><br />-- <br />Sent from my Android device with K-9 Mail. Please excuse my brevity.<br /><hr /><br />sword-devel mailing list: sword-devel@crosswire.org<br /><mailto:sword-devel@crosswire.org><br /><a href="http://www.crosswire.org/mailman/listinfo/sword-devel">http://www.crosswire.org/mailman/listinfo/sword-devel</a><br />Instructions to unsubscribe/change your settings at above page</blockquote><br /><br /><br /><hr /><br />sword-devel mailing list: sword-devel@crosswire.org<br /><a href="http://www.crosswire.org/mailman/listinfo/sword-devel">http://www.crosswire.org/mailman/listinfo/sword-devel</a><br />Instructions to unsubscribe/change your settings at above page</blockquote><br /><br /></pre><p style="margin-top: 2.5em; margin-bottom: 1em; border-bottom: 1px solid #000"></p><pre class="k9mail"><hr /><br />sword-devel mailing list: sword-devel@crosswire.org<br /><a href="http://www.crosswire.org/mailman/listinfo/sword-devel">http://www.crosswire.org/mailman/listinfo/sword-devel</a><br />Instructions to unsubscribe/change your settings at above page</pre></blockquote></div><br>
-- <br>
Sent from my Android device with K-9 Mail. Please excuse my brevity.</body></html>