Skip to content

Commit

Permalink
Fix NLLanguageRecognizer crash (#6689)
Browse files Browse the repository at this point in the history
The dispose of `nslang` was happening outside of the check if `nslang` is null. This was causing a crash when trying to recognise a string that contains just one number.

Fixes: #6688
  • Loading branch information
sofokli1 authored and mandel-macaque committed Aug 7, 2019
1 parent b517f70 commit 42311ca
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/NaturalLanguage/NLLanguageRecognizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,9 @@ public static NLLanguage GetDominantLanguage (string @string)
{
var nsstring = NSString.CreateNative (@string);
var nslang = _GetDominantLanguage (nsstring);
var lang = NLLanguage.Undetermined;
if (nslang != null)
lang = NLLanguageExtensions.GetValue (nslang);
var lang = NLLanguageExtensions.GetValue (nslang);
nslang?.Dispose ();
NSString.ReleaseNative (nsstring);
nslang.Dispose ();
return lang;
}

Expand Down
11 changes: 11 additions & 0 deletions tests/monotouch-test/NaturalLanguage/NLLanguageRecognizerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,16 @@ public void Process ()
Assert.That (hypo.Count, Is.GreaterThan (0), "GetLanguageHypotheses");
}
}

[Test]
public void HandelNumbers()
{
using (var recognizer = new NLLanguageRecognizer ()) {
Assert.That (recognizer.DominantLanguage, Is.EqualTo (NLLanguage.Unevaluated), "DominantLanguage/Pre-Process");
var text = "2";
recognizer.Process (text);
Assert.That (recognizer.DominantLanguage, Is.EqualTo (NLLanguage.Unevaluated), "DominantLanguage/Post-Process");
}
}
}
}

3 comments on commit 42311ca

@xamarin-release-manager
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥 Device tests completed (Failed) on iOS on Azure DevOps(iOS): Html Report 🔥

Test results

113 tests failed, 0 tests passed.

Failed tests

  • monotouch-test/iOS Unified 64-bits - device/Debug: Crashed
  • framework-test/iOS Unified 64-bits - device/Debug: Crashed
  • interdependent-binding-projects/iOS Unified 64-bits - device/Debug: Crashed
  • fsharp/iOS Unified 64-bits - device/Debug: Crashed
  • dont link/iOS Unified 64-bits - device/Debug: Crashed
  • link all/iOS Unified 64-bits - device/Debug: Crashed
  • link sdk/iOS Unified 64-bits - device/Debug: Crashed
  • mono-native-compat/iOS Unified 64-bits - device/Debug: Crashed
  • mono-native-unified/iOS Unified 64-bits - device/Debug: Crashed
  • [NUnit] Mono BCL tests group 1/iOS Unified 64-bits - device/Debug: Crashed
  • [NUnit] Mono BCL tests group 2/iOS Unified 64-bits - device/Debug: Crashed
  • [xUnit] Mono BCL tests group 3/iOS Unified 64-bits - device/Debug: Crashed
  • [xUnit] Mono BCL tests group 4/iOS Unified 64-bits - device/Debug: Crashed
  • mscorlib/iOS Unified 64-bits - device/Debug: Crashed
  • [xUnit] Mono BCL tests group 6/iOS Unified 64-bits - device/Debug: Crashed
  • monotouch-test/iOS Unified 64-bits - device/AssemblyBuildTarget: dylib (debug): TimedOut
  • monotouch-test/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (debug): Crashed
  • monotouch-test/iOS Unified 64-bits - device/AssemblyBuildTarget: dylib (debug, profiling): Crashed
  • monotouch-test/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (debug, profiling): Crashed
  • monotouch-test/iOS Unified 64-bits - device/Release: Crashed
  • monotouch-test/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (release): Crashed
  • monotouch-test/iOS Unified 64-bits - device/Debug (dynamic registrar): Crashed
  • monotouch-test/iOS Unified 64-bits - device/Release (all optimizations): Crashed
  • monotouch-test/iOS Unified 64-bits - device/Debug (all optimizations): Crashed
  • monotouch-test/iOS Unified 64-bits - device/Debug: SGenConc: Crashed
  • monotouch-test/iOS Unified 64-bits - device/Debug (interpreter): TimedOut
  • monotouch-test/iOS Unified 64-bits - device/Debug (interpreter -mscorlib): Crashed
  • monotouch-test/iOS Unified 64-bits - device/Release (interpreter -mscorlib): TimedOut
  • framework-test/iOS Unified 64-bits - device/AssemblyBuildTarget: dylib (debug): Crashed
  • framework-test/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (debug): Crashed
  • framework-test/iOS Unified 64-bits - device/AssemblyBuildTarget: dylib (debug, profiling): Crashed
  • framework-test/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (debug, profiling): Crashed
  • framework-test/iOS Unified 64-bits - device/Release: Crashed
  • framework-test/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (release): Crashed
  • interdependent-binding-projects/iOS Unified 64-bits - device/AssemblyBuildTarget: dylib (debug): Crashed
  • interdependent-binding-projects/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (debug): Crashed
  • interdependent-binding-projects/iOS Unified 64-bits - device/AssemblyBuildTarget: dylib (debug, profiling): Crashed
  • interdependent-binding-projects/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (debug, profiling): Crashed
  • interdependent-binding-projects/iOS Unified 64-bits - device/Release: Crashed
  • interdependent-binding-projects/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (release): Crashed
  • fsharp/iOS Unified 64-bits - device/AssemblyBuildTarget: dylib (debug): Crashed
  • fsharp/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (debug): Crashed
  • fsharp/iOS Unified 64-bits - device/AssemblyBuildTarget: dylib (debug, profiling): Crashed
  • fsharp/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (debug, profiling): Crashed
  • fsharp/iOS Unified 64-bits - device/Release: Crashed
  • fsharp/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (release): Crashed
  • dont link/iOS Unified 64-bits - device/AssemblyBuildTarget: dylib (debug): Crashed
  • dont link/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (debug): Crashed
  • dont link/iOS Unified 64-bits - device/AssemblyBuildTarget: dylib (debug, profiling): Crashed
  • dont link/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (debug, profiling): Crashed
  • dont link/iOS Unified 64-bits - device/Release: Crashed
  • dont link/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (release): Crashed
  • link all/iOS Unified 64-bits - device/AssemblyBuildTarget: dylib (debug): Crashed
  • link all/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (debug): Crashed
  • link all/iOS Unified 64-bits - device/AssemblyBuildTarget: dylib (debug, profiling): Crashed
  • link all/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (debug, profiling): Crashed
  • link all/iOS Unified 64-bits - device/Release: Crashed
  • link all/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (release): Crashed
  • link sdk/iOS Unified 64-bits - device/AssemblyBuildTarget: dylib (debug): Crashed
  • link sdk/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (debug): Crashed
  • link sdk/iOS Unified 64-bits - device/AssemblyBuildTarget: dylib (debug, profiling): Crashed
  • link sdk/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (debug, profiling): Crashed
  • link sdk/iOS Unified 64-bits - device/Release: Crashed
  • link sdk/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (release): Crashed
  • mono-native-compat/iOS Unified 64-bits - device/AssemblyBuildTarget: dylib (debug): Crashed
  • mono-native-compat/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (debug): Crashed
  • mono-native-compat/iOS Unified 64-bits - device/AssemblyBuildTarget: dylib (debug, profiling): Crashed
  • mono-native-compat/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (debug, profiling): Crashed
  • mono-native-compat/iOS Unified 64-bits - device/Release: Crashed
  • mono-native-compat/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (release): Crashed
  • mono-native-unified/iOS Unified 64-bits - device/AssemblyBuildTarget: dylib (debug): Crashed
  • mono-native-unified/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (debug): Crashed
  • mono-native-unified/iOS Unified 64-bits - device/AssemblyBuildTarget: dylib (debug, profiling): Crashed
  • mono-native-unified/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (debug, profiling): Crashed
  • mono-native-unified/iOS Unified 64-bits - device/Release: Crashed
  • mono-native-unified/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (release): Crashed
  • [NUnit] Mono BCL tests group 1/iOS Unified 64-bits - device/AssemblyBuildTarget: dylib (debug): Crashed
  • [NUnit] Mono BCL tests group 1/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (debug): Crashed
  • [NUnit] Mono BCL tests group 1/iOS Unified 64-bits - device/AssemblyBuildTarget: dylib (debug, profiling): Crashed
  • [NUnit] Mono BCL tests group 1/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (debug, profiling): Crashed
  • [NUnit] Mono BCL tests group 1/iOS Unified 64-bits - device/Release: Crashed
  • [NUnit] Mono BCL tests group 1/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (release): Crashed
  • [NUnit] Mono BCL tests group 2/iOS Unified 64-bits - device/AssemblyBuildTarget: dylib (debug): Crashed
  • [NUnit] Mono BCL tests group 2/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (debug): Crashed
  • [NUnit] Mono BCL tests group 2/iOS Unified 64-bits - device/AssemblyBuildTarget: dylib (debug, profiling): Crashed
  • [NUnit] Mono BCL tests group 2/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (debug, profiling): Crashed
  • [NUnit] Mono BCL tests group 2/iOS Unified 64-bits - device/Release: Crashed
  • [NUnit] Mono BCL tests group 2/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (release): Crashed
  • [xUnit] Mono BCL tests group 3/iOS Unified 64-bits - device/AssemblyBuildTarget: dylib (debug): Crashed
  • [xUnit] Mono BCL tests group 3/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (debug): Crashed
  • [xUnit] Mono BCL tests group 3/iOS Unified 64-bits - device/AssemblyBuildTarget: dylib (debug, profiling): Crashed
  • [xUnit] Mono BCL tests group 3/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (debug, profiling): Crashed
  • [xUnit] Mono BCL tests group 3/iOS Unified 64-bits - device/Release: Crashed
  • [xUnit] Mono BCL tests group 3/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (release): Crashed
  • [xUnit] Mono BCL tests group 4/iOS Unified 64-bits - device/AssemblyBuildTarget: dylib (debug): Crashed
  • [xUnit] Mono BCL tests group 4/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (debug): Crashed
  • [xUnit] Mono BCL tests group 4/iOS Unified 64-bits - device/AssemblyBuildTarget: dylib (debug, profiling): Crashed
  • [xUnit] Mono BCL tests group 4/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (debug, profiling): Crashed
  • [xUnit] Mono BCL tests group 4/iOS Unified 64-bits - device/Release: Crashed
  • [xUnit] Mono BCL tests group 4/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (release): Crashed
  • mscorlib/iOS Unified 64-bits - device/AssemblyBuildTarget: dylib (debug): Crashed
  • mscorlib/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (debug): Crashed
  • mscorlib/iOS Unified 64-bits - device/AssemblyBuildTarget: dylib (debug, profiling): Crashed
  • mscorlib/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (debug, profiling): Crashed
  • mscorlib/iOS Unified 64-bits - device/Release: Crashed
  • mscorlib/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (release): Crashed
  • mscorlib/iOS Unified 64-bits - device/Debug: SGenConc: Crashed
  • [xUnit] Mono BCL tests group 6/iOS Unified 64-bits - device/AssemblyBuildTarget: dylib (debug): Crashed
  • [xUnit] Mono BCL tests group 6/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (debug): Crashed
  • [xUnit] Mono BCL tests group 6/iOS Unified 64-bits - device/AssemblyBuildTarget: dylib (debug, profiling): Crashed
  • [xUnit] Mono BCL tests group 6/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (debug, profiling): Crashed
  • [xUnit] Mono BCL tests group 6/iOS Unified 64-bits - device/Release: Crashed
  • [xUnit] Mono BCL tests group 6/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (release): Crashed

@xamarin-release-manager
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Build was (probably) aborted

🔥 Jenkins job (on internal Jenkins) failed in stage(s) 'Test run, Test run' 🔥

Build succeeded
✅ Packages: xamarin.ios-12.15.0.286.pkg xamarin.mac-5.15.0.286.pkg
API Diff (from stable)
API Diff (from PR only) (no change)
Generator Diff (no change)
🔥 Test run failed 🔥

Test results

3 tests failed, 168 tests passed.

Failed tests

  • monotouch-test/watchOS 32-bits - simulator/Debug: Crashed
  • [NUnit] Mono SystemWebServicesTests/watchOS 32-bits - simulator/Debug: Crashed
  • introspection/watchOS 32-bits - simulator/Debug (watchOS 2.0): Crashed

@xamarin-release-manager
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥 Device tests completed (Canceled) on TvOS on Azure DevOps(TvOS): Html Report 🔥

Test results

# Test run in progress: Building: 1, Running: 1, RunQueued: 90, Succeeded: 14, Ignored: 946, TimedOut: 7

Failed tests

  • monotouch-test/tvOS - device/Debug: TimedOut
  • monotouch-test/tvOS - device/AssemblyBuildTarget: dylib (debug): TimedOut
  • monotouch-test/tvOS - device/AssemblyBuildTarget: SDK framework (debug): TimedOut
  • monotouch-test/tvOS - device/AssemblyBuildTarget: dylib (debug, profiling): TimedOut
  • [xUnit] Mono BCL tests group 3/tvOS - device/AssemblyBuildTarget: SDK framework (debug): TimedOut
  • mscorlib/tvOS - device/Release: TimedOut
  • mscorlib/tvOS - device/Debug: SGenConc: TimedOut

Please sign in to comment.