Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix segmentation fault when trying to save invalid long strings #60

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

simon-ess
Copy link
Contributor

@simon-ess simon-ess commented Feb 23, 2024

This can occur if you have something like the following:

record(waveform, "foo") {
  field(FTVL, "CHAR")
  field(NELM, "10")
  info(autosaveFields, "VAL VAL$")
}

The VAL$ field will cause a segmentation fault when it tries to save it to disk. The reason this seems to happen is that on one hand, VAL$ is regarded by autosave as a valid field (it is a field, but with a $ at the end). On the other hand, when connecting a monitor, the connection fails as the VAL field is not of the correcct type as defined in dbChannelCreate from EPICS base.

This means that autosave will try to save the date from an unconnected array, with uninitialised pArray, causing a segmentation fault.

Fixes #59

@anjohnson
Copy link
Member

I'd recommend testing this change against the lsi & lso (long string in/out) record types too, they provide access to the VAL field slightly differently than a waveform record although I doubt the code would need to be any different for them. Using these types instead of a CHAR waveform makes the database designer's intention clearer when they're available (since Base 3.15).

This can occur if you have something like the following:
```
record(waveform, "foo") {
  field(FTVL, "CHAR")
  field(NELM, "10")
  info(autosaveFields, "VAL VAL$")
}
```
The `VAL$` field will cause a segmentation fault when it tries to
save it to disk. The reason this seems to happen is that on one hand,
`VAL$` is regarded by autosave as a valid field (it is a field, but
with a `$` at the end). On the other hand, when connecting a monitor,
the connection fails as the `VAL` field is not of the correcct type
as defined in `dbChannelCreate` from EPICS base.

This means that autosave will try to save the date from an unconnected
array, with uninitialised pArray, causing a segmentation fault.
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.

Segmentation fault when autosaving long string-type fields
2 participants