Inform7: Value handling failed: impossible deallocation

I’m using interfacing Inform7 to Inform6 routines to do real-time cryptography in adventures.
After returning from the Inform6 routines and successfully showing the results, I get the following message:

[code]*** Value handling failed: impossible deallocation ***

*** Run-time problem P49: Memory allocation proved impossible.

[ The game has finished ][/code]
The following code segments show how I’m defining my variables and calling the routines.

[Define the variables.] par_a is a number that varies. par_b is a number that varies. plaintext is indexed text that varies. ciphertext is indexed text that varies. alphabet is indexed text that varies.

To check Affine Cipher: Now par_a is 7; [slope] Now par_b is 17; [offset] Now plaintext is "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; [Set to allow one to easily see the shift is working] Now alphabet is "ABCDEFGHIJKLMNOPQRSTUVWXYZ "; [alphabet] Now ciphertext is the Affine Encryption of plaintext using alphabet and par_a and par_b; [Determine the ciphertext] Say "Returned from Encryption with [ciphertext]."; [Say the Affine Encryption of plaintext using par_a and par_b is ciphertext; [Say the ciphertext]] Now plaintext is the Affine Decryption of ciphertext using alphabet and par_a and par_b; [Determine the decrypted text] Say "Returned from Decryption with [plaintext]."; [Say the Affine Decryption of ciphertext using par_a and par_b is plaintext. [Say the decrypted text]]

[code]To decide which text is the Affine Encryption of (from_text - text) using (str_alphabet - text)and (par_a - a number) and (par_b - a number):
(- (Affine_Cipher(0, {-by-value: from_text}, {-new:indexed text},{-by-value:str_alphabet}, {par_a}, {par_b})) -).

To decide which text is the Affine Decryption of (from_text - text) using (str_alphabet - text)and (par_a - a number) and (par_b - a number):
(- (Affine_Cipher(1, {-by-value: from_text}, {-new:indexed text},{-by-value:str_alphabet}, {par_a}, {par_b})) -).
[/code]

Looks like the crypto code is working exactly as it should, but Inform7 is having trouble deallocating some of the variables at the end of the run.
It looks like the same bug as reported in http://inform7.com/mantis/view.php?id=1415
The only difference is that I’m using Inform (1.5/6.33/6L02) on a Mac OSX 10.9.4 instead of Windows.

Can anyone help me overcome this hurdle…
Am I coding something incorrectly?
Is there a better way to call the routines and avoid the issue?
If I can’t revise the code to avoid the issue, are there any known work-arounds???

ADDENDUM

I tried running the code using Glulx and got a different response:

Glulxe fatal error: Memory access out of range (3027230E)

Not sure what is being “accessed” at this point in the program, since the correct results were printed.

Managed to get things working without errors.
Seems that one must always transmute and un-transmute any “string” not passed back to Inform7.
Any “strings” returned as a “retval” must be transmuted within in the routine and passed back without un-transmuting.
Had a dickens of a time extracting this info from the various code and documentation.
It isn’t actually stated explicitly anywhere.

If even the template files don’t make it clear when to transmute text then I think you could file that as a documentation bug.

Actually; I may file a bug (suggestion) report. I haven’t yet, because I really don’t want to beat on a team who are doing this on their own time. It could just be that I was trying to use the new Inform7/I6 before they had a chance to update the documentation.

Frankly, I think that the individual routines are reasonably well documented (especially for a free product). However; a call/return section in each routine header would have helped me a lot. However; I was still able to distill how to call and return strings (with the new string handling) by pouring over enough of the templates routines and “reverse engineering” the design concept.

In figuring out how to pass and return arguments, I noted that currently there appears to be very little documentation on interfacing I7 and I6. What there is does not address how to pass “string” data under the new string handling paradigm. A few examples would sure help, too. I’d submit mine, but I’d want to vet them out with one of the key designers to ensure I don’t lead anyone astray.