Jump to content

Sir Alex

Members
  • Content Count

    3
  • Joined

  • Last visited

Community Reputation

1 Neutral

Technical Information

  • Delphi-Version
    Delphi 11 Alexandria
  1. Sir Alex

    Segmentation Fault in IcsMbToWc

    Ok, found a way to solve problem. In fact, System module already have crossplatform versions of functions WideCharToMultibyte and MultiByteToWideChar. So functions IcsWcToMb and IcsMbToWc can be easily replaced within: {* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *} function IcsWcToMb(CodePage: LongWord; Flags: Cardinal; WStr: PWideChar; WStrLen: Integer; MbStr: PAnsiChar; MbStrLen: Integer; DefaultChar: PAnsiChar; UsedDefaultChar: PLongBool): Integer; begin Result := LocaleCharsFromUnicode(CodePage, Flags, WStr, WStrLen, MbStr, MbStrLen, DefaultChar, PLongBool(UsedDefaultChar)); end; {* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *} function IcsMbToWc(CodePage: LongWord; Flags: Cardinal; MbStr: PAnsiChar; MbStrLen: Integer; WStr: PWideChar; WStrLen: Integer): Integer; begin Result := UnicodeFromLocaleChars(CodePage, Flags, MbStr, MbStrLen, WStr, WStrLen); end; P.S. Now, MIME decoder works fine
  2. Sir Alex

    Segmentation Fault in IcsMbToWc

    Thank you. It's successfully compiled, so I think v8.70 support Linux. :) Looks like USE_ICONV defined for all non windows platforms, so IcsMbToWc function uses libiconv library for conversion, but something going wrong inside iconv function call...
  3. Hello. I'm just tried to convert our application which uses MIME decoder from OverbyteIcsMimeDec.pas Under Ubuntu I'm got Access Violation (Segmentation fault/Invalid address) in function IcsMbToWc while decoding simple EML file. Problem reproduced by sample code (see below). Sysinfo: Delphi 11.3 (28.0.47991.2819) ICS: v8.70 release Ubunt: 22.04.2 LTS Test code: program Project1; {$APPTYPE CONSOLE} {$R *.res} uses System.SysUtils, OverbyteIcsUtils; var TestStr: RawByteString; ResStr: string; begin TestStr := 'This is an OpenPGP/MIME signed message (RFC 4880 and 3156)'; ResStr := AnsiToUnicode(TestStr, CP_UTF8); end. Stacktrace (Delphi does not show any stacktrace, so this trace from lldb debugger): * thread #1, name = 'Project1', stop reason = signal SIGSEGV: invalid address (fault address: 0x7ffffffff000) * frame #0: 0x00007ffff7fb16db UTF-16.so`gconv at loop.c:335:7 frame #1: 0x00007ffff7fb16d0 UTF-16.so`gconv(step=0x00000000007354d8, data=0x0000000000745d10, inptrp=0x00007fffffffe0a8, inend="", outbufstart=0x0000000000000000, irreversible=0x00007fffffffe170, do_flush=0, consume_incomplete=0) at skeleton.c:623:12 frame #2: 0x00007ffff7d991c2 libc.so.6`__gconv_transform_utf8_internal(step=0x0000000000735470, data=0x0000000000745ce0, inptrp=0x00007fffffffe2f8, inend="", outbufstart=0x0000000000000000, irreversible=0x00007fffffffe170, do_flush=0, consume_incomplete=0) at skeleton.c:675:17 frame #3: 0x00007ffff7d92a9f libc.so.6`__gconv(cd=0x0000000000745cd0, inbuf=0x00007fffffffe2f8, inbufend="", outbuf=0x00007fffffffe2f0, outbufend=<unavailable>, irreversible=0x00007fffffffe170) at gconv.c:77:13 frame #4: 0x00007ffff7d9238b libc.so.6`iconv(cd=<unavailable>, inbuf=0x00007fffffffe2f8, inbytesleft=0x00007fffffffe304, outbuf=0x00007fffffffe2f0, outbytesleft=0x00007fffffffe308) at iconv.c:51:16 frame #5: 0x00000000005a5dd2 Project1`Overbyteicsutils::IcsMbToWc(CodePage=0, Flags=0, MbStr=0x0000000000000000, MbStrLen=0, WStr=Summary Unavailable, WStrLen=0) at OverbyteIcsUtils.pas:2164:1
×