Skip to content

Conversation

@Jan-E
Copy link

@Jan-E Jan-E commented Jul 6, 2015

No description provided.

@Jan-E
Copy link
Author

Jan-E commented Jul 6, 2015

On Debian I still got a segfault. Might be a sign mismatch. See https://bugs.php.net/bug.php?id=69403 with the same error message:

Program received signal SIGSEGV, Segmentation fault.
__memcpy_sse2_unaligned ()
    at ../sysdeps/x86_64/multiarch/memcpy-sse2-unaligned.S:157
157     ../sysdeps/x86_64/multiarch/memcpy-sse2-unaligned.S: No such file or directory.
(gdb) bt
#0  __memcpy_sse2_unaligned ()
    at ../sysdeps/x86_64/multiarch/memcpy-sse2-unaligned.S:157
#1  0x00007fffecf12ff1 in smart_str_appendl_ex (dest=0x7fffffffa980,
    str=0x7fff00000000 <error: Cannot access memory at address 0x7fff00000000>,
len=12, persistent=0 '\000')
    at /usr/local/php70-debug/include/php/Zend/zend_smart_str.h:90
#2  0x00007fffecf14d45 in redis_cmd_format_static (ret=0x7fffffffaad0,
    keyword=0x7fffecf46ab3 "INFO", format=0x7fffecf46ab1 "s")
    at /usr/local/src/redis/library.c:650
#3  0x00007fffeceec262 in zim_Redis_info (execute_data=0x7fffed814200,
    return_value=0x7fffed814170) at /usr/local/src/redis/redis.c:1729
#4  0x0000000000ab0071 in ZEND_DO_FCALL_SPEC_HANDLER ()
    at /home/vagrant/php-src/Zend/zend_vm_execute.h:836
#5  0x0000000000aaef07 in execute_ex (ex=0x7fffed814030)
    at /home/vagrant/php-src/Zend/zend_vm_execute.h:405
#6  0x0000000000aaf01c in zend_execute (op_array=0x7fffed87f000,
    return_value=0x0) at /home/vagrant/php-src/Zend/zend_vm_execute.h:449
#7  0x0000000000a54bd1 in zend_execute_scripts (type=8, retval=0x0,
    file_count=3) at /home/vagrant/php-src/Zend/zend.c:1390
#8  0x00000000009c6ea2 in php_execute_script (primary_file=0x7fffffffe2f0)
    at /home/vagrant/php-src/main/main.c:2475
#9  0x0000000000b1419e in do_cli (argc=2, argv=0x1497560)
    at /home/vagrant/php-src/sapi/cli/php_cli.c:971
#10 0x0000000000b15149 in main (argc=2, argv=0x1497560)
    at /home/vagrant/php-src/sapi/cli/php_cli.c:1338
(gdb) quit
vagrant@php7dev:/usr/local/src/redis$ cat /vagrant/redis.php
<?php
ini_set('display_errors','On');
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
$count = $redis->dbSize();
echo "Redis has $count keys\n<pre>";
var_dump($redis->info()); /* standard redis INFO command */

@Jan-E
Copy link
Author

Jan-E commented Jul 6, 2015

It did not build on Debian without the change in library.h (conflicting types), but the error messages were abundant while building:

/usr/local/src/redis/redis.c: In function ‘send_discard_static’:
/usr/local/src/redis/redis.c:397:48: warning: passing argument 2 of ‘redis_sock_read’ from incompatible pointer type
             (resp = redis_sock_read(redis_sock,&resp_len TSRMLS_CC)) != NULL) 
                                                ^
In file included from /usr/local/src/redis/redis_commands.h:5:0,
                 from /usr/local/src/redis/redis.c:31:
/usr/local/src/redis/library.h:17:22: note: expected ‘size_t *’ but argument is of type ‘int *’
 PHP_REDIS_API char * redis_sock_read(RedisSock *redis_sock, size_t *buf_len TSRMLS_DC);
                      ^
/usr/local/src/redis/redis.c: In function ‘zim_Redis_multi’:
/usr/local/src/redis/redis.c:2219:53: warning: passing argument 2 of ‘redis_sock_read’ from incompatible pointer type
         if ((response = redis_sock_read(redis_sock, &response_len TSRMLS_CC)) 
                                                     ^
In file included from /usr/local/src/redis/redis_commands.h:5:0,
                 from /usr/local/src/redis/redis.c:31:
/usr/local/src/redis/library.h:17:22: note: expected ‘size_t *’ but argument is of type ‘int *’
 PHP_REDIS_API char * redis_sock_read(RedisSock *redis_sock, size_t *buf_len TSRMLS_DC);
                      ^
/usr/local/src/redis/redis.c: In function ‘redis_response_enqueued’:
/usr/local/src/redis/redis.c:2430:45: warning: passing argument 2 of ‘redis_sock_read’ from incompatible pointer type
     if ((resp = redis_sock_read(redis_sock, &resp_len TSRMLS_CC)) == NULL) {
                                             ^
In file included from /usr/local/src/redis/redis_commands.h:5:0,
                 from /usr/local/src/redis/redis.c:31:
/usr/local/src/redis/library.h:17:22: note: expected ‘size_t *’ but argument is of type ‘int *’
 PHP_REDIS_API char * redis_sock_read(RedisSock *redis_sock, size_t *buf_len TSRMLS_DC);
                      ^
/usr/local/src/redis/redis_commands.c: In function ‘redis_key_cmd’:
/usr/local/src/redis/redis_commands.c:337:51: warning: passing argument 3 of ‘redis_key_prefix’ from incompatible pointer type
     key_free = redis_key_prefix(redis_sock, &key, &key_len);
                                                   ^
In file included from /usr/local/src/redis/redis_commands.h:5:0,
                 from /usr/local/src/redis/redis_commands.c:21:
/usr/local/src/redis/library.h:65:1: note: expected ‘int *’ but argument is of type ‘size_t *’
 redis_key_prefix(RedisSock *redis_sock, char **key, int *key_len);
 ^
/usr/local/src/redis/redis_commands.c: In function ‘redis_key_dbl_cmd’:
/usr/local/src/redis/redis_commands.c:367:51: warning: passing argument 3 of ‘redis_key_prefix’ from incompatible pointer type
     key_free = redis_key_prefix(redis_sock, &key, &key_len);
                                                   ^
In file included from /usr/local/src/redis/redis_commands.h:5:0,
                 from /usr/local/src/redis/redis_commands.c:21:
/usr/local/src/redis/library.h:65:1: note: expected ‘int *’ but argument is of type ‘size_t *’
 redis_key_prefix(RedisSock *redis_sock, char **key, int *key_len);
 ^
/usr/local/src/redis/redis_commands.c: In function ‘redis_set_cmd’:
/usr/local/src/redis/redis_commands.c:1100:51: warning: passing argument 3 of ‘redis_key_prefix’ from incompatible pointer type
     key_free = redis_key_prefix(redis_sock, &key, &key_len);
                                                   ^
In file included from /usr/local/src/redis/redis_commands.h:5:0,
                 from /usr/local/src/redis/redis_commands.c:21:
/usr/local/src/redis/library.h:65:1: note: expected ‘int *’ but argument is of type ‘size_t *’
 redis_key_prefix(RedisSock *redis_sock, char **key, int *key_len);
 ^
/usr/local/src/redis/redis_commands.c: In function ‘redis_atomic_increment’:
/usr/local/src/redis/redis_commands.c:1230:51: warning: passing argument 3 of ‘redis_key_prefix’ from incompatible pointer type
     key_free = redis_key_prefix(redis_sock, &key, &key_len);
                                                   ^
In file included from /usr/local/src/redis/redis_commands.h:5:0,
                 from /usr/local/src/redis/redis_commands.c:21:
/usr/local/src/redis/library.h:65:1: note: expected ‘int *’ but argument is of type ‘size_t *’
 redis_key_prefix(RedisSock *redis_sock, char **key, int *key_len);
 ^
/usr/local/src/redis/library.c: In function ‘reselect_db’:
/usr/local/src/redis/library.c:59:49: warning: passing argument 2 of ‘redis_sock_read’ from incompatible pointer type
     if ((response = redis_sock_read(redis_sock, &response_len TSRMLS_CC)) == NULL) {
                                                 ^
In file included from /usr/local/src/redis/library.c:19:0:
/usr/local/src/redis/library.h:17:22: note: expected ‘size_t *’ but argument is of type ‘int *’
 PHP_REDIS_API char * redis_sock_read(RedisSock *redis_sock, size_t *buf_len TSRMLS_DC);
                      ^
/usr/local/src/redis/library.c: In function ‘resend_auth’:
/usr/local/src/redis/library.c:87:44: warning: passing argument 2 of ‘redis_sock_read’ from incompatible pointer type
     response = redis_sock_read(redis_sock, &response_len TSRMLS_CC);
                                            ^
In file included from /usr/local/src/redis/library.c:19:0:
/usr/local/src/redis/library.h:17:22: note: expected ‘size_t *’ but argument is of type ‘int *’
 PHP_REDIS_API char * redis_sock_read(RedisSock *redis_sock, size_t *buf_len TSRMLS_DC);
                      ^
/usr/local/src/redis/library.c: In function ‘redis_client_list_reply’:
/usr/local/src/redis/library.c:1017:45: warning: passing argument 2 of ‘redis_sock_read’ from incompatible pointer type
     if ((resp = redis_sock_read(redis_sock, &resp_len TSRMLS_CC)) == NULL) {
                                             ^
/usr/local/src/redis/library.c:496:21: note: expected ‘size_t *’ but argument is of type ‘int *’
 PHP_REDIS_API char *redis_sock_read(RedisSock *redis_sock, size_t *buf_len TSRMLS_DC)
                     ^
/usr/local/src/redis/library.c: In function ‘redis_mbulk_reply_loop’:
/usr/local/src/redis/library.c:1829:44: warning: passing argument 2 of ‘redis_sock_read’ from incompatible pointer type
         line = redis_sock_read(redis_sock, &len TSRMLS_CC);
                                            ^
/usr/local/src/redis/library.c:496:21: note: expected ‘size_t *’ but argument is of type ‘int *’
 PHP_REDIS_API char *redis_sock_read(RedisSock *redis_sock, size_t *buf_len TSRMLS_DC)
                     ^
/usr/local/src/redis/library.c: In function ‘redis_serialize’:
/usr/local/src/redis/library.c:2006:28: warning: passing argument 1 of ‘zend_string_init’ from incompatible pointer type
    *val = zend_string_init(sstr.s,(*val)->len, 0);
                            ^
In file included from /usr/local/php70-debug/include/php/Zend/zend.h:35:0,
                 from /usr/local/php70-debug/include/php/main/php.h:35,
                 from /usr/local/src/redis/common.h:1,
                 from /usr/local/src/redis/library.c:4:
/usr/local/php70-debug/include/php/Zend/zend_string.h:155:40: note: expected ‘const char *’ but argument is of type ‘struct zend_string *’
 static zend_always_inline zend_string *zend_string_init(const char *str, size_t len, int persistent)
                                        ^
/usr/local/src/redis/redis_session.c: In function ‘redis_pool_member_auth’:
/usr/local/src/redis/redis_session.c:129:53: warning: passing argument 2 of ‘redis_sock_read’ from incompatible pointer type
         if ((response = redis_sock_read(redis_sock, &response_len TSRMLS_CC))) {
                                                     ^
In file included from /usr/local/src/redis/redis_session.c:36:0:
/usr/local/src/redis/library.h:17:22: note: expected ‘size_t *’ but argument is of type ‘int *’
 PHP_REDIS_API char * redis_sock_read(RedisSock *redis_sock, size_t *buf_len TSRMLS_DC);
                      ^
/usr/local/src/redis/redis_session.c: In function ‘redis_pool_member_select’:
/usr/local/src/redis/redis_session.c:145:53: warning: passing argument 2 of ‘redis_sock_read’ from incompatible pointer type
         if ((response = redis_sock_read(redis_sock, &response_len TSRMLS_CC))) {
                                                     ^
In file included from /usr/local/src/redis/redis_session.c:36:0:
/usr/local/src/redis/library.h:17:22: note: expected ‘size_t *’ but argument is of type ‘int *’
 PHP_REDIS_API char * redis_sock_read(RedisSock *redis_sock, size_t *buf_len TSRMLS_DC);
                      ^
/usr/local/src/redis/redis_session.c: In function ‘ps_write_redis’:
/usr/local/src/redis/redis_session.c:397:58: warning: passing argument 4 of ‘redis_session_key’ from incompatible pointer type
     session = redis_session_key(rpm, key->val, key->len, &session_len);
                                                          ^
/usr/local/src/redis/redis_session.c:324:1: note: expected ‘int *’ but argument is of type ‘size_t *’
 redis_session_key(redis_pool_member *rpm, const char *key, int key_len, int *session_len) {
 ^
/usr/local/src/redis/redis_session.c: In function ‘ps_delete_redis’:
/usr/local/src/redis/redis_session.c:449:49: warning: passing argument 2 of ‘redis_sock_read’ from incompatible pointer type
     if ((response = redis_sock_read(redis_sock, &response_len TSRMLS_CC)) == NULL) {
                                                 ^
In file included from /usr/local/src/redis/redis_session.c:36:0:
/usr/local/src/redis/library.h:17:22: note: expected ‘size_t *’ but argument is of type ‘int *’
 PHP_REDIS_API char * redis_sock_read(RedisSock *redis_sock, size_t *buf_len TSRMLS_DC);
                      ^
/usr/local/src/redis/redis_cluster.c: In function ‘get_key_val_ht’:
/usr/local/src/redis/redis_cluster.c:554:57: warning: passing argument 3 of ‘redis_key_prefix’ makes pointer from integer without a cast
     kv->key_free = redis_key_prefix(c->flags, &tmp_key, kv->key->len);
                                                         ^
In file included from /usr/local/src/redis/redis_commands.h:5:0,
                 from /usr/local/src/redis/redis_cluster.c:29:
/usr/local/src/redis/library.h:65:1: note: expected ‘int *’ but argument is of type ‘size_t’
 redis_key_prefix(RedisSock *redis_sock, char **key, int *key_len);
 ^
/usr/local/src/redis/redis_cluster.c: In function ‘get_key_ht’:
/usr/local/src/redis/redis_cluster.c:590:57: warning: passing argument 3 of ‘redis_key_prefix’ makes pointer from integer without a cast
     kv->key_free = redis_key_prefix(c->flags, &tmp_key, kv->key->len);
                                                         ^
In file included from /usr/local/src/redis/redis_commands.h:5:0,
                 from /usr/local/src/redis/redis_cluster.c:29:
/usr/local/src/redis/library.h:65:1: note: expected ‘int *’ but argument is of type ‘size_t’
 redis_key_prefix(RedisSock *redis_sock, char **key, int *key_len);
 ^
/usr/local/src/redis/cluster_library.c: In function ‘cluster_multibulk_resp_recursive’:
/usr/local/src/redis/cluster_library.c:135:57: warning: passing argument 4 of ‘redis_sock_gets’ makes pointer from integer without a cast
                 if(redis_sock_gets(sock,buf,sizeof(buf),r->len TSRMLS_CC)<0) {
                                                         ^
In file included from /usr/local/src/redis/cluster_library.c:3:0:
/usr/local/src/redis/library.h:18:19: note: expected ‘size_t *’ but argument is of type ‘long long int’
 PHP_REDIS_API int redis_sock_gets(RedisSock *redis_sock, char *buf, int buf_size, size_t* line_len TSRMLS_DC);
                   ^
/usr/local/src/redis/cluster_library.c: In function ‘cluster_slot_sock’:
/usr/local/src/redis/cluster_library.c:180:92: warning: comparison between pointer and integer
     if (!SLOT_SLAVES(c, slot) || (node = zend_hash_index_find(SLOT_SLAVES(c,slot), slaveidx==NULL))) {
                                                                                            ^
/usr/local/src/redis/cluster_library.c:180:40: warning: assignment from incompatible pointer type
     if (!SLOT_SLAVES(c, slot) || (node = zend_hash_index_find(SLOT_SLAVES(c,slot), slaveidx==NULL))) {
                                        ^
/usr/local/src/redis/cluster_library.c: In function ‘mbulk_resp_loop_raw’:
/usr/local/src/redis/cluster_library.c:2190:44: warning: passing argument 2 of ‘redis_sock_read’ from incompatible pointer type
         line = redis_sock_read(redis_sock, &line_len TSRMLS_CC);
                                            ^
In file included from /usr/local/src/redis/cluster_library.c:3:0:
/usr/local/src/redis/library.h:17:22: note: expected ‘size_t *’ but argument is of type ‘int *’
 PHP_REDIS_API char * redis_sock_read(RedisSock *redis_sock, size_t *buf_len TSRMLS_DC);
                      ^
/usr/local/src/redis/cluster_library.c: In function ‘mbulk_resp_loop’:
/usr/local/src/redis/cluster_library.c:2211:44: warning: passing argument 2 of ‘redis_sock_read’ from incompatible pointer type
         line = redis_sock_read(redis_sock, &line_len TSRMLS_CC);
                                            ^
In file included from /usr/local/src/redis/cluster_library.c:3:0:
/usr/local/src/redis/library.h:17:22: note: expected ‘size_t *’ but argument is of type ‘int *’
 PHP_REDIS_API char * redis_sock_read(RedisSock *redis_sock, size_t *buf_len TSRMLS_DC);
                      ^
/usr/local/src/redis/cluster_library.c: In function ‘mbulk_resp_loop_zipstr’:
/usr/local/src/redis/cluster_library.c:2246:44: warning: passing argument 2 of ‘redis_sock_read’ from incompatible pointer type
         line = redis_sock_read(redis_sock, &line_len TSRMLS_CC);
                                            ^
In file included from /usr/local/src/redis/cluster_library.c:3:0:
/usr/local/src/redis/library.h:17:22: note: expected ‘size_t *’ but argument is of type ‘int *’
 PHP_REDIS_API char * redis_sock_read(RedisSock *redis_sock, size_t *buf_len TSRMLS_DC);
                      ^
/usr/local/src/redis/cluster_library.c: In function ‘mbulk_resp_loop_zipdbl’:
/usr/local/src/redis/cluster_library.c:2285:44: warning: passing argument 2 of ‘redis_sock_read’ from incompatible pointer type
         line = redis_sock_read(redis_sock, &line_len TSRMLS_CC);
                                            ^
In file included from /usr/local/src/redis/cluster_library.c:3:0:
/usr/local/src/redis/library.h:17:22: note: expected ‘size_t *’ but argument is of type ‘int *’
 PHP_REDIS_API char * redis_sock_read(RedisSock *redis_sock, size_t *buf_len TSRMLS_DC);
                      ^
/usr/local/src/redis/cluster_library.c: In function ‘mbulk_resp_loop_assoc’:
/usr/local/src/redis/cluster_library.c:2321:44: warning: passing argument 2 of ‘redis_sock_read’ from incompatible pointer type
         line = redis_sock_read(redis_sock, &line_len TSRMLS_CC);
                                            ^
In file included from /usr/local/src/redis/cluster_library.c:3:0:
/usr/local/src/redis/library.h:17:22: note: expected ‘size_t *’ but argument is of type ‘int *’
 PHP_REDIS_API char * redis_sock_read(RedisSock *redis_sock, size_t *buf_len TSRMLS_DC);

@Jan-E
Copy link
Author

Jan-E commented Jul 6, 2015

After these commits the errors in Debian are reduced a lot:

/usr/local/src/redis.php7/library.c: In function ‘redis_serialize’:
/usr/local/src/redis.php7/library.c:2008:28: warning: passing argument 1 of ‘zend_string_init’ from incompatible pointer type
    *val = zend_string_init(sstr.s,(*val)->len, 0);
                            ^
In file included from /usr/local/php70/include/php/Zend/zend.h:35:0,
                 from /usr/local/php70/include/php/main/php.h:35,
                 from /usr/local/src/redis.php7/common.h:1,
                 from /usr/local/src/redis.php7/library.c:4:
/usr/local/php70/include/php/Zend/zend_string.h:155:40: note: expected ‘const char *’ but argument is of type ‘struct zend_string *’
 static zend_always_inline zend_string *zend_string_init(const char *str, size_t len, int persistent)
                                        ^
/usr/local/src/redis.php7/cluster_library.c: In function ‘cluster_slot_sock’:
/usr/local/src/redis.php7/cluster_library.c:180:92: warning: comparison between pointer and integer
     if (!SLOT_SLAVES(c, slot) || (node = zend_hash_index_find(SLOT_SLAVES(c,slot), slaveidx==NULL))) {
                                                                                            ^
/usr/local/src/redis.php7/cluster_library.c:180:40: warning: assignment from incompatible pointer type
     if (!SLOT_SLAVES(c, slot) || (node = zend_hash_index_find(SLOT_SLAVES(c,slot), slaveidx==NULL))) {

But I am still getting a segfault at var_dump($redis->info("CPU")). I am recompiling all PHP7 builds with these commits.

edtechd added a commit that referenced this pull request Jul 6, 2015
Fixed types for better compatibility
@edtechd edtechd merged commit caec901 into edtechd:php7 Jul 6, 2015
@Jan-E
Copy link
Author

Jan-E commented Jul 7, 2015

Additional info on the segfaults on Debian: it segfaults when running 'php [some redis script]', but just quits halfway down the script when running 'sudo php [some redis script]'. I have been testing this on Rasmus' php7 vagrant box: https://github.com/rlerdorf/php7dev

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 this pull request may close these issues.

2 participants