Skip to content

fix: Prevent a crash when track is called with nil data - #130

Merged
kinyoklion merged 1 commit into
mainfrom
rlamb/track-nil-data
Nov 4, 2026
Merged

kinyoklion merged 1 commit into
mainfrom
rlamb/track-nil-data

Conversation

@kinyoklion

@kinyoklion kinyoklion commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Summary

client:track(key, context, nil) and client:track(key, context, nil, metric) passed a NULL value to the C++ SDK, which dereferences it, so the process crashed. Without data or a metric, track now sends a custom event with no data field (track(key, context) used to send "data": null). A metric without data sends JSON null as the data, as the C API recommends.

Tested with new testTrack and testTrackWithNilData cases on LuaJIT: they segfault on the old binding and pass with this change.

Opened from termag


Note

Overview
Fixes a segfault when client:track is called with nil data (with or without a metric), which previously forwarded a NULL LDValue into the C++ SDK.

The Lua track binding now routes by what was passed: metric-only calls use TrackMetric with JSON null when data is omitted; data-only calls use TrackData; key + context only use TrackEvent so the payload has no data field (instead of "data": null). Docs note that nil data can be used to send a metric without custom data.

Adds testTrack and testTrackWithNilData covering these call shapes.

Reviewed by Cursor Bugbot for commit 06991d8. Bugbot is set up for automated code reviews on this repo. Configure here.

@kinyoklion
kinyoklion marked this pull request as ready for review October 30, 2026 23:07
@kinyoklion
kinyoklion requested a review from a team as a code owner October 30, 2026 23:08
@kinyoklion
kinyoklion merged commit fa3e0d8 into main Nov 4, 2026
20 checks passed
@kinyoklion
kinyoklion deleted the rlamb/track-nil-data branch November 4, 2026 21:14
kinyoklion pushed a commit that referenced this pull request Nov 20, 2026
🤖 I have created a release *beep* *boop*
---


##
[2.2.1](v2.2.0...v2.2.1)
(2026-11-19)


### Bug Fixes

* Prevent a crash when track is called with nil data
([#130](#130))
([fa3e0d8](fa3e0d8))
* Require C++ server SDK 3.15.0 so that track sends metric values
correctly
([#132](#132))
([7bbc9cc](7bbc9cc))
* Require C++ server SDK 3.15.2 so that wrong-type evaluations record
the default value in events
([#134](#134))
([3043105](3043105))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Overview**
> Cuts **patch release 2.2.1** by sweeping version references from
**2.2.0** through release tooling: `release-please` manifest,
`CHANGELOG`, LuaRocks rockspecs (base + Redis) with `v2.2.1` source
tags, `SDKVersion` in `launchdarkly-server-sdk.c`, helper scripts,
README `luarocks make` examples, and example Docker `ARG VERSION`
values.
> 
> No new functional code appears in this diff; **2.2.1** is documented
as fixing a **`track` crash when `data` is nil**, correct **metric**
behavior via C++ server SDK **3.15.0+**, and **wrong-type evaluation
events** recording defaults via C++ **3.15.2+** (those fixes ship in
commits referenced by the changelog).
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
7a54ce2. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: LaunchDarklyReleaseBot <LaunchDarklyReleaseBot@launchdarkly.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