Skip to content

Read a borrowed const char * return without freeing it - #14

Merged
estebanzimanyi merged 1 commit into
MobilityDB:mainfrom
estebanzimanyi:fix/const-char-return
Sep 2, 2026
Merged

estebanzimanyi merged 1 commit into
MobilityDB:mainfrom
estebanzimanyi:fix/const-char-return

Conversation

@estebanzimanyi

@estebanzimanyi estebanzimanyi commented Sep 2, 2026 •

Copy link
Copy Markdown
Member

The Utf8 string marshaller frees the pointer a char * return hands back.
That is right for a string MEOS mallocs for the caller and fatal for the
const char * it returns out of a static table: temporal_interp answers
with an element of MEOS_INTERPTYPE_NAMES, and freeing that ends the
process — Test host process crashed : free(): invalid pointer. The
eleven functions whose return is const char * — temporal_interp,
temporal_subtype, temporal_basetype_name, meostype_name and their
kin — come back as the pointer itself and are read with
Marshal.PtrToStringUTF8, which copies and frees nothing.

Three tests read an interpolation name: off a linear sequence, off a
discrete one, and off two temporal values in turn. They exercise the native
library, so the test step takes the LD_LIBRARY_PATH of the prefix the
provisioning built, as the smoke step does, and every test class opens a
MEOS session of its own: MEOS keeps the timezone its text I/O goes through
and the error handler per thread, and the test host runs a test on
whichever thread it has free, so a session opened once for the assembly
reaches the thread that opened it and no other.

The Utf8 string marshaller frees the pointer a `char *` return hands back.
That is right for a string MEOS mallocs for the caller and fatal for the
`const char *` it returns out of a static table: `temporal_interp` answers
with an element of `MEOS_INTERPTYPE_NAMES`, and freeing that ends the
process — `Test host process crashed : free(): invalid pointer`. The
eleven functions whose return is `const char *` — `temporal_interp`,
`temporal_subtype`, `temporal_basetype_name`, `meostype_name` and their
kin — come back as the pointer itself and are read with
`Marshal.PtrToStringUTF8`, which copies and frees nothing.

Three tests read an interpolation name: off a linear sequence, off a
discrete one, and off two temporal values in turn. They exercise the native
library, so the test step takes the LD_LIBRARY_PATH of the prefix the
provisioning built, as the smoke step does, and every test class opens a
MEOS session of its own: MEOS keeps the timezone its text I/O goes through
and the error handler per thread, and the test host runs a test on
whichever thread it has free, so a session opened once for the assembly
reaches the thread that opened it and no other.
@estebanzimanyi
estebanzimanyi merged commit 7b79705 into MobilityDB:main Sep 2, 2026
1 check passed
@estebanzimanyi
estebanzimanyi deleted the fix/const-char-return branch September 2, 2026 20:18
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.

1 participant