debugconsole/console.cpp: In function 'void dc_do_command(SCP_string*)':
debugconsole/console.cpp:266:49: error: cannot pass objects of non-trivially-copyable type 'SCP_string {aka class std::basic_string<char, std::char_traits<char>, SCP_vm_allocator<char> >}' through '...'
dc_printf("Command not found: '%s'\n", command);
^
debugconsole/console.cpp:274:70: error: cannot pass objects of non-trivially-copyable type 'SCP_string {aka class std::basic_string<char, std::char_traits<char>, SCP_vm_allocator<char> >}' through '...'
dc_printf( "Ignoring the unused command line tail '%s'\n", command );
==7742== Invalid read of size 8
==7742== at 0x70ECB3A: ??? (in /usr/lib/libstdc++.so.6.0.19)
==7742== by 0x4A78FE: std::_Rb_tree_iterator<std::pair<std::basic_string<char, std::char_traits<char>, SCP_vm_allocator<char> > const, debug_command*> >::operator--() (stl_tree.h:204)
==7742== by 0x4A783A: std::_Rb_tree<std::basic_string<char, std::char_traits<char>, SCP_vm_allocator<char> >, std::pair<std::basic_string<char, std::char_traits<char>, SCP_vm_allocator<char> > const, debug_command*>, std::_Select1st<std::pair<std::basic_string<char, std::char_traits<char>, SCP_vm_allocator<char> > const, debug_command*> >, std::less<std::basic_string<char, std::char_traits<char>, SCP_vm_allocator<char> > >, SCP_vm_allocator<std::pair<std::basic_string<char, std::char_traits<char>, SCP_vm_allocator<char> > const, debug_command*> > >::_M_get_insert_unique_pos(std::basic_string<char, std::char_traits<char>, SCP_vm_allocator<char> > const&) (stl_tree.h:1333)
==7742== by 0x4A7222: std::_Rb_tree<std::basic_string<char, std::char_traits<char>, SCP_vm_allocator<char> >, std::pair<std::basic_string<char, std::char_traits<char>, SCP_vm_allocator<char> > const, debug_command*>, std::_Select1st<std::pair<std::basic_string<char, std::char_traits<char>, SCP_vm_allocator<char> > const, debug_command*> >, std::less<std::basic_string<char, std::char_traits<char>, SCP_vm_allocator<char> > >, SCP_vm_allocator<std::pair<std::basic_string<char, std::char_traits<char>, SCP_vm_allocator<char> > const, debug_command*> > >::_M_get_insert_hint_unique_pos(std::_Rb_tree_const_iterator<std::pair<std::basic_string<char, std::char_traits<char>, SCP_vm_allocator<char> > const, debug_command*> >, std::basic_string<char, std::char_traits<char>, SCP_vm_allocator<char> > const&) (stl_tree.h:1425)
==7742== by 0x4A6F9E: std::_Rb_tree<std::basic_string<char, std::char_traits<char>, SCP_vm_allocator<char> >, std::pair<std::basic_string<char, std::char_traits<char>, SCP_vm_allocator<char> > const, debug_command*>, std::_Select1st<std::pair<std::basic_string<char, std::char_traits<char>, SCP_vm_allocator<char> > const, debug_command*> >, std::less<std::basic_string<char, std::char_traits<char>, SCP_vm_allocator<char> > >, SCP_vm_allocator<std::pair<std::basic_string<char, std::char_traits<char>, SCP_vm_allocator<char> > const, debug_command*> > >::_M_insert_unique_(std::_Rb_tree_const_iterator<std::pair<std::basic_string<char, std::char_traits<char>, SCP_vm_allocator<char> > const, debug_command*> >, std::pair<std::basic_string<char, std::char_traits<char>, SCP_vm_allocator<char> > const, debug_command*> const&) (stl_tree.h:1478)
==7742== by 0x4A6C3D: std::map<std::basic_string<char, std::char_traits<char>, SCP_vm_allocator<char> >, debug_command*, std::less<std::basic_string<char, std::char_traits<char>, SCP_vm_allocator<char> > >, SCP_vm_allocator<std::pair<std::basic_string<char, std::char_traits<char>, SCP_vm_allocator<char> > const, debug_command*> > >::insert(std::_Rb_tree_iterator<std::pair<std::basic_string<char, std::char_traits<char>, SCP_vm_allocator<char> > const, debug_command*> >, std::pair<std::basic_string<char, std::char_traits<char>, SCP_vm_allocator<char> > const, debug_command*> const&) (stl_map.h:648)
==7742== by 0x4A68BA: std::map<std::basic_string<char, std::char_traits<char>, SCP_vm_allocator<char> >, debug_command*, std::less<std::basic_string<char, std::char_traits<char>, SCP_vm_allocator<char> > >, SCP_vm_allocator<std::pair<std::basic_string<char, std::char_traits<char>, SCP_vm_allocator<char> > const, debug_command*> > >::operator[](std::basic_string<char, std::char_traits<char>, SCP_vm_allocator<char> > const&) (stl_map.h:469)
==7742== by 0x4A6102: debug_command::debug_command(char*, char*, void (*)()) (consolecmds.cpp:37)
==7742== by 0x41B10D: __static_initialization_and_destruction_0(int, int) (freespace.cpp:669)
==7742== by 0x41B5EB: _GLOBAL__sub_I_Env_cubemap_drawn (freespace.cpp:8942)
==7742== by 0x916FEC: __libc_csu_init (in /home/tobias/games/fs2/fs2_open_3.7.1_DEBUG)
==7742== by 0x75B3A94: (below main) (in /usr/lib/libc-2.19.so)
==7742== Address 0x8 is not stack'd, malloc'd or (recently) free'd
[...] Based on m!m's comment "...removing all uses of [the c-style version] and patching all usages of it", it sounds like there are quite a lot of references to both throughout the code, so you should leave both versions in for now. [...]I haven't actually checked which version is used, I only noticed that there was quite a lot of duplicated code because of this and I though now would be a better time to unify it to use the SCP_string version instead of waiting and then never doing it.
Regarding "using a pointer to a variable to pass return values ", I haven't checked the diff, but is this used in the function parameter list or in the return statement? If it's in the latter, you would be returning a pointer to a variable on the stack and that is a big no-no.I was talking about pointers in the argument list.
I haven't actually checked which version is used, I only noticed that there was quite a lot of duplicated code because of this and I though now would be a better time to unify it to use the SCP_string version instead of waiting and then never doing it.
+ <ClCompile Include="..\..\code\debugconsole\consolecmds.cpp" />
+ <ClCompile Include="..\..\code\debugconsole\consoleparse.cpp" />
...
+ <ClInclude Include="..\..\code\debugconsole\console.h" />
+ <ClInclude Include="..\..\code\debugconsole\consoleparse.h" />
A few remaining locations where non-POD types passed to variadic functions. Suggest adding the *.c_str() to each.
I experienced issues that required me to "#include "debugconsole/console.h" at the top of code/windows_stubs/stubs.cpp on OS X.
There's an introduction of a C++11 feature, pop_back() on the std_string type. This raising of the minimum supported compiler might be inadvertent, as there is broad use of the old pop_back() on the deque container in that file. Suggest approach is discussed here in the forum thread.
dc_command_buf.erase(dc_command_buf.size() - 1);
code/parse/sexp.cpp:24672:51: error: cannot pass object of non-POD type 'SCP_string' (aka 'basic_string<char,
std::char_traits<char>, SCP_vm_allocator<char> >') through variadic function; call will abort at runtime [-Wnon-pod-varargs]
sprintf(sexp_always, "( when ( true ) ( %s ) )", sexp);
^
code/parse/sexp.cpp:24675:46: error: cannot pass object of non-POD type 'SCP_string' (aka 'basic_string<char,
std::char_traits<char>, SCP_vm_allocator<char> >') through variadic function; call will abort at runtime [-Wnon-pod-varargs]
dc_printf("SEXP '%s' run, sexp_val = %d\n", sexp_always, sexp_val);
code/starfield/starfield.cpp:983:53: error: cannot pass object of non-POD type 'SCP_string' (aka
'basic_string<char, std::char_traits<char>, SCP_vm_allocator<char> >') through variadic function; call will abort at runtime [-Wnon-pod-varargs]
dc_printf("Error: unknown flag argument '%s'\n", arg);
^
There's a DCF_BOOL macro invoked at line 405, this is likely the cause. Since code/windows_stubs/ is not included in the MSVS project filters, I did not catch that. Thanks.
set_hull ?
==10060==ERROR: AddressSanitizer: SEGV on unknown address 0x0000000001e8 (pc 0x000102212d8a sp 0x7fff5fbfc740 bp 0x7fff5fbfc830 T0)
#0 0x102212d89 in dcf_set_hull ship.cpp:13666
#1 0x10074003e in dc_do_command console.cpp:145
#2 0x100747296 in debug_console) console.cpp:576
#3 0x10016e885 in game_poll freespace.cpp:5139
#4 0x100147d52 in game_check_key freespace.cpp:4934
#5 0x102515404 in UI_WINDOW::process window.cpp:416
#6 0x101067bd1 in player_select_do playermenu.cpp:343
#7 0x100177f1b in game_do_state freespace.cpp:6763
#8 0x1007b4bbd in gameseq_process_events gamesequence.cpp:409
#9 0x10017e334 in game_main freespace.cpp:7142
#10 0x10017f9f8 in SDL_main freespace.cpp:7276
set_shield ?
==10010==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000028 (pc 0x000102af59ec sp 0x7fff5fbfc600 bp 0x7fff5fbfc750 T0)
#0 0x102af59eb in shield_get_strength objectshield.cpp:24
#1 0x102212815 in dcf_set_shield ship.cpp:13640
#2 0x10074003e in dc_do_command console.cpp:145
#3 0x100747296 in debug_console) console.cpp:576
#4 0x10016e885 in game_poll freespace.cpp:5139
#5 0x100147d52 in game_check_key freespace.cpp:4934
#6 0x102515404 in UI_WINDOW::process window.cpp:416
#7 0x101067bd1 in player_select_do playermenu.cpp:343
#8 0x100177f1b in game_do_state freespace.cpp:6763
#9 0x1007b4bbd in gameseq_process_events gamesequence.cpp:409
#10 0x10017e334 in game_main freespace.cpp:7142
#11 0x10017f9f8 in SDL_main freespace.cpp:7276
* SHA-1: 6253bd373f34cd086ba7fce140b74bd48519db66
|\
| * SHA-1: c9fd0e4a2bfdd9436c90cc4cc4abe8b35aabbcd3
| |
* | SHA-1: ce281814043471e5263c35d86178709a4715fb46
|/
* SHA-1: 21136e87a5c5601e33c01162c43d0cae648de10b