问题描述
场景如下: 我使用 R dotnet 的程序将在以下情况下崩溃:
只有在我的 csv 文件中包含名为“ClientName”的特定列时,它才会崩溃。列值只是字母数字值。
当它崩溃时,它看起来像这样:
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.AccessViolationException
at RDotNet.Expression.TryEvaluate(RDotNet.REnvironment,RDotNet.SymbolicExpression ByRef)
at RDotNet.REngine.Parse(System.String,System.Text.StringBuilder,RDotNet.REnvironment)
at RDotNet.REngine+<Defer>d__63.MoveNext()
at System.Linq.Enumerable.LastOrDefault[[System.__Canon,mscorlib,Version=4.0.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089]](System.Collections.Generic.IEnumerable`1<System.__Canon>)
at RDotNet.REngine.Evaluate(System.String,RDotNet.REnvironment)
失败的命令最终看起来像这样(发送到 REngine.Evaluate 的命令):
library(rpart)
Tree <- rpart(Pass ~ WindowsetNumber
+WSID
+WSDim.OverallFrameWidth
+WSDim.OverallFrameHeight
+WSDim.MeasurementType
+Layout.NumberWide
+ProductType
+Series
+Shape
+BaseProductType
+ProductConfiguration
+UnitType.PanelCount
+UnitType.UnitType
+UnitType.OperationVenting
+UnitType.SwingDirection
+UnitType.ThermalBreak
+UnitType.SillType
+UnitType.ShippingbyWestern
+UnitType.CratingbyWestern
+W0.ratings.UFactor
+W0.ratings.UFactorMetric
+W0.ratings.SHGC
+W0.ratings.CR
+W0.ratings.VT
+ratings.CPD
+ColorMaterialType.FrameColor
+Glass.Glassprovider
+Glass.GlazingType
+Glass.InsulatedLowE
+Glass.Cardinali89
+Glass.GasFilledHighAltitude
+Glass.withNEAT
+Glass.Glasstint
+Glass.Glasspattern
+Glass.SpacerType
+Glass.SpacerColor
+Glass.NFRCUnitGlassthickness
+Glass.NFRCUnitGlassstrength
+Hardware.CoastalStainlessHardwarePackage
+Hardware.BiFoldHardware
+Hardware.HardwareColor
+HiddenQuestions.SpecialOrderrequired
+GrilleApp
+GrilleApp.GrilleBOMExteriorHasGrilles
+GrilleApp.GrilleBOMInteriorHasGrilles
+GrilleApp.GrilleBOMInternalHasGrilles
+GrilleApp.GrilleBOMInternalGlassBased
+GrilleApp.SSL
+GrillePattern
+W0.Dim.FrameWidth
+W0.Dim.FrameHeight
+Glass1.Glass.Glassstrength
+Glass1.Glass.Glassthickness
+Glass2.Glass.Glassstrength
+Glass2.Glass.Glassthickness
+Glass3.Glass.Glassstrength
+Glass3.Glass.Glassthickness
+ClientName
+MarketSegmentID
+WRAP1.PerimeterOptions.PerimeterFrame
+WRAP1.InteriorAccessoryOptions.JambWidth
+WRAP1.BackendQuestions.NumberofReasons
+WRAP1.BackendQuestions.ServiceReasonCode
+WRAP1.BackendQuestions.TouchTimeComponents
+WRAP1.BackendQuestions.TouchTimeServices
+WRAP1.BackendQuestions.LineItemSpecialOrder,data=ErrorData,minsplit=1,minbucket=1,method='class')
gc()
PrunedTree <- prune(Tree,cp=Tree$cptable[which.min(Tree$cptable[,"xerror"]),"CP"])
ErrorData["leafid"] <- PrunedTree$where
post(Tree,file="C:/Safeguard/AnalysisNodeQA/AnalysisNode/output/Error1noprune.ps")
post(PrunedTree,file="C:/Safeguard/AnalysisNodeQA/AnalysisNode/output/Error1.ps")
gc()
%!PS-Adobe-3.0
%%DocumentNeededResources: font Helvetica
%%+ font Helvetica-Bold
%%+ font Helvetica-Oblique
%%+ font Helvetica-Boldoblique
%%+ font Symbol
%%DocumentMedia: letter 612 792 0 () ()
%%Title: R Graphics Output
%%Creator: R Software
%%Pages: (atend)
%%Orientation: Landscape
%%BoundingBox: 18 18 594 774
%%EndComments
%%BeginProlog
/bp { gs sRGB 612.00 0 translate 90 rotate gs } def
% begin .ps.prolog
/gs { gsave } bind def
/gr { grestore } bind def
/ep { showpage gr gr } bind def
/m { moveto } bind def
/l { rlineto } bind def
/np { newpath } bind def
/cp { closepath } bind def
/f { fill } bind def
/o { stroke } bind def
/c { newpath 0 360 arc } bind def
/r { 4 2 roll moveto 1 copy 3 -1 roll exch 0 exch rlineto 0 rlineto -1 mul 0 exch rlineto closepath } bind def
/p1 { stroke } bind def
/p2 { gsave bg fill grestore newpath } bind def
/p3 { gsave bg fill grestore stroke } bind def
/p6 { gsave bg eofill grestore newpath } bind def
/p7 { gsave bg eofill grestore stroke } bind def
/t { 5 -2 roll moveto gsave rotate
1 index stringwidth pop
mul neg 0 rmoveto show grestore } bind def
/ta { 4 -2 roll moveto gsave rotate show } bind def
/tb { 2 -1 roll 0 rmoveto show } bind def
/cl { grestore gsave newpath 3 index 3 index moveto 1 index
4 -1 roll lineto exch 1 index lineto lineto
closepath clip newpath } bind def
/rgb { setrgbcolor } bind def
/s { scalefont setfont } bind def
% end .ps.prolog
/sRGB { [ /CIEBasedABC
<< /DecodeLMN
[ { dup 0.03928 le
{12.92321 div}
{0.055 add 1.055 div 2.4 exp }
ifelse
} bind dup dup
]
/MatrixLMN [0.412457 0.212673 0.019334
0.357576 0.715152 0.119192
0.180437 0.072175 0.950301]
/WhitePoint [0.9505 1.0 1.0890]
>>
] setcolorspace } bind def
/srgb { setcolor } bind def
% begin encoding
/WinAnsiEncoding [
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/space /exclam /quotedbl /numbersign /dollar /percent /ampersand /quoteright
/parenleft /parenright /asterisk /plus /comma /minus /period /slash
/zero /one /two /three /four /five /six /seven
/eight /nine /colon /semicolon /less /equal /greater /question
/at /A /B /C /D /E /F /G
/H /I /J /K /L /M /N /O
/P /Q /R /S /T /U /V /W
/X /Y /Z /bracketleft /backslash /bracketright /asciicircum /underscore
/grave /a /b /c /d /e /f /g
/h /i /j /k /l /m /n /o
/p /q /r /s /t /u /v /w
/x /y /z /braceleft /bar /braceright /asciitilde /.notdef
/Euro /.notdef /quotesinglbase /florin /quotedblbase /ellipsis /dagger /daggerdbl
/circumflex /perthousand /Scaron /guilsinglleft /OE /.notdef /Zcaron /.notdef
/.notdef /quoteleft /quoteright /quotedblleft /quotedblright /bullet /endash /emdash
/tilde /Trademark /scaron /guilsinglright /oe /.notdef /zcaron /Ydieresis
/space /exclamdown /cent /sterling /currency /yen /brokenbar /section
/dieresis /copyright /ordfeminine /guillemotleft /logicalnot /hyphen /registered /macron
/degree /plusminus /twosuperior /threesuperior /acute /mu /paragraph /periodcentered
/cedilla /onesuperior /ordmasculine /guillemotright /onequarter /onehalf /threequarters /questiondown
/Agrave /Aacute /Acircumflex /Atilde /Adieresis /Aring /AE /Ccedilla
/Egrave /Eacute /Ecircumflex /Edieresis /Igrave /Iacute /Icircumflex /Idieresis
/Eth /Ntilde /Ograve /Oacute /Ocircumflex /Otilde /Odieresis /multiply
/Oslash /Ugrave /Uacute /Ucircumflex /Udieresis /Yacute /Thorn /germandbls
/agrave /aacute /acircumflex /atilde /adieresis /aring /ae /ccedilla
/egrave /eacute /ecircumflex /edieresis /igrave /iacute /icircumflex /idieresis
/eth /ntilde /ograve /oacute /ocircumflex /otilde /odieresis /divide
/oslash /ugrave /uac
你可以看到它在崩溃时被切断。
正如我所说,如果我在登录时手动运行 exe,则不会出错。只有当我有一个计划任务作为“系统”用户运行它时,我才能重现它。如果我删除“ClientName”列,它也不会崩溃。
任何有关下一步尝试的建议将不胜感激。 我尝试了许多版本的 R,但目前使用的是最新的 4.0.4(我也尝试过 3.6 和 3.5)并使用 R dotnet 1.9 版。
*编辑好吧,我找到了罪魁祸首。我的“ClientName”列中有一个包含 unicode 字符 8211 的值(EN-Dash)。我仍然不清楚为什么这只是一个问题,如果作为系统用户从计划任务运行。现在我可以强制使用 ascii 字符来解决我的问题,但在某些时候我可能需要包含 unicode 字符,所以我猜这会再次困扰我。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)