Skip to content

[clr-ios] DataContractSerializerTests.DCS_DeeplyLinkedData crashes with StackOverflowException on CoreCLR #127463

@kotlarmilos

Description

@kotlarmilos

Description

DataContractSerializerTests.DCS_DeeplyLinkedData crashes with System.StackOverflowException when run on Apple mobile platforms under CoreCLR. This is the only failure in System.Runtime.Serialization.Xml.Tests on these platforms, the surrounding ~70 tests pass.

It could happen that the smaller default thread stack on Apple mobile is exhausted before the chain finishes serializing, but not confirmed yet.

Reproduction

Configuration: iossimulator-arm64, Release, RuntimeFlavor=CoreCLR, EnableAggressiveTrimming=true (matches the iossimulator-CoreCLR smoke job).

./build.sh clr+libs+host -os iossimulator -arch arm64 -c Release \
  /p:UseMonoRuntime=false /p:UseNativeAOTRuntime=false

./dotnet.sh build /t:Test \
  /p:TargetOS=iossimulator /p:TargetArchitecture=arm64 /p:Configuration=Release \
  /p:UseMonoRuntime=false /p:UseNativeAOTRuntime=false \
  /p:EnableAggressiveTrimming=true \
  src/libraries/System.Runtime.Serialization.Xml/tests/System.Runtime.Serialization.Xml.Tests.csproj

XHarness reports APP_CRASH (exit 80).

Stack trace (from XHarness app log)

Stack overflow.
Repeated 301 times:
--------------------------------
   at DynamicClass.WriteTypeWithLinkedPropertyToXml(System.Runtime.Serialization.XmlWriterDelegator, System.Object, System.Runtime.Serialization.XmlObjectSerializerWriteContext, System.Runtime.Serialization.ClassDataContract)
   at System.Runtime.Serialization.XmlObjectSerializerWriteContext.InternalSerializeReference(System.Runtime.Serialization.XmlWriterDelegator, System.Object, Boolean, Boolean, Int32, System.Runtime.Serialization.RuntimeTypeHandle)
--------------------------------
   at System.Runtime.Serialization.DataContractSerializer.InternalWriteObjectContent(System.Runtime.Serialization.XmlWriterDelegator, System.Object, System.Runtime.Serialization.DataContractResolver)
   at System.Runtime.Serialization.DataContractSerializer.InternalWriteObject(System.Runtime.Serialization.XmlWriterDelegator, System.Object, System.Runtime.Serialization.DataContractResolver)
   at System.Runtime.Serialization.XmlObjectSerializer.WriteObjectHandleExceptions(System.Runtime.Serialization.XmlWriterDelegator, System.Object, System.Runtime.Serialization.DataContractResolver)
   at System.Runtime.Serialization.XmlObjectSerializer.WriteObject(System.IO.Stream, System.Object)
   at DataContractSerializerTests.DCS_DeeplyLinkedData()

The recursive cycle (WriteTypeWithLinkedPropertyToXml <-> InternalSerializeReference) terminates after ~300 frames in this environment, before the chain is fully written.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions