-
Notifications
You must be signed in to change notification settings - Fork 333
Ruby string::include? bug (only in docker) #77
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
Comments
I made a quick example (in some limited tests, it seems to happen with 4 chars in the second string, if it starts with the second to last letter, and 3 chars if it starts the last letter): $ docker run -it --rm ruby:alpine ruby -e '(1..20).each { |i| str = "*" * i + "An"; print "#{i}: "; puts str.include? "Azzz"}'
1: false
2: false
3: true
4: true
5: true
6: true
7: true
8: true
9: true
10: true
11: true
12: true
13: true
14: true
15: true
16: true
17: true
18: true
19: true
20: true
$ docker run -it --rm ruby ruby -e '(1..20).each { |i| str = "*" * i + "An"; print "#{i}: "; puts str.include? "Azzz"}'
1: false
2: false
3: false
4: false
5: false
6: false
7: false
8: false
9: false
10: false
11: false
12: false
13: false
14: false
15: false
16: false
17: false
18: false
19: false
20: false It seems to be specifically Alpine Linux related and happens in their package of ruby. 😕 $ docker run -it --rm alpine sh
/ # apk add --no-cache ruby
fetch http://dl-cdn.alpinelinux.org/alpine/v3.3/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.3/community/x86_64/APKINDEX.tar.gz
(1/10) Installing ncurses-terminfo-base (6.0-r6)
(2/10) Installing ncurses-terminfo (6.0-r6)
(3/10) Installing ncurses-libs (6.0-r6)
(4/10) Installing libedit (20150325.3.1-r3)
(5/10) Installing libffi (3.2.1-r2)
(6/10) Installing gdbm (1.11-r1)
(7/10) Installing gmp (6.1.0-r0)
(8/10) Installing yaml (0.1.6-r1)
(9/10) Installing ruby-libs (2.2.4-r0)
(10/10) Installing ruby (2.2.4-r0)
Executing busybox-1.24.1-r7.trigger
OK: 26 MiB in 21 packages
/ # ruby -e '(1..20).each { |i| str = "*" * i + "An"; print "#{i}: "; puts str.include? "A
zzz"}'
1: false
2: false
3: true
4: true
5: true
6: true
7: true
8: true
9: true
10: true
11: true
... Maybe @ncopa would know more here? |
Also repros in Busybox Ruby package, seems like they share the same library.
|
This is definitively a bug in musl. Fix is on its way. |
fixes docker-library/ruby#77 (cherry picked from commit 4ad5f40)
I'll rebuild images and open library PR shortly. |
I'm still not certain as to why this is happening but
string::include?
in some cases is returning true where it should be false.To repro just run the following:
Here are some more test cases:
The text was updated successfully, but these errors were encountered: