Building sdcc-20120118-7234 from source, the compile of _atof.c fails with a SEGV, but only for the z80, z180, r2k and gbz80 ports (although I'm not sure about the pic ports as I don't have all the bits to build them). The relevant failure of the build for z80 is this:
if [ -f z80/Makefile ]; then \
gmake -C z80 PORT=z80; \
fi
gmake[5]: Entering directory `/build/sdcc-20120118-7234/device/lib/z80'
../../../bin/sdcc -mz80 -I./../../include -I. --std-c99 -c ../_atof.c
Caught signal 11: SIGSEGV
gmake[5]: *** [_atof.rel] Error 1
gmake[5]: Leaving directory `/build/sdcc-20120118-7234/device/lib/z80'
gmake[4]: [port-specific-objects] Error 2 (ignored)
$ truss -lf -S SEGV -t!all -sSEGV gmake
[ many lines elided ]
gmake[5]: Entering directory `/build/sdcc-20120118-7234/device/lib/z80'
../../../bin/sdcc -mz80 -I./../../include -I. --std-c99 -c ../_atof.c
20350/1: Incurred fault #6, FLTBOUNDS %pc = 0xFEF2E6ED
20350/1: siginfo: SIGSEGV SEGV_MAPERR addr=0x00000004
20350/1: Received signal #11, SIGSEGV [caught]
20350/1: siginfo: SIGSEGV SEGV_MAPERR addr=0x00000004
$ pstack 20350 | c++filt
20350: ../../../bin/sdcc -mz80 -I./../../include -I. --std-c99 -c ../_atof.c
fef2e6ed std::_Rb_tree_decrement(std, _Rb_tree_node_base) (803d598, 803d5a0, 803d5a8, 81fb81d, 855e9a8, 0) + d
081f8a5d std::_Rb_tree<short, short, std, _Identity<short>, std, less<short>, std::allocator,<short>void>::_M_insert_unique(const short&) (803d5e4, 855e9c4, 8422788, 803d728, 803d7bc, 803d70c) + 12b
081f7403 std::set<short, std, less<short>, std::allocator,<short>void>::insert(const short&) (803d7cc, 855e9c4, 8422788, 803d8f0, 8446228, 0) + 23
0826a870 _Z10create_cfgRN5boost14adjacency_listINS_4vecSES1_NS_14bidirectionalSE8cfg_nodeNS_11no_propertyES4_NS_5listSEEERNS0_INS_4setSES1_NS_11undirectedSE8con_nodeS4_S4_S5_EEP8ebbIndex (803d8f0, 803d8d8, 85225a0, 0, 85305d8, 803d8fc) + 819
082683b4 z80_ralloc2_cc (85225a0, 16, 8324eed, 1, 8324d4c, b56) + 44
082671b3 z80_ralloc (85225a0, 20, 1, 1, 82ee110, 4b5) + 283
08194813 eBBlockFromiCode (8441450, 82f03ea, 82f03e3, 2, 82ee5a4, 19c5) + be3
081aa94a createFunction (84234c8, 8439480, 8423458, 8433528, 8436420, 55e) + 6ea
0817919b yyparse (83ca768, 0, 82ead6f, 1, 2, 8269860) + 40cb
0817eae8 main (7, 8047780, 80477a0, 8173c32, 82e5a20, 0) + 10a8
08173c93 _start (7, 80478ec, 80478fe, 8047904, 8047916, 804791a) + 83
This seems to be related to a recently fixed bug - 3466784 which was reported against the mcs51 build.
I'm using GCC 4.5.2 to build sdcc on Solaris 11 with Boost 1.47.0.
$ bin/sdcc -v
SDCC : mcs51/gbz80/z80/z180/r2k/ds390/TININative/ds400/hc08 3.1.2 #7234 (Jan 18 2012) (Solaris i386)
I can provide gcore dumps or full build logs, etc.. if required. Let me know what you want.
I can reproduce this with sdcc-20120113-7211 but not sdcc-20120112-7209.
Configure line in both cases was:
$ ./configure --prefix=/tmp/sdcc --disable-mcs51-port --disable-gbz80-port --disable-ds390-port --disable-ds400-port --disable-pic16-port --disable-pic14-port --disable-hc08-port --disable-ucsim --disable-sdcdb --disable-r2k-port --disable-gbz80-port
(with CXXFLAGS set to -I/build/boost_1_47_0 which is where boost is unpacked for this test).
I've attached the configure output, config.log and gmake output for reference.
config.log from failing build
output from configure for failing build
gmake output from failing build
I reproduced the problem on Windows XP with Visual Studio 2010 in debug mode:
If dies with "First-chance exception at 0x006e91b3 in sdcc.exe: 0xC0000005: Access violation reading location 0xcdcdcdd1." in file SDCCralloc.hpp, function create_cfg(), line 431:
cfg[key_to_index[ic->key]].alive.insert(sym_to_index[std::pair<int, int>(i, k)]);
After some investigation I found out that cfg[key_to_index[ic->key]].alive and cfg[key_to_index[ic->key]].dying members are not initialized:
- cfg[key_to_index[ic->key]] {ic=0x02d1b0b0 operands=[0x00000000]() alive=[0xcccccccc](...) ...} cfg_node
+ ic 0x02d1b0b0 {op=0x0000003d key=0x000000a4 seq=0x00000003 ...} iCode *
+ operands [0x00000000]() std::multimap<int,short,std::less<int>,std::allocator<std::pair<int const ,short> > >
+ alive [0xcccccccc](...) std::set<short,std::less<short>,std::allocator<short> >
+ dying [0xcccccccc](...) std::set<short,std::less<short>,std::allocator<short> >
I found the initialization of ic member at line 283:
cfg[i].ic = ic;
but I didn't find the alive and dying members initialization.
Borut
alive any dying don't have to be initialized separately: They are std::set, and the constructor will initialize them to empty sets.
Philipp
Is this problem still present in current sdcc? Are there any error message sgiven by sdcc in current versions?
Philipp
The problem still exists in svn revision #7530: alive and dying members seems not to be initilaized (value 0xcdcdcdcd) and no error messages are given.
Borut
cfg[key_to_index[ic->key]].alive and cfg[key_to_index[ic->key]].dying have default constructors. The only way for them to be uninitialized is for all of cfg[key_to_index[ic->key]] to be uninitialized. Since none of my assertions triggered, the error thus has to be uninitialized cfg[key_to_index[ic->key]] or uninitialized key_to_index[ic->key].
Philipp
Sorry, forget about key_to_index[ic->key], that one would have triggered an assertion. That leaves cfg[key_to_index[ic->key]] itself.
Philipp
Can you try once more? I added another two assertions.
Philipp
Tried with #7531 with the same result as before: no assertions hit, no additional messages. Just Caught signal 11: SIGSEGV.
Borut
Would you have another try? As of #7532 the code looks like it's half assertions. Please also check in which place the SIGSEGV occurs, since it might happen earlier now (in one of the assertions).
Philipp
With svn revision #7532 I get the following:
123 repetitions of line:
_atof.c:94: error 9: FATAL Compiler Internal Error in file 'd:\svn_snapshots\sdcc\sdcc_msvc.build\src\sdccralloc.hpp' line number '268' : Alive set non-empty upon creation.
Contact Author with source code
and after that:
Caught signal 11: SIGSEGV
The SIGSEGV happens in the same line as before.
Borut
I get pretty much the same using #7540:
gmake[5]: Entering directory `/scratch/sdcc/sdcc/device/lib/z80'
../../../bin/sdcc -mz80 -I./../../include -I. --std-c99 -c ../_atof.c
../_atof.c:94: error 9: FATAL Compiler Internal Error in file './../SDCCralloc.hpp' line number '269' : Alive set non-empty upon creation.
Contact Author with source code
Caught signal 11: SIGSEGV
gmake[5]: *** [_atof.rel] Error 1
This is most likely the same issue as #3506333, though this one occours on Solaris and the other one on Windows.
Philipp
I suspect that the constructor of cfg_node is not called by add_vertex as it should be, and added another assertion to check this in revision #7544.
Philipp
Using #7544, I don't see any asserts around the SEGV, I just get this:
....
../../../bin/sdasz80 -plosgff setjmp.s
test . = . || rm setjmp.s
../../../bin/sdcc -mz80 -I./../../include -I. --std-c99 -c ../_atof.c
Caught signal 11: SIGSEGV
gmake[5]: *** [_atof.rel] Error 1
gmake[5]: Leaving directory `/scratch/sdcc/sdcc/device/lib/z80'
gmake[4]: [port-specific-objects] Error 2 (ignored)
but I did notice this whilst building ralloc2.cc earlier in the gmake output:
g++ -ggdb -I/scratch/sdcc/boost_1_48_0 -Wall -Wno-parentheses -ggdb -I/scratch/sdcc/boost_1_48_0 -I./.. -I.. -I. -I../.. -I./../../support/util -I. -c -o ralloc2.o ralloc2.cc
ralloc2.cc: In function ‘bool omit_frame_ptr(const G_t&) [with G_t = boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS, cfg_node>]’:
ralloc2.cc:1471:60: instantiated from here
ralloc2.cc:1420:7: warning: comparison between signed and unsigned integer expressions
ralloc2.cc: In function ‘bool DEinst_ok(const assignment&, short unsigned int, const G_t&, const I_t&) [with G_t = boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS, cfg_node>, I_t = boost::adjacency_matrix<boost::undirectedS, con_node>]’:
ralloc2.cc:1070:3: instantiated from ‘float instruction_cost(const assignment&, short unsigned int, const G_t&, const I_t&) [with G_t = boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS, cfg_node>, I_t = boost::adjacency_matrix<boost::undirectedS, con_node>]’
./../SDCCralloc.hpp:720:7: instantiated from ‘void tree_dec_ralloc_introduce(T_t&, typename boost::graph_traits<Graph>::vertex_descriptor, const G_t&, const I_t&, const assignment&, bool*) [with T_t = boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS, tree_dec_node>, G_t = boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS, cfg_node>, I_t = boost::adjacency_matrix<boost::undirectedS, con_node>, typename boost::graph_traits<Graph>::vertex_descriptor = unsigned int]’
./../SDCCralloc.hpp:933:7: instantiated from ‘void tree_dec_ralloc_nodes(T_t&, typename boost::graph_traits<Graph>::vertex_descriptor, const G_t&, const I_t&, const assignment&, bool*) [with T_t = boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS, tree_dec_node>, G_t = boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS, cfg_node>, I_t = boost::adjacency_matrix<boost::undirectedS, con_node>, typename boost::graph_traits<Graph>::vertex_descriptor = unsigned int]’
ralloc2.cc:1341:3: instantiated from ‘bool tree_dec_ralloc(T_t&, const G_t&, const I_t&) [with T_t = boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS, tree_dec_node>, G_t = boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS, cfg_node>, I_t = boost::adjacency_list<boost::setS, boost::vecS, boost::undirectedS, con_node>]’
ralloc2.cc:1495:98: instantiated from here
ralloc2.cc:938:26: warning: unused variable ‘dying’
Correction - last output is from #7545
Is this issue still there in current sdcc?
Philipp
It's not evident in #8070
Ok, so I'll assume it got fixed some time around the 3.2.0 release (it seems some similar bugs went away the same way).
Philipp