Skip to content

Conversation

@gaborbernat
Copy link
Contributor

@gaborbernat gaborbernat commented Oct 24, 2025

The tokenDelete() function in main/tokeninfo.c was being called with NULL pointers from the R6 parser error handling code, causing segmentation faults.

The R6 parser in parsers/r-r6class.c had a comment stating tokenDelete accepts NULL"but the function did not actually handle NULL pointers safely.
This occurred when parsing malformed R6 syntax such as:

  • R6::SomethingElse() (wrong function after R6 namespace)
  • R6:: (incomplete namespace reference)
  • R6::R6Clas() (typo in R6Class)

The fix ensures ctags handles malformed R6 syntax gracefully by falling back to parsing assignments as regular global variables instead of crashing. Fixes segmentation fault when processing certain R6Class syntax patterns.

Signed-off-by: Bernát Gábor [email protected]

@gaborbernat gaborbernat force-pushed the master branch 2 times, most recently from 61f7ec3 to 55479cd Compare October 24, 2025 14:51
@gaborbernat gaborbernat changed the title Fix null pointer crash in tokenDelete function R6: Fix null pointer crash in tokenDelete function Oct 24, 2025
@gaborbernat gaborbernat force-pushed the master branch 2 times, most recently from 3f52a47 to e7d47bf Compare October 24, 2025 15:15
@masatake masatake self-requested a review October 24, 2025 15:23
@masatake masatake self-assigned this Oct 24, 2025
@codecov
Copy link

codecov bot commented Oct 24, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.88%. Comparing base (ead1d93) to head (2bfc47b).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4324      +/-   ##
==========================================
- Coverage   86.01%   85.88%   -0.13%     
==========================================
  Files         250      250              
  Lines       64159    62329    -1830     
==========================================
- Hits        55187    53533    -1654     
+ Misses       8972     8796     -176     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@masatake
Copy link
Member

@gaborbernat Thank you. Valgrind says something. I will look into this.

@gaborbernat
Copy link
Contributor Author

🤔 considering I did not touch the allocation surprised how could be any new leaks here 🤔

@masatake
Copy link
Member

Yes! Internal token0 and token1 hide the outer ones.

@masatake
Copy link
Member

CURRENT.tags may be used in debugging. Please don't include the commits.
Could you change the commit header "Fix null pointer crash in tokenDelete function" to "tokeninfo: fix null pointer crash in tokenDelete function"?

Could you change the commit header "Fix valgrind error" to "R6: fix valgrind error"?

The tokenDelete() function in main/tokeninfo.c was being called with NULL
pointers from the R6 parser error handling code, causing segmentation faults.

The R6 parser in parsers/r-r6class.c had a comment stating "tokenDelete
accepts NULL" but the function did not actually handle NULL pointers safely.
This occurred when parsing malformed R6 syntax such as:
- R6::SomethingElse() (wrong function after R6 namespace)
- R6:: (incomplete namespace reference)
- R6::R6Clas() (typo in R6Class)

The fix ensures ctags handles malformed R6 syntax gracefully by falling back
to parsing assignments as regular global variables instead of crashing.

  Fixes segmentation fault when processing certain R6Class syntax patterns.

Signed-off-by: Bernát Gábor <[email protected]>
Signed-off-by: Bernát Gábor <[email protected]>
@gaborbernat
Copy link
Contributor Author

Done 👍 let me know if you'd like anything else.

@gaborbernat
Copy link
Contributor Author

Once this lands, would it be possible to cut a new release? 🤔 This is actively crashing our OpenGrok indexing 😆 and otherwise we'd have to downgrade back to 5.9, but would rather upgrade to 6.3 if possible.

@masatake
Copy link
Member

Once this lands, would it be possible to cut a new release? 🤔 This is actively crashing our OpenGrok indexing 😆 and otherwise we'd have to downgrade back to 5.9, but would rather upgrade to 6.3 if possible.

I will release 6.2.1, which may include the commits in this pull request, 556fc03, 0be19d0, and 33d1d1b.

I will not release 6.3 until #4266, #4267, and #4268 are merged.

@masatake masatake added this to the 6.2.1 milestone Oct 24, 2025
@gaborbernat
Copy link
Contributor Author

6.2.1 is perfect for me, thanks!

@masatake masatake merged commit 11498fd into universal-ctags:master Oct 24, 2025
82 of 83 checks passed
@masatake
Copy link
Member

Thank you. I will work on releasing v6.2.1. It will take a week.

@gaborbernat
Copy link
Contributor Author

Thanks!

@masatake
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants