Bug #87584 Error in `/usr/bin/mysqlsh': munmap_chunk(): invalid pointer: 0x0000000001afd5c0
Submitted: 29 Aug 2017 13:40 Modified: 10 Apr 2018 23:08
Reporter: Shahriyar Rzayev Email Updates:
Status: Can't repeat Impact on me:
None 
Category:Connector / Python Severity:S1 (Critical)
Version:8.0.0 OS:CentOS (7)
Assigned to: CPU Architecture:Any

[29 Aug 2017 13:40] Shahriyar Rzayev
Description:
Installed 8.0.0 DMR on CentOS 7 and read the DOC:

https://dev.mysql.com/doc/refman/5.7/en/mysqlsh.html#option_mysqlsh_execute

Tried to execute command:

$ mysqlsh root@localhost/generated_columns_test --py --execute "import mysqlx"
Enter password: 
*** Error in `mysqlsh': double free or corruption (out): 0x00000000039ac000 ***
======= Backtrace: =========
/lib64/libc.so.6(+0x7d1fd)[0x7ff1017e41fd]
mysqlsh[0xd25d33]
mysqlsh(_ZN6google8protobuf20FileDescriptorTablesD1Ev+0x86)[0xd3148a]
/lib64/libc.so.6(+0x38e49)[0x7ff10179fe49]
/lib64/libc.so.6(+0x38e95)[0x7ff10179fe95]
/lib64/libc.so.6(__libc_start_main+0xfc)[0x7ff101788afc]
mysqlsh[0x73917c]
======= Memory map: ========
00400000-012f7000 r-xp 00000000 fd:00 141957189                          /usr/bin/mysqlsh
014f6000-01510000 r--p 00ef6000 fd:00 141957189                          /usr/bin/mysqlsh
01510000-016cf000 rw-p 00f10000 fd:00 141957189                          /usr/bin/mysqlsh
016cf000-016e1000 rw-p 00000000 00:00 0 
035ed000-03b70000 rw-p 00000000 00:00 0                                  [heap]

$ gdb mysqlsh core.4715.mysqlsh.6

(gdb) bt
+bt
#0  0x00007ff10179c5d7 in raise () from /lib64/libc.so.6
#1  0x00007ff10179dcc8 in abort () from /lib64/libc.so.6
#2  0x00007ff1017dce07 in __libc_message () from /lib64/libc.so.6
#3  0x00007ff1017e41fd in _int_free () from /lib64/libc.so.6
#4  0x0000000000d25d33 in deallocate (__p=<optimized out>, this=0x16dd624 <google::protobuf::FileDescriptorTables::kEmpty+196>) at /usr/include/c++/4.8.2/ext/new_allocator.h:110
#5  _M_deallocate_node (__n=<optimized out>, this=0x16dd620 <google::protobuf::FileDescriptorTables::kEmpty+192>) at /usr/include/c++/4.8.2/tr1/hashtable.h:453
#6  _M_deallocate_nodes (__n=11, __array=0x39ef940, this=0x16dd620 <google::protobuf::FileDescriptorTables::kEmpty+192>) at /usr/include/c++/4.8.2/tr1/hashtable.h:472
#7  clear (this=0x16dd620 <google::protobuf::FileDescriptorTables::kEmpty+192>) at /usr/include/c++/4.8.2/tr1/hashtable.h:1121
#8  std::tr1::_Hashtable<std::pair<google::protobuf::EnumDescriptor const*, int>, std::pair<std::pair<google::protobuf::EnumDescriptor const*, int> const, google::protobuf::EnumValueDescriptor const*>, std::allocator<std::pair<std::pair<google::protobuf::EnumDescriptor const*, int> const, google::protobuf::EnumValueDescriptor const*> >, std::_Select1st<std::pair<std::pair<google::protobuf::EnumDescriptor const*, int> const, google::protobuf::EnumValueDescriptor const*> >, std::equal_to<std::pair<google::protobuf::EnumDescriptor const*, int> >, google::protobuf::(anonymous namespace)::PointerIntegerPairHash<std::pair<google::protobuf::EnumDescriptor const*, int> >, std::tr1::__detail::_Mod_range_hashing, std::tr1::__detail::_Default_ranged_hash, std::tr1::__detail::_Prime_rehash_policy, false, false, true>::~_Hashtable (this=this@entry=0x16dd620 <google::protobuf::FileDescriptorTables::kEmpty+192>, __in_chrg=<optimized out>) at /usr/include/c++/4.8.2/tr1/hashtable.h:640
#9  0x0000000000d3148a in ~__unordered_map (this=0x16dd620 <google::protobuf::FileDescriptorTables::kEmpty+192>, __in_chrg=<optimized out>) at /usr/include/c++/4.8.2/tr1/unordered_map.h:43
#10 ~unordered_map (this=0x16dd620 <google::protobuf::FileDescriptorTables::kEmpty+192>, __in_chrg=<optimized out>) at /usr/include/c++/4.8.2/tr1/unordered_map.h:180
#11 ~hash_map (this=0x16dd620 <google::protobuf::FileDescriptorTables::kEmpty+192>, __in_chrg=<optimized out>) at google/protobuf/stubs/hash.h:172
#12 google::protobuf::FileDescriptorTables::~FileDescriptorTables (this=0x16dd560 <google::protobuf::FileDescriptorTables::kEmpty>, __in_chrg=<optimized out>) at google/protobuf/descriptor.cc:606
#13 0x00007ff10179fe49 in __run_exit_handlers () from /lib64/libc.so.6
#14 0x00007ff10179fe95 in exit () from /lib64/libc.so.6
#15 0x00007ff101788afc in __libc_start_main () from /lib64/libc.so.6
#16 0x000000000073917c in _start ()

How to repeat:
See description
[29 Aug 2017 13:59] MySQL Verification Team
Thank you for the bug report. Are you tried the current released version 8.0.2 dmr? otherwise please try. Thanks.
[29 Aug 2017 14:03] Shahriyar Rzayev
From downloads page the latest is 8.0.0-0.1.dmr

Attachment: there_is_no_such_version_in_downloads.png (image/png, text), 249.54 KiB.

[29 Aug 2017 14:10] MySQL Verification Team
Thank you for the feedback. I confused with server version.
[30 Aug 2017 8:44] MySQL Verification Team
Thank you for the report.
I'm not seeing the issue on FC26.

==
[ushastry@fedora26 Downloads]$ mysqlsh root@localhost/world_x --py --execute "import mysql"
Enter password: 

-- I have these packages though:

[ushastry@fedora26 Downloads]$ rpm -qa|grep mysql
mysql-community-common-5.7.19-1.fc26.x86_64
mysql57-community-release-fc26-10.noarch
mysql-connector-python-2.1.7-1.fc26.x86_64
mysql-community-client-5.7.19-1.fc26.x86_64
mysql-shell-8.0.0-0.1.dmr.fc26.x86_64
mysql-community-libs-5.7.19-1.fc26.x86_64
mysql-community-server-5.7.19-1.fc26.x86_64

Are you using GA mysql-connector-python-2.1.7 or DMR mysql-connector-python-8.0.x?

Thanks,
Umesh
[30 Aug 2017 10:37] Shahriyar Rzayev
Hi Umesh,

I am using:

mysql-connector-python-8.0.4-0.1.dmr.el7.x86_64.rpm
[13 Sep 2017 6:31] Shahriyar Rzayev
Hi Umesh,
Did you test it with DMR?
[13 Sep 2017 6:46] MySQL Verification Team
Hi Shahriyar,

I have not made much progress on this as all my efforts ended without any issues. I have tried on many OSs(except CentOS) but not seeing the crash at my end. I'll give it a try today on CentOS and will comeback.

thanks,
Umesh
[18 Sep 2017 13:02] MySQL Verification Team
Finally, verified as described on CentOS7.
Joining the logs shortly.
[18 Sep 2017 13:13] MySQL Verification Team
test results

Attachment: 87584.results (application/octet-stream, text), 10.95 KiB.

[26 Sep 2017 18:16] Krzysztof Grzadziel
Hi Shahriyar and Umesh,

The issue is in 3rd party library `protobuf`. To fix this, I have to know if
mysqlsh on centos is using shared protobuf library or static one.

Could you send me printout from shared object dependecies of mysqlsh, please?
Find `mysqlsh` path, using:
$ which mysqlsh

and get shared object dependecies by:
$ ldd `which mysqlsh`
or
$ ldd /path/to/mysqlsh

If your `mysqlsh` depends on protobuf dynamic library, please upgrade
`protobuf` library on your OS.

Best regards,
Krzysztof
[28 Sep 2017 0:56] Alfredo Kojima
Posted by developer:
 
Reassigning bug to Connector/Python
[28 Sep 2017 2:07] Krzysztof Grzadziel
Posted by developer:
 
Hi Shahriyar,

You found bug in MySQL Connector/Python driver and thank you for the bug report.
Issue with `mysql-connector-python-8.0.4-0.1.dmr.el7.x86_64` is that Connector/Python use dynamic loaded `/usr/lib64/python2.7/site-packages/_mysqlxpb.so`
which use `protobuf` version with this bug https://github.com/google/protobuf/pull/1062.

Reported bug will be moved to MySQL Connector/Python team.

`import mysqlx` imports Connector/Python library module which is not supported to be used with MySQL Shell.
You should use `mysqlx` module from `mysqlsh` package which is supported by MySQL Shell, i.e. `from mysqlsh import mysqlx` instead of `import mysqlx`.

$ mysqlsh root@localhost --py --execute "from mysqlsh import mysqlx"

To sum up. Please use `from mysqlsh import mysqlx`.

Best regards,
Krzysztof
[10 Apr 2018 23:08] Alfredo Kojima
Posted by developer:
 
Issue can no longer be reproduced, please reopen if you can still repeat with the latest version.

Furthermore, the command to import the mysqlx module in the shell should be:
from mysqlsh import mysqlx

Directly importing mysqlx is not supported in the shell, only in standalone Python interpreters.