Skip to content

Fix unsafe fixed buffer pointer handling in F1 telemetry extensions#11

Merged
codegefluester merged 5 commits intofeat/udp-base-sourcefrom
copilot/sub-pr-4
Feb 11, 2026
Merged

Fix unsafe fixed buffer pointer handling in F1 telemetry extensions#11
codegefluester merged 5 commits intofeat/udp-base-sourcefrom
copilot/sub-pr-4

Conversation

Copy link
Contributor

Copilot AI commented Feb 10, 2026

  • Fix fixed buffer casting issues in F1TelemetryFrameExtensions.cs (use proper pointer access)
    • Fix GetPacket() method (use Unsafe.AsPointer with ref to first element)
    • Fix DeserializePacket() method (use Unsafe.AsPointer with ref to first element)
    • Fix GetRawData() method (use Unsafe.AsPointer with ref to first element)
  • Fix UTF-8 marshaling issue in F12025/Participant.cs (use byte array instead of ByValTStr)
    • Add Name property for convenient UTF-8 string access
  • Verify UdpSourceBase.Dispose() implementation is correct (already implemented in previous PR)
  • Run tests to validate changes
  • Code review
  • Fix AccessViolationException reported in testing

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits February 10, 2026 23:04
- Fix F1TelemetryFrameExtensions to use Unsafe.Read<T> and direct pointer access for fixed buffers
- Change F12025 Participant m_name from ByValTStr to byte array for proper UTF-8 marshaling
- UdpSourceBase Dispose() implementation already correct (from previous PR)

Co-authored-by: codegefluester <203914+codegefluester@users.noreply.github.com>
Co-authored-by: codegefluester <203914+codegefluester@users.noreply.github.com>
Copilot AI changed the title [WIP] Add source for F1 games Fix unsafe fixed buffer pointer handling in F1 telemetry extensions Feb 10, 2026
Copilot AI requested a review from codegefluester February 10, 2026 23:06
Use Unsafe.AsPointer(ref frame.RawData[0]) instead of Unsafe.Read to properly get a pointer to the fixed buffer. This resolves both the CS0213 compilation error and the runtime AccessViolationException.

Co-authored-by: codegefluester <203914+codegefluester@users.noreply.github.com>
@codegefluester codegefluester marked this pull request as ready for review February 11, 2026 10:38
@codegefluester codegefluester merged commit 5519f4f into feat/udp-base-source Feb 11, 2026
@codegefluester codegefluester deleted the copilot/sub-pr-4 branch February 11, 2026 10:38
codegefluester added a commit that referenced this pull request Feb 11, 2026
* Added F1 2025 packets

* Added F1 2024 types

* Added F1 2023 structs

* Added F1 packets and fixtures

* Added F1 2025 packets

* Added F1 2024 types

* Added F1 2023 structs

* Added F1 packets and fixtures

* Remove legacy F1 implementation workflow file

* Remove debug tooling for F1

* Add F1 fixture files to test project

* Add refactoring plan for telemetry source interface

* Remove debug logging

* Added test cases for F1 packet parsing (super basic)

* Added tests for event details parsing in F1 2025

* Tested F1 recording and reading of session recording

* Update GamesDat.Demo.Wpf/Resources/Styles.xaml

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Björn Kaiser <masterchiefs2002@hotmail.com>

* Update GamesDat.Demo.Wpf/ViewModels/IRealtimeSource.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Björn Kaiser <masterchiefs2002@hotmail.com>

* [WIP] WIP Address feedback on adding source for F1 games (#5)

* Initial plan

* Fix: Change m_zoneFlag from byte to sbyte in F12025 MarshalZone

Co-authored-by: codegefluester <203914+codegefluester@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: codegefluester <203914+codegefluester@users.noreply.github.com>

* Apply BufferSize to UDP socket ReceiveBufferSize (#6)

* Initial plan

* Apply BufferSize to socket's ReceiveBufferSize property

Co-authored-by: codegefluester <203914+codegefluester@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: codegefluester <203914+codegefluester@users.noreply.github.com>

* Refactor UdpSourceBase to use proper Dispose pattern (#7)

* Initial plan

* Refactor UdpSourceBase to use Dispose pattern instead of manual disposal in finally block

Co-authored-by: codegefluester <203914+codegefluester@users.noreply.github.com>

* Add thread-safety to Dispose method in UdpSourceBase

Co-authored-by: codegefluester <203914+codegefluester@users.noreply.github.com>

* Move base.Dispose() inside lock for better thread-safety

Co-authored-by: codegefluester <203914+codegefluester@users.noreply.github.com>

* Set disposed flag before disposal operations for better exception safety

Co-authored-by: codegefluester <203914+codegefluester@users.noreply.github.com>

* Add try-finally to ensure base.Dispose() is always called

Co-authored-by: codegefluester <203914+codegefluester@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: codegefluester <203914+codegefluester@users.noreply.github.com>

* Make LiveryColour struct fields public for deserialization access (#8)

* Initial plan

* Make LiveryColour fields public to allow access

Co-authored-by: codegefluester <203914+codegefluester@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: codegefluester <203914+codegefluester@users.noreply.github.com>

* Remove unused BytesToStruct method from F1RealtimeTelemetrySource (#9)

* Initial plan

* Remove unused BytesToStruct method from F1RealtimeTelemetrySource

Co-authored-by: codegefluester <203914+codegefluester@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: codegefluester <203914+codegefluester@users.noreply.github.com>

* [WIP] WIP address feedback from review on adding source for F1 games (#10)

* Initial plan

* Remove .claude/settings.local.json files from repository

* Push changes - removed .claude/settings.local.json files

Co-authored-by: codegefluester <203914+codegefluester@users.noreply.github.com>

* Remove .claude/settings.local.json files and update .gitignore pattern

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: codegefluester <203914+codegefluester@users.noreply.github.com>

* Fix unsafe fixed buffer pointer handling in F1 telemetry extensions (#11)

* Initial plan

* Fix unsafe fixed buffer pointer handling and UTF-8 marshaling

- Fix F1TelemetryFrameExtensions to use Unsafe.Read<T> and direct pointer access for fixed buffers
- Change F12025 Participant m_name from ByValTStr to byte array for proper UTF-8 marshaling
- UdpSourceBase Dispose() implementation already correct (from previous PR)

Co-authored-by: codegefluester <203914+codegefluester@users.noreply.github.com>

* Add Name property helper for UTF-8 decoded participant name

Co-authored-by: codegefluester <203914+codegefluester@users.noreply.github.com>

* Fix AccessViolationException in GetPacket by using Unsafe.AsPointer

Use Unsafe.AsPointer(ref frame.RawData[0]) instead of Unsafe.Read to properly get a pointer to the fixed buffer. This resolves both the CS0213 compilation error and the runtime AccessViolationException.

Co-authored-by: codegefluester <203914+codegefluester@users.noreply.github.com>

* Fix frame extension and test

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: codegefluester <203914+codegefluester@users.noreply.github.com>
Co-authored-by: Björn Kaiser <bjoern@codegefluester.de>

---------

Signed-off-by: Björn Kaiser <masterchiefs2002@hotmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants