ServiceStack / Issues

Issue Tracker for the commercial versions of ServiceStack
11 stars 8 forks source link

Mapping a closed concrete class to a closed interface fails with stack overflow #777

Closed brunomlopes closed 2 years ago

brunomlopes commented 2 years ago

Describe the issue

We are upgrading to ServiceStack 6.1, and our testing has caught a stack overflow when converting from Dictionary<,> to IDictionary<,>

Reproduction

We added a test case on a gist here: https://gist.github.com/brunomlopes/521e0a5a05ad37eb9237542be7656ab2

The issue seems to be around here: https://github.com/ServiceStack/ServiceStack/blob/main/ServiceStack.Text/src/ServiceStack.Text/AutoMappingUtils.cs#L985-L992 , because it checks the target type, but the source instance.

Expected behavior

The convert should succeed and not crash the application

System Info

Using servicestack 6.1.0 on net48

Additional context

No response

Validations

mythz commented 2 years ago

Thanks for the repro, the type checks were failing because it didn't guard against null values, which is now fixed in this commit.

This change is available from the latest v6.1.1 that's now available on MyGet.