Another HiPE bug?

Kostis Sagonas kostis@REDACTED
Wed Oct 22 23:55:51 CEST 2003


David Wallin wrote:
 > 
 > A binary consisting of an even number of ones is taken as argument. A 
 > randomly picked bit is flipped and the new binary returned. As shown 
 > below, this is not the case (the input in this case is 
 > <<2#00000011>>). I also tried with other inputs and the result was 
 > always <<192>> when compiled with HiPE.
 >

We confirm this bug.  It is related to the construction of binaries
with variable-sized segments.  A minimal example that shows the
problem is:

construct(S) ->
    <<42:S>>.

In BEAM the call construct(8) returns <<42>> as it should.
In native code, it returns <<192>>.
Apparently, this only affects the first segment of the binary...

Thanks for this report.  We'll look into this.

Kostis Sagonas.

PS. Your previous bug report is actually a problem in the loader
    and requires help from the OTP team to be fixed...  It is due
    to the magic that the BEAM loader performs to create the code
    for module_info/* when loading a .beam file.  A simple way to
    get around it, is to change the line that reads:

	   Info = module_info(),
    to be:
	   Info = apply(?MODULE, module_info, []),

    Amazing how easily you can fool the BEAM compiler, isn't it?




More information about the erlang-questions mailing list