Archived Forum Post

Index of archived forum posts

Question:

base58 encoding of some strings cause Visual Studio crash

Nov 13 '15 at 06:47

I am experimenting with base58 encoding in EncryptStringENC and EncodeString methods. I was trying to encode a Guid string (w/o braces) as base58 (the reason is irrelevant) when I decided to try random strings. If I specify e.g. the single character "f" as input, Visual Studio 2015 closes immediately. No crash message or anything. In some tests I manage to get a System.StackOverflowException, but mostly VS2015 closes without warning. Even if I wrap the code in try/catch it still does not catch the exception.

I have to acknowledge that base58 encoding may not be the proper choice or even possible in some cases, but I still do not believe that the application should not crash.

I created a new empty win32 console application targeting .NET Framework 4.5.2 and x86 platform for the test and installed Chilkat 9.5.0.52 from Nuget.

The code for the test:

var crypt = new Crypt2();
crypt.UnlockComponent("xxxx");
crypt.VerboseLogging = true;
crypt.DebugLogFilePath = "...";
var strOutput = crypt.EncodeString("f", "utf-8", "base58");

and/or:

var crypt = new Crypt2();
crypt.UnlockComponent("xxxx");
crypt.VerboseLogging = true;
crypt.DebugLogFilePath = "...";
crypt.CryptAlgorithm = "none";
crypt.EncodingMode = "base58";
crypt.Charset = "utf-8";
var strOutput = crypt.EncryptStringENC("f");

In both cases it makes no difference if I specify "ansi" or "utf-8" as charset or leave it out completely. If I try many other input strings, e.g. "abc123", "ijijij" it works fine, but e.g. "xyzxyz" does not.

The debug log does not provide much help unfortunately (include both success and failure output):

EncodeString:
    DllDate: Aug 26 2015
    ChilkatVersion: 9.5.0.52
    UnlockPrefix: xxxxxx
    Username: xxxx:xxxx
    Architecture: Little Endian; 32-bit
    Language: .NET 4.5
    VerboseLogging: 1
    inputString: ijijij
    charset: ansi
    encoding: base58
    result: uVeZm5Db
    (leaveContext 15ms)
EncodeString:
    DllDate: Aug 26 2015
    ChilkatVersion: 9.5.0.52
    UnlockPrefix: xxxx
    Username: xxxx:xxxx
    Architecture: Little Endian; 32-bit
    Language: .NET 4.5
    VerboseLogging: 1
    inputString: xyzxyz
    charset: ansi
    encoding: base58

and from EncryptStringENC:

EncryptStringENC:
    DllDate: Aug 26 2015
    ChilkatVersion: 9.5.0.52
    UnlockPrefix: xxxx
    Username: xxxx::xxxx
    Architecture: Little Endian; 32-bit
    Language: .NET 4.5
    VerboseLogging: 1
    szInput: 6
    cryptDetails:
        algorithm: none
        keyLength: 128
        paddingScheme: 0
        cipherMode: cbc
        encodingMode: base58
        charset: utf-8
        secretKeyLen: 0
        iv: (empty)
        dataNumBytes: 6
        dataHex: 7879 7A78 797A
        (leaveContext 15ms)
    encryptData2:
        algorithm: none
        (leaveContext)
    szOutput: 6
EncryptStringENC:
    DllDate: Aug 26 2015
    ChilkatVersion: 9.5.0.52
    UnlockPrefix: xxxx
    Username: xxxx:xxxx
    Architecture: Little Endian; 32-bit
    Language: .NET 4.5
    VerboseLogging: 1
    szInput: 6
    cryptDetails:
        algorithm: none
        keyLength: 128
        paddingScheme: 0
        cipherMode: cbc
        encodingMode: base58
        charset: utf-8
        secretKeyLen: 0
        iv: (empty)
        dataNumBytes: 6
        dataHex: 696A 696A 696A
        (leaveContext 31ms)
    encryptData2:
        algorithm: none
        (leaveContext 16ms)
    szOutput: 6
    Success.
    (leaveContext 47ms)

I ran the same tests with Visual Studio 2013 that does not appear to close without warning, however it does not provide any more detail. The following event log gets added from Visual Studio 2015 though:

The description for Event ID 0 from source Application cannot be found. Either the component that raises this event is not installed on your local computer or the installation is corrupted. You can install or repair the component on the local computer.

If the event originated on another computer, the display information had to be saved with the event.

The following information was included with the event:

Error Handler Exception: System.ServiceModel.CommunicationException: There was an error reading from the pipe: Unrecognized error 109 (0x6d). ---> System.IO.IOException: The read operation failed, see inner exception. ---> System.ServiceModel.CommunicationException: There was an error reading from the pipe: Unrecognized error 109 (0x6d). ---> System.IO.PipeException: There was an error reading from the pipe: Unrecognized error 109 (0x6d).
   at System.ServiceModel.Channels.PipeConnection.OnAsyncReadComplete(Boolean haveResult, Int32 error, Int32 numBytes)
   --- End of inner exception stack trace ---
   at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result)
   at System.ServiceModel.Channels.ConnectionStream.EndRead(IAsyncResult asyncResult)
   at System.Net.FixedSizeReader.ReadCallback(IAsyncResult transportResult)
   --- End of inner exception stack trace ---
   at System.Net.Security.NegotiateStream.EndRead(IAsyncResult asyncResult)
   at System.ServiceModel.Channels.StreamConnection.EndRead()
   --- End of inner exception stack trace ---
   at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result)
   at System.ServiceModel.Channels.TransportDuplexSessionChannel.EndTryReceive(IAsyncResult result, Message& message)
   at System.ServiceModel.Dispatcher.DuplexChannelBinder.EndTryReceive(IAsyncResult result, RequestContext& requestContext)
   at System.ServiceModel.Dispatcher.ErrorHandlingReceiver.EndTryReceive(IAsyncResult result, RequestContext& requestContext) \r\n    at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result)
   at System.ServiceModel.Channels.TransportDuplexSessionChannel.EndTryReceive(IAsyncResult result, Message& message)
   at System.ServiceModel.Dispatcher.DuplexChannelBinder.EndTryReceive(IAsyncResult result, RequestContext& requestContext)
   at System.ServiceModel.Dispatcher.ErrorHandlingReceiver.EndTryReceive(IAsyncResult result, RequestContext& requestContext)

the message resource is present but the message is not found in the string/message table

Accepted Answer

This new build should fix it:

32-bit Download: http://www.chilkatsoft.com/download/preRelease/ChilkatDotNet45-9.5.0-win32.zip
64-bit Download: http://www.chilkatsoft.com/download/preRelease/ChilkatDotNet45-9.5.0-x64.zip


Answer

Thanks, I'll investigate..


Answer

Thanks, the new win32 build works great :-)

Can I ask what was the problem and whether it was only related to base58?

And also an estimated release date of the next Nuget package including this fix?