Inconsistent behaviour between trace(strtok(...)) and s = strtok(...); trace(s)
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 189
- Forks
- 23
- PR merge metrics
- No merged PRs in 30d
Description
Consider the following:
dtrace -n BEGIN'{ x = "a|b|c|"; trace(x); trace(strtok(x, "|")); trace(strtok(NULL, "|")); trace(strtok(NULL, "|")); trace(strtok(NULL, "|")); exit(0); }'
dtrace: description 'BEGIN' matched 1 probe
dtrace: error on enabled probe ID 2 (ID 1: dtrace:::BEGIN): invalid address (0x0) in action #1
vs
dtrace -n BEGIN'{ x = "a|b|c|"; trace(x); trace(strtok(x, "|")); trace(strtok(NULL, "|")); trace(strtok(NULL, "|")); s = strtok(NULL, "|"); trace(s); exit(0); }'
dtrace: description 'BEGIN' matched 1 probe
CPU ID FUNCTION:NAME
9 1 :BEGIN a|b|c| a b c
In the second case, s is output as the empty string while the first example would indicate that the result of the strtok is NULL.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the two BEGIN probe commands from the issue and compare the direct trace(strtok(...)) results with the value assigned to s. Trace the strtok handling in the DTrace implementation, then verify that both forms represent the final empty result consistently rather than as NULL in one case and an empty string in the other.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100