Printing from Session 0 and Locale causing variant issues?

edited 7:05AM in FastReport VCL
I have a small command line program that gets kicked off by another service that appears to run in Session 0 of windows.
They use it to print invoices and such from an old inventory system.

I notice a lot of cases where in session 0, my program generates a lot of EVariantTypeCastError's

Run the program again manually from a logged in user and everything is fine.

Windows 10 / 7 / 2012 server / ect ....

Using Tokyo 10.3.2 and latest FR6 ...
exception class    : EVariantTypeCastError
exception message  : Could not convert variant of type (UnicodeString) into type (Currency).

main thread ($30f8):
00470a97 +06f CMW.exe      System.Variants   679   +1 VarCastError
00470ede +01a CMW.exe      System.Variants   748   +3 VarResultCheck
004749ca +086 CMW.exe      System.Variants  2838   +7 VarToCurrencyAsString
00474da3 +23b CMW.exe      System.Variants  2926  +31 @VarToCurrency
004781d2 +022 CMW.exe      System.Variants  4274   +2 CurrOp
00478440 +108 CMW.exe      System.Variants  4364  +26 SimpleVarOp
004785fe +022 CMW.exe      System.Variants  4435   +6 @VarOp
01f684a1 +40d CMW.exe      frxClass         8889  +74 TfrxCustomMemoView.CalcAndFormat
01f67bdc +5d4 CMW.exe      frxClass         8766  +87 TfrxCustomMemoView.GetData
01782e1c +14c CMW.exe      frxEngine        1830  +33 TfrxEngine.Stretch
0178594b +223 CMW.exe      frxEngine        2796  +58 TfrxEngine.DoShow
01782622 +05a CMW.exe      frxEngine        1638   +8 TfrxEngine.ShowBand
017835d0 +2b8 CMW.exe      frxEngine        2003  +49 TfrxEngine.AddPage
0178228a +222 CMW.exe      frxEngine        1549  +35 TfrxEngine.InitPage
0178192f +06f CMW.exe      frxEngine        1359   +4 ShowPage
01781cb6 +102 CMW.exe      frxEngine        1418  +27 TfrxEngine.RunPage
0177f219 +0e5 CMW.exe      frxEngine         514  +14 DoPages
0177f276 +026 CMW.exe      frxEngine         523   +3 TfrxEngine.RunReportPages
0177ee9a +1b2 CMW.exe      frxEngine         435  +37 TfrxEngine.Run
01f76baf +1df CMW.exe      frxClass        13381  +45 TfrxReport.PrepareReport

..
..
..

stack dump:
0019f494  9c 0a 47 00 de fa ed 0e - 01 00 00 00 07 00 00 00  ..G.............
0019f4a4  a8 f4 19 00 9c 0a 47 00 - 30 93 5e 08 02 01 00 00  ......G.0.^.....
0019f4b4  06 00 4a 08 f8 7f 4e 08 - f4 f4 19 00 c4 f4 19 00  ..J...N.........
0019f4c4  04 f5 19 00 3c b8 40 00 - f4 f4 19 00 f8 7f 4e 08  ....<.@.......N.
0019f4d4  00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00  ................
0019f4e4  2c d7 4f 08 11 03 46 00 - 5c a4 49 08 11 7f 4e 08  ,.O...F.\.I...N.
0019f4f4  28 f5 19 00 e3 0e 47 00 - e4 f5 19 00 cf 49 47 00  (.....G......IG.
0019f504  a4 f5 19 00 3c b8 40 00 - 28 f5 19 00 e4 f5 19 00  ....<.@.(.......
0019f514  00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00  ................
0019f524  00 00 00 00 6c f5 19 00 - a8 4d 47 00 00 00 00 00  ....l....MG.....
0019f534  00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00  ................
0019f544  11 00 00 00 8c f5 19 00 - e4 f5 19 00 d7 81 47 00  ..............G.
0019f554  e4 f5 19 00 06 00 00 00 - ef 33 f7 01 f7 33 f7 01  .........3...3..
0019f564  03 00 00 00 12 74 40 00 - 00 00 00 00 45 84 47 00  .....t@.....E.G.
0019f574  05 00 00 00 06 00 00 00 - 05 00 00 00 90 f6 19 00  ................
0019f584  00 00 00 00 f8 7f 4e 08 - e4 f5 19 00 03 86 47 00  ......N.......G.
0019f594  b8 18 fe 01 b8 18 fe 01 - 90 d4 77 01 a6 84 f6 01  ..........w.....
0019f5a4  b0 f5 19 00 94 b7 40 00 - 90 f6 19 00 bc f5 19 00  ......@.........
0019f5b4  d0 85 f6 01 90 f6 19 00 - 9c f6 19 00 72 86 f6 01  ............r...
0019f5c4  90 f6 19 00 b8 18 fe 01 - b8 18 fe 01 90 d4 77 01  ..............w.

disassembling:
00470a28     public System.Variants.VarCastError: ; function entry point
00470a28 678   push    ebp
00470a29       mov     ebp, esp
00470a2b       add     esp, -$1c
00470a2e       push    ebx
00470a2f       push    esi
00470a30       xor     ecx, ecx
00470a32       mov     [ebp-$14], ecx
00470a35       mov     [ebp-$18], ecx
00470a38       mov     [ebp-$1c], ecx
00470a3b       mov     esi, edx
00470a3d       mov     ebx, eax
00470a3f       xor     eax, eax
00470a41       push    ebp
00470a42       push    $470ab7               ; System.@HandleFinally
00470a47       push    dword ptr fs:[eax]
00470a4a       mov     fs:[eax], esp
00470a4d 679   lea     edx, [ebp-$14]
00470a50       mov     eax, ebx
00470a52       call    +$9119 ($479b70)      ; System.Variants.VarTypeAsText
00470a57       mov     eax, [ebp-$14]
00470a5a       mov     [ebp-$10], eax
00470a5d       mov     byte ptr [ebp-$c], $11
00470a61       lea     edx, [ebp-$18]
00470a64       mov     eax, esi
00470a66       call    +$9105 ($479b70)      ; System.Variants.VarTypeAsText
00470a6b       mov     eax, [ebp-$18]
00470a6e       mov     [ebp-8], eax
00470a71       mov     byte ptr [ebp-4], $11
00470a75       lea     eax, [ebp-$10]
00470a78       push    eax
00470a79       push    1
00470a7b       lea     edx, [ebp-$1c]
00470a7e       mov     eax, [$20b73b4]
00470a83       call    -$5dc00 ($412e88)     ; System.LoadResString
00470a88       mov     ecx, [ebp-$1c]
00470a8b       mov     dl, 1
00470a8d       mov     eax, [$470044]
00470a92       call    -$c99f ($4640f8)      ; System.SysUtils.Exception.CreateFmt
00470a97     > call    -$6513c ($40b960)     ; System.@RaiseExcept
00470a9c 681   xor     eax, eax
00470a9e       pop     edx
00470a9f       pop     ecx
00470aa0       pop     ecx
00470aa1       mov     fs:[eax], edx
00470aa4       push    $470abe
00470aa9       lea     eax, [ebp-$1c]
00470aac       mov     edx, 3
00470ab1       call    -$646f2 ($40c3c4)     ; System.@UStrArrayClr
00470ab6       ret
00470ab7       jmp     -$65300 ($40b7bc)     ; System.@HandleFinally
00470abc       jmp     loc_470aa9
00470abe       pop     esi
00470abf       pop     ebx
00470ac0       mov     esp, ebp
00470ac2       pop     ebp
00470ac3       ret
exception class    : EVariantTypeCastError
exception message  : Could not convert variant of type (String) into type (Double).

..
..
main thread ($30f8):
00470a97 +06f CMW.exe      System.Variants   679   +1 VarCastError
00470ede +01a CMW.exe      System.Variants   748   +3 VarResultCheck
00473be3 +08f CMW.exe      System.Variants  2537   +9 VarToDoubleAsString
00473f09 +1e9 CMW.exe      System.Variants  2612  +30 @VarToDouble
00474118 +008 CMW.exe      System.Variants  2646   +1 @VarToReal
01f68ab1 +205 CMW.exe      frxClass         8933  +22 TfrxCustomMemoView.FormatData
01f685af +51b CMW.exe      frxClass         8900  +85 TfrxCustomMemoView.CalcAndFormat
01f67bdc +5d4 CMW.exe      frxClass         8766  +87 TfrxCustomMemoView.GetData
01782e1c +14c CMW.exe      frxEngine        1830  +33 TfrxEngine.Stretch
0178594b +223 CMW.exe      frxEngine        2796  +58 TfrxEngine.DoShow
01782622 +05a CMW.exe      frxEngine        1638   +8 TfrxEngine.ShowBand
017811de +47a CMW.exe      frxEngine        1226  +84 ShowBandTree
017819d4 +114 CMW.exe      frxEngine        1367  +12 ShowPage
01781cb6 +102 CMW.exe      frxEngine        1418  +27 TfrxEngine.RunPage
0177f219 +0e5 CMW.exe      frxEngine         514  +14 DoPages
0177f276 +026 CMW.exe      frxEngine         523   +3 TfrxEngine.RunReportPages
0177ee9a +1b2 CMW.exe      frxEngine         435  +37 TfrxEngine.Run
01f76baf +1df CMW.exe      frxClass        13381  +45 TfrxReport.PrepareReport

stack dump:
0019f3b4  9c 0a 47 00 de fa ed 0e - 01 00 00 00 07 00 00 00  ..G.............
0019f3c4  c8 f3 19 00 9c 0a 47 00 - 60 fc a5 06 00 01 00 00  ......G.`.......
0019f3d4  05 00 a5 06 b8 18 fe 01 - 14 f4 19 00 e4 f3 19 00  ................
0019f3e4  24 f4 19 00 3c b8 40 00 - 14 f4 19 00 b8 18 fe 01  $...<.@.........
0019f3f4  00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00  ................
0019f404  8c fc a5 06 11 03 46 00 - ec fc a5 06 11 18 fe 01  ......F.........
0019f414  58 f4 19 00 e3 0e 47 00 - f8 e3 4e 08 e8 3b 47 00  X.....G...N..;G.
0019f424  94 f4 19 00 3c b8 40 00 - 58 f4 19 00 f8 e3 4e 08  ....<.@.X.....N.
0019f434  00 00 00 00 85 e2 40 00 - 00 00 00 00 f4 a6 51 00  ......@.......Q.
0019f444  3d ad 40 00 66 a4 40 00 - b8 18 fe 01 b8 87 5d 08  =.@.f.@.......].
0019f454  00 00 00 00 40 f5 19 00 - 0e 3f 47 00 d0 ca 4b 00  ....@....?G...K.
0019f464  01 63 52 00 f7 0a 54 00 - 98 f4 19 00 34 aa 51 00  .cR...T.....4.Q.
0019f474  f8 e3 4e 08 1d 41 47 00 - 00 00 00 00 24 f6 af f7  ..N..AG.....$...
0019f484  e6 09 50 08 90 d4 77 01 - b6 8a f6 01 e4 f4 19 00  ..P...w.........
0019f494  a0 f4 19 00 0c b6 40 00 - 40 f5 19 00 4c f5 19 00  ......@.@...L...
0019f4a4  00 8e f6 01 40 f5 19 00 - b8 18 fe 01 b8 18 fe 01  ....@...........
0019f4b4  90 d4 77 01 00 00 00 00 - 00 00 00 00 00 00 00 00  ..w.............
0019f4c4  00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00  ................
0019f4d4  00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00  ................
0019f4e4  00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00  ................

disassembling:
00470a28     public System.Variants.VarCastError: ; function entry point
00470a28 678   push    ebp
00470a29       mov     ebp, esp
00470a2b       add     esp, -$1c
00470a2e       push    ebx
00470a2f       push    esi
00470a30       xor     ecx, ecx
00470a32       mov     [ebp-$14], ecx
00470a35       mov     [ebp-$18], ecx
00470a38       mov     [ebp-$1c], ecx
00470a3b       mov     esi, edx
00470a3d       mov     ebx, eax
00470a3f       xor     eax, eax
00470a41       push    ebp
00470a42       push    $470ab7               ; System.@HandleFinally
00470a47       push    dword ptr fs:[eax]
00470a4a       mov     fs:[eax], esp
00470a4d 679   lea     edx, [ebp-$14]
00470a50       mov     eax, ebx
00470a52       call    +$9119 ($479b70)      ; System.Variants.VarTypeAsText
00470a57       mov     eax, [ebp-$14]
00470a5a       mov     [ebp-$10], eax
00470a5d       mov     byte ptr [ebp-$c], $11
00470a61       lea     edx, [ebp-$18]
00470a64       mov     eax, esi
00470a66       call    +$9105 ($479b70)      ; System.Variants.VarTypeAsText
00470a6b       mov     eax, [ebp-$18]
00470a6e       mov     [ebp-8], eax
00470a71       mov     byte ptr [ebp-4], $11
00470a75       lea     eax, [ebp-$10]
00470a78       push    eax
00470a79       push    1
00470a7b       lea     edx, [ebp-$1c]
00470a7e       mov     eax, [$20b73b4]
00470a83       call    -$5dc00 ($412e88)     ; System.LoadResString
00470a88       mov     ecx, [ebp-$1c]
00470a8b       mov     dl, 1
00470a8d       mov     eax, [$470044]
00470a92       call    -$c99f ($4640f8)      ; System.SysUtils.Exception.CreateFmt
00470a97     > call    -$6513c ($40b960)     ; System.@RaiseExcept
00470a9c 681   xor     eax, eax
00470a9e       pop     edx
00470a9f       pop     ecx
00470aa0       pop     ecx
00470aa1       mov     fs:[eax], edx
00470aa4       push    $470abe
00470aa9       lea     eax, [ebp-$1c]
00470aac       mov     edx, 3
00470ab1       call    -$646f2 ($40c3c4)     ; System.@UStrArrayClr
00470ab6       ret
00470ab7       jmp     -$65300 ($40b7bc)     ; System.@HandleFinally
00470abc       jmp     loc_470aa9
00470abe       pop     esi
00470abf       pop     ebx
00470ac0       mov     esp, ebp
00470ac2       pop     ebp
00470ac3       ret

I will get a ton of these from 1 single report... everysingle time it runs.... always showing in my logging from session 0.

And always, if I run it manually in the command line prompt my self using the same data/parameters/ect ... not a peep of an issue.

I think it has something to do with Locale / System.VariantManager / VarUtils.VarR8FromStr from some research maybe?

I've got a number of locations that have this issue and not 100% sure what is up.
0

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.