Skip to content

Fix ziplist length updates on bigendian platforms - #2080

Merged
oranagra merged 1 commit into
redis:unstablefrom
robscary:Issue-2033
Jun 30, 2021
Merged

oranagra merged 1 commit into
redis:unstablefrom
robscary:Issue-2033

Conversation

@robscary

Copy link
Copy Markdown
Contributor

Adds call to intrev16ifbe to ensure ZIPLIST_LENGTH is compared correctly

Adds call to intrev16ifbe to ensure ZIPLIST_LENGTH is compared correctly
@mattsta mattsta changed the title Fix for #2033 Ensure ZIPLIST_LENGTH is compared correctly (Fix for #2033) Oct 21, 2014
@sundb

sundb commented Jun 30, 2021

Copy link
Copy Markdown
Collaborator

ping @oranagra, This is indeed a bug.

@oranagra oranagra linked an issue Jun 30, 2021 that may be closed by this pull request

@oranagra oranagra left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WOW.. this was sitting in plain sight (two adjacent lines) for so many years.
i guess no one is using bigendian.. or at least not with any of the non-string data types that use ziplists.

@oranagra

Copy link
Copy Markdown
Member

actually, the implications on bigendian platforms are just that the ziplist length will be broken. i suppose many (not all) hash and zset commands will still work correctly, and i think list type commands will not be affected at all..

@oranagra oranagra added the release-notes indication that this issue needs to be mentioned in the release notes label Jun 30, 2021
@oranagra oranagra changed the title Ensure ZIPLIST_LENGTH is compared correctly (Fix for #2033) Fix ziplist length updates on bigendian platforms Jun 30, 2021
@oranagra
oranagra merged commit eaa5271 into redis:unstable Jun 30, 2021
@yoav-steinberg

yoav-steinberg commented Jul 1, 2021 •

Copy link
Copy Markdown
Contributor

Looking at the code, I think it would be nicer to make this fix so that ZIPLIST_LENGTH would return the value already converted to little endian. And add a macro named ZIPLIST_SET_LENGTH (which will be used by ZIPLIST_INCR_LENGTH), otherwise we'll end up with similar bugs in the future.
Code like ZIPLIST_LENGTH(zl) = x; is pretty ugly.

I know this is just a cleanup so we can scrap this idea, but it's an easy fix, wdyt?

@oranagra

oranagra commented Jul 1, 2021

Copy link
Copy Markdown
Member

we're gonna scrap ziplist.c soon, so i don't care much about making it pretty or safe for future changes.

This was referenced Jul 21, 2021
oranagra pushed a commit that referenced this pull request Jul 21, 2021
Adds call to intrev16ifbe to ensure ZIPLIST_LENGTH is compared correctly

(cherry picked from commit eaa5271)
(cherry picked from commit 4c18123)
oranagra pushed a commit that referenced this pull request Jul 21, 2021
Adds call to intrev16ifbe to ensure ZIPLIST_LENGTH is compared correctly

(cherry picked from commit eaa5271)
oranagra pushed a commit that referenced this pull request Jul 21, 2021
Adds call to intrev16ifbe to ensure ZIPLIST_LENGTH is compared correctly

(cherry picked from commit eaa5271)
JackieXie168 pushed a commit to JackieXie168/redis that referenced this pull request Sep 8, 2021
Adds call to intrev16ifbe to ensure ZIPLIST_LENGTH is compared correctly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-notes indication that this issue needs to be mentioned in the release notes

Projects

Development

Successfully merging this pull request may close these issues.

A trial problem In branch 3.0 ziplist.c 153 lines ?

4 participants