Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin loads but aborts with "unable to mmap memory size: 4096, errno: 12" #150

Closed
RickPizzi opened this issue Nov 24, 2016 · 22 comments
Closed

Comments

@RickPizzi
Copy link
Contributor

RickPizzi commented Nov 24, 2016

I have been trying to upgrade our plugin from 1.0.9 to 1.1.0 because of that bug that we raised and which is fixed in this version. Unfortunately, the 1.1.0 aborts right after loading with the above error. Previous version works just fine. This does not happen on all servers though....

Server version:		5.6.29-76.2-log Percona Server (GPL), Release 76.2, Revision ddf26fe

plugin-load=AUDIT=libaudit_plugin.so
audit_offsets=7704, 7760, 4392, 5032, 88, 2720, 96, 0, 32, 104, 152, 7880
audit_json_file=ON
audit_json_log_file=/db/log/audit.log
audit_record_objs="<redacted>"
audit_record_cmds="select"
audit_force_record_logins=ON
audit_whitelist_users="<redacted>,{}"

Machine where this does not work (phisycal)

CentOS 6.7
Linux redacted 2.6.32-573.18.1.el6.x86_64 #1 SMP Tue Feb 9 22:46:17 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

Machine where the plugin runs fine (virtual, AWS):

CentOS 6-7
Linux redacted 2.6.32-573.8.1.el6.centos.plus.x86_64 #1 SMP Tue Nov 10 18:20:27 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

Please let me know if more information is needed.

Thanks

Rick

@aharonrobbins
Copy link

aharonrobbins commented Nov 24, 2016 via email

@RickPizzi
Copy link
Contributor Author

Oddly, the result is the same on both:

_SC_PAGE_SIZE = 4096

@aharonrobbins
Copy link

aharonrobbins commented Nov 24, 2016 via email

@RickPizzi
Copy link
Contributor Author

selinux is disabled...

@aharonrobbins
Copy link

aharonrobbins commented Nov 24, 2016 via email

@RickPizzi
Copy link
Contributor Author

RickPizzi commented Nov 24, 2016 via email

@aharonrobbins
Copy link

aharonrobbins commented Nov 24, 2016 via email

@RickPizzi
Copy link
Contributor Author

I have tried to run the snippet alone:

#include <stdio.h>
#include <unistd.h>
#include <sys/mman.h>

int main()
{
        int mmap_flags = MAP_PRIVATE|MAP_ANONYMOUS;
        const unsigned long page_size = sysconf(_SC_PAGESIZE);

        if (mmap(NULL, page_size, PROT_READ|PROT_EXEC, mmap_flags, -1, 0) == NULL)
                perror("mmap");
}

This one works fine.
So, why is it failing in the plugin?

Please note, we are loading the plugin at runtime (we cannot stop this server). May the problem be related?

Also, I had to replace your call to GETPAGESIZE() with the sysconf equivalent, but don't think that this changes anything, pagesize is 4k and it is reported by the abort error message...

@aharonrobbins
Copy link

aharonrobbins commented Nov 24, 2016 via email

@RickPizzi
Copy link
Contributor Author

RickPizzi commented Nov 24, 2016 via email

@aharonrobbins
Copy link

aharonrobbins commented Nov 24, 2016 via email

@aharonrobbins
Copy link

aharonrobbins commented Nov 24, 2016 via email

@RickPizzi
Copy link
Contributor Author

RickPizzi commented Nov 24, 2016 via email

@RickPizzi
Copy link
Contributor Author

RickPizzi commented Nov 24, 2016 via email

@aharonrobbins
Copy link

aharonrobbins commented Nov 24, 2016 via email

@RickPizzi
Copy link
Contributor Author

RickPizzi commented Nov 24, 2016 via email

@aharonrobbins
Copy link

aharonrobbins commented Nov 24, 2016 via email

@RickPizzi
Copy link
Contributor Author

RickPizzi commented Nov 24, 2016 via email

@RickPizzi
Copy link
Contributor Author

RickPizzi commented Nov 24, 2016 via email

@aharonrobbins
Copy link

aharonrobbins commented Nov 27, 2016 via email

@RickPizzi
Copy link
Contributor Author

RickPizzi commented Nov 28, 2016

Some updates.
Compiling requires to follow instructions in compiling.txt file which was not part of tarball, but checking out from git and following the instructions in that file worked and the plugin compiled just fine.

Regarding original problem, it appears that setting use_static_memory to true allows the plugin to load and work just fine, so I just patched the code that sets that to false:

        if (func_in_mysqld < INT_MAX && func_in_plugin > INT_MAX)
        {
                // See comment about IndirectJump in hot_patch.cc.
                mmap_flags |= MAP_32BIT;
        //      use_static_memory = false;

@aharonrobbins
Copy link

We are working on this, to see if we can make things work correctly without requiring rebuilding the plugin.

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

No branches or pull requests

2 participants