similar to here: http://dev.eros-os.com/hg/bitc/rev/6fcc345cd3b3
but the "(_)" case at MixFix.cxx:571
causes the invalid read at MixFix.cxx:635

the attached patch can cause a segfault on valid code (here at least
it will hit the jackpot, ymmv)
it won't segfault until you uncomment the unused import stdio I added
in sets/bit.bitc
test with the existing tests/unit/bitset.bitc
unaffected by my earlier patch, and should not conflict.
but compiles ok without it, not sure if you want the patch otherwise,

it'd probably be cleaner to cache min/max somewhere (inside or outside
of) sets.bit
and the map function could probably use callfWhenOn:bool, callfWhenOff:bool
flags currently only calls f when on,

there is an argument that could be made that none of them belong in
sets/bit.bitc,
not really standard set operations... so maybe it belongs in an
auxiliary bit set stuff place
as for the implementations they are kind of brutish, and the
similarity of implementations is
a good hint that theres probably a cleaner way.

below is a minimal reproduction which does not segfault, but can show
the problem with valgrind

bitc version 0.11
import bitc.main as main
provide bitc.main main


def main.main(argv: string[]) = {
  let on = true in
    if (on) then 1:int32 else 0:int32
  0:int32
}

$valgrind ../../compiler/BUILD/bitcc -O -I ../../libbitc --nostdlib -v
-o BUILD/parens parens.bitc ../../libbitc/BUILD/libbitc.a


==28022== Invalid read of size 8
==28022==    at 0x386DA9D49B: std::string::assign(std::string const&)
(basic_string.h:286)
==28022==    by 0x49F526: CleanMixFix(sherpa::INOstream&,
boost::shared_ptr<AST>) (basic_string.h:511)
==28022==    by 0x4A3B1F: ProcessMixFix(std::ostream&,
boost::shared_ptr<AST>) (MixFix.cxx:720)
==28022==    by 0x4A3FDC: HandleMixFix(std::ostream&,
boost::shared_ptr<AST>) (MixFix.cxx:1136)
==28022==    by 0x4A3F84: HandleMixFix(std::ostream&,
boost::shared_ptr<AST>) (MixFix.cxx:1133)
==28022==    by 0x4A3F84: HandleMixFix(std::ostream&,
boost::shared_ptr<AST>) (MixFix.cxx:1133)
==28022==    by 0x4A3F84: HandleMixFix(std::ostream&,
boost::shared_ptr<AST>) (MixFix.cxx:1133)
==28022==    by 0x4A3F84: HandleMixFix(std::ostream&,
boost::shared_ptr<AST>) (MixFix.cxx:1133)
==28022==    by 0x4A3F84: HandleMixFix(std::ostream&,
boost::shared_ptr<AST>) (MixFix.cxx:1133)
==28022==    by 0x4A3F84: HandleMixFix(std::ostream&,
boost::shared_ptr<AST>) (MixFix.cxx:1133)
==28022==    by 0x4A3F84: HandleMixFix(std::ostream&,
boost::shared_ptr<AST>) (MixFix.cxx:1133)
==28022==    by 0x4A3F84: HandleMixFix(std::ostream&,
boost::shared_ptr<AST>) (MixFix.cxx:1133)
==28022==  Address 0x5e31b78 is 24 bytes inside a block of size 464 free'd
==28022==    at 0x4A04A84: operator delete(void*) (vg_replace_malloc.c:346)
==28022==    by 0x409C98: boost::detail::shared_count::~shared_count()
(sp_counted_base_gcc_x86.hpp:145)
==28022==    by 0x4A40F0: HandleMixFix(std::ostream&,
boost::shared_ptr<AST>) (shared_ptr.hpp:160)
==28022==    by 0x4A3F84: HandleMixFix(std::ostream&,
boost::shared_ptr<AST>) (MixFix.cxx:1133)
==28022==    by 0x4A3F84: HandleMixFix(std::ostream&,
boost::shared_ptr<AST>) (MixFix.cxx:1133)
==28022==    by 0x4A3F84: HandleMixFix(std::ostream&,
boost::shared_ptr<AST>) (MixFix.cxx:1133)
==28022==    by 0x4A3F84: HandleMixFix(std::ostream&,
boost::shared_ptr<AST>) (MixFix.cxx:1133)
==28022==    by 0x4A3F84: HandleMixFix(std::ostream&,
boost::shared_ptr<AST>) (MixFix.cxx:1133)
==28022==    by 0x4A3F84: HandleMixFix(std::ostream&,
boost::shared_ptr<AST>) (MixFix.cxx:1133)
==28022==    by 0x4A3F84: HandleMixFix(std::ostream&,
boost::shared_ptr<AST>) (MixFix.cxx:1133)
==28022==    by 0x4A3F84: HandleMixFix(std::ostream&,
boost::shared_ptr<AST>) (MixFix.cxx:1133)
==28022==    by 0x4A3F84: HandleMixFix(std::ostream&,
boost::shared_ptr<AST>) (MixFix.cxx:1133)
==28022==
bitcc: Instantiate.cxx:1306: boost::shared_ptr<AST>
UocInfo::recInstantiate(std::ostream&, boost::shared_ptr<AST>, bool&,
WorkList<std::basic_string<char, std::char_traits<char>,
std::allocator<char> > >&): Assertion `ast->symType->isConcrete()'
failed.
_______________________________________________
bitc-dev mailing list
[email protected]
http://www.coyotos.org/mailman/listinfo/bitc-dev

Reply via email to