snehac-miner / redis

Automatically exported from code.google.com/p/redis
0 stars 0 forks source link

Hangs on getting wrong trimmed multibyte strings #117

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Trim utf-8 string with not multi-byte compatible algorithm (for 
example, PHP substr()). 
2. Put it into Redis (we've used lpop).
3. Try to push it.

What is the expected output? What do you see instead?
Expected to get what we've put. Redis hangs instead.

What version of the product are you using? On what operating system?
Redis 1.02, FreeBSD

Please provide any additional information below.

Original issue reported on code.google.com by alexander.makarow on 2 Dec 2009 at 10:58

GoogleCodeExporter commented 8 years ago
Hello,

this sounds very strange, as one of the Redis tests performs binary sets and 
gets. Can 
you please provide an exact string that when set and read back will hang Redis? 
Thanks 
for the report.

Original comment by anti...@gmail.com on 2 Dec 2009 at 11:04

GoogleCodeExporter commented 8 years ago
I'm guessing that PHP reports the length in characters rather than bytes, but 
Redis
needs to know the number of BYTES to store.

Original comment by jzaw...@gmail.com on 2 Dec 2009 at 11:07

GoogleCodeExporter commented 8 years ago
Which library are you using? phpredis passes this test.
<?php
$r = new Redis;
$r->connect('127.0.0.1', 6379);

$str = "快来加入我们的爱马氏社团";
$str = substr($str, 0, 4); 

var_dump($str);

$r->lpush('myList', $str);
if($r->lpop('myList') === $str) {
        echo "no problem\n";
} else {
        echo "error\n";
}
?>
// output:
string(4) "快�"
no problem

Original comment by n.favref...@gmail.com on 3 Dec 2009 at 11:18

GoogleCodeExporter commented 8 years ago
I've used this one: 
http://code.google.com/p/redis-ajax-chat/source/browse/trunk/lib/
Redis_Server.php?spec=svn5&r=5

Original comment by alexander.makarow on 3 Dec 2009 at 11:30

GoogleCodeExporter commented 8 years ago
the old PHP lib is broken, please use Predis or Rediska.

Cheers,
Salvatore

Original comment by anti...@gmail.com on 23 Aug 2010 at 4:09

GoogleCodeExporter commented 8 years ago
@antirez.
As written above, phpredis passes this test just fine. The old PHP lib from 
November didn't work. The project was taken over and has supported binary 
strings for 8 or 9 monhts now. Please stop replying to people that phpredis is 
broken, it is certainly not the case.

Thank you.

Original comment by n.favref...@gmail.com on 25 Aug 2010 at 1:43