Skip to content

[AI Refactoring] Location.Timestamp internal setter 자기 자신 재귀 호출 → StackOverflowException 잠복 결함 [Scope: src/Tizen.Location] (2026-07-12) #7749

Description

@JoonghyunCho

[Type: Refactoring]
[Scope: src/Tizen.Location]
[Priority: 🟡 Improvement]
[Lens: Coding Guidelines, Clean Code]

Observation

The Location.Timestamp property setter assigns to itself, producing unbounded recursion (src/Tizen.Location/Tizen.Location/Location.cs:188-199):

public DateTime Timestamp
{
    get
    {
        return Interop.ConvertDateTime(_timestamp);
    }
    internal set
    {
        Timestamp = value;   // ← recurses into this same setter, not the backing field
    }
}

The backing field is internal int _timestamp; (Unix seconds). The setter was clearly intended to write _timestamp, but instead re-enters itself.

Problem

  • Latent StackOverflowException (bug risk). Any invocation of this setter recurses forever and terminates the process — StackOverflowException cannot be caught in .NET.
  • Reachability. The setter is internal set; rg finds 0 current call sites within the assembly, so it is not triggered today. It is nonetheless a live correctness landmine: any future internal caller (or a mistaken Timestamp = ... inside a location callback) would hard-crash the process with no catchable exception. This is exactly the kind of defect that is cheap to fix now and expensive to diagnose later (uncatchable crash, no stack).

Proposed Improvement

Assign the backing field with the correct DateTime → Unix-seconds conversion (mirror of the getter's ConvertDateTime). Alternatively, if the internal setter is genuinely never needed, remove it entirely — the public getter is unaffected either way.

Before

internal set
{
    Timestamp = value;
}

After (fix)

internal set
{
    _timestamp = (int)(value.ToUniversalTime() - DateTime.UnixEpoch).TotalSeconds;
}

After (alternative — remove unused setter)

public DateTime Timestamp
{
    get
    {
        return Interop.ConvertDateTime(_timestamp);
    }
}

Target Files

  • src/Tizen.Location/Tizen.Location/Location.cs

Expected Impact (Quantitative Metrics)

  • Process-terminating recursion paths in Location.Timestamp: 1 → 0.
  • Cyclomatic/behavioral correctness: the setter now performs a real, O(1) field assignment (or is removed).

API Compatibility Check

  • Public API signature change: none — the setter accessibility is internal, so it is not part of the public surface; the public get is unchanged.
  • Behavior change: the (currently unreachable) setter changes from "infinite recursion / crash" to "correct field assignment" (or removal). No observable change for any existing caller, since there are none.
  • Tizen API Level floor: maintained (DateTime.UnixEpoch available since .NET Standard 2.1 / .NET Core 2.1; substitute new DateTime(1970,1,1,0,0,0,DateTimeKind.Utc) if an older floor must be honored).

Impact Scope

  • 1 internal setter, single assembly. Measured via rg: 0 call sites (.Timestamp = appears nowhere in src/Tizen.Location).
  • No cross-assembly impact.

Auto-generated by the TizenFX AI refactoring discovery pipeline (scan date 2026-07-12).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions