Re: SWITCH question

new topic     » goto parent     » topic index » view thread      » older message » newer message

Brilliant, irv! Good work.

irv said...

In addition, see if you can find anything that breaks due to removing it.

I haven't tested it, but that looks like it would break the duplicate check when one is comparing strings.

irv said...

In be_execute.c, around line 1616 or so, in function analyze_switch():

else if( !IS_ATOM_INT( new_values->base[i] ) || IS_ATOM_INT( second_val ) ){ 
	//c = (0 == compare( new_values->base[i], second_val ) ); -- commenting this out avoids the crash ? 

I think the real bug is the line above. I think there's a typo with a missing logical not, and the real fix should be:

else if( !IS_ATOM_INT( new_values->base[i] ) || !IS_ATOM_INT( second_val ) ){ 
	c = (0 == compare( new_values->base[i], second_val ) ); 

If you look at the definition of compare(), in be_runtime.c, you will see this:

object compare(object a, object b) 
/* Compare general objects a and b. Return 0 if they are identical, 

   1 if a > b, -1 if a < b. All atoms are less than all sequences. 
   The INT-INT case *must* be taken care of by the caller */ 

However, the missing 'logical not' after the 'logical or' means that we are sending some INT-INT cases to compare(), which causes a crash (since compare() assumes one of the arguments is a pointer to an internal structure and dereferences accordingly).

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu