Skip to content

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

Closed
amasad opened this issue Mar 31, 2016 · 5 comments · Fixed by docker-library/official-images#1580
Closed

Ruby string::include? bug (only in docker) #77

amasad opened this issue Mar 31, 2016 · 5 comments · Fixed by docker-library/official-images#1580

Comments

@amasad
Copy link

amasad commented Mar 31, 2016

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:

docker run ruby:2.3-alpine ruby -e 'puts "xxxAy".include? "Azzz"'

Here are some more test cases:

"12390".include? "9567"
"xyzab".include? "aklm" 
@yosifkit
Copy link
Member

yosifkit commented Apr 1, 2016

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?

@amasad
Copy link
Author

amasad commented Apr 1, 2016

Also repros in Busybox Ruby package, seems like they share the same library.

docker run amasad/busyruby ruby -e 'puts "xxxAy".include? "Azzz"'

@ncopa
Copy link
Contributor

ncopa commented Apr 1, 2016

This is definitively a bug in musl. Fix is on its way.

ncopa added a commit to alpinelinux/aports that referenced this issue Apr 1, 2016
@andyshinn
Copy link

I'll rebuild images and open library PR shortly.

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.

4 participants