facebook / facebook/hhvm

ext_memcached.cpp fails to set compression flags correctly

Open
#8,028 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
18.7k
Forks
3.1k
Avg merge
1h 47m
Merged PRs (30d)
2

Description

### HHVM Version
HipHop VM 3.18.5 (rel)
Compiler: tags/HHVM-3.18.5-0-g61f6a1f9a199c929980408aff866f36a7b4a1515
Repo schema: 514949365dd9d370d84ea5a6db4a3dd3b619e484

### Standalone code, or other way to reproduce the problem
When the HHVM implementation of memcached is compressing a value, it correctly sets the `MEMC_VAL_COMPRESSED` flag, but fails to set the flag that specifies what type of compression is used (either `MEMC_VAL_COMPRESSION_FASTLZ` or `MEMC_VAL_COMPRESSION_ZLIB`). This becomes a problem when a non-HHVM implementation of memcached (like php-memcached) tries to read and decompress the value. It can see that the "compressed" flag is set, but doesn't know what compression type it is, and the read fails with a (misleading) error like:

`Memcached::get(): could not decompress value: unrecognised encryption type`

This HHVM implementation doesn't suffer from this problem because, if it can't determine the compression type, it falls back to decompressing with ZLIB.

I believe the fix is to change line 185 in ext_memcached.cpp from this:

` flags |= MEMC_VAL_COMPRESSED;`

to this:

` flags |= MEMC_VAL_COMPRESSED | MEMC_VAL_COMPRESSION_ZLIB;`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.