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

[CRBTreeMap] Segmentation fault at Leetcode #1429 #51

Open
alantudyk opened this issue Oct 15, 2023 · 4 comments · May be fixed by #55
Open

[CRBTreeMap] Segmentation fault at Leetcode #1429 #51

alantudyk opened this issue Oct 15, 2023 · 4 comments · May be fixed by #55

Comments

@alantudyk
Copy link

Only 1 line is different:

OK: https://leetcode.com/submissions/detail/1075862918/

@t.delete p if @t[p]

Not OK: https://leetcode.com/submissions/detail/1075860617/

@t.delete p

@alantudyk alantudyk changed the title [Segmentation fault], Leetcode 1429 [CRBTreeMap, Segmentation fault], Leetcode 1429 Oct 15, 2023
@alantudyk alantudyk changed the title [CRBTreeMap, Segmentation fault], Leetcode 1429 [CRBTreeMap] Segmentation fault at Leetcode #1429 Oct 15, 2023
@GarrisonJ
Copy link
Contributor

I can confirm that deleting a non-existent element causes a segmentation fault sometimes. If you run rspec ten times or so you should see a segmentation fault.

@GarrisonJ
Copy link
Contributor

Causes seg fault with ruby 3.2.2

require 'algorithms'
include Containers

tree = CRBTreeMap.new

tree.push(2, 2)
tree.delete(3)

@GarrisonJ
Copy link
Contributor

A similar issue exists inside RubyRBTreeMap

require 'algorithms'
include Containers

tree = RubyRBTreeMap.new

tree.push(2,2)
tree.delete(3)
`delete_recursive': undefined method `left' for nil:NilClass (NoMethodError)

      if ( !isred(node.right) && !isred(node.right.left) )

@GarrisonJ GarrisonJ linked a pull request Jan 9, 2024 that will close this issue
@GarrisonJ
Copy link
Contributor

I have a fix waiting for a PR review.

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 a pull request may close this issue.

2 participants