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

lua and luajit crash on OpenSUSE 12.1 (i386/32bit) #7

Closed
bfg opened this issue Mar 28, 2012 · 8 comments
Closed

lua and luajit crash on OpenSUSE 12.1 (i386/32bit) #7

bfg opened this issue Mar 28, 2012 · 8 comments

Comments

@bfg
Copy link

bfg commented Mar 28, 2012

Hello there!

I'm experiencing weird errors on my laptop while trying to use lua-openssl. Lua and/or luajit interpreters crash immediately.

My environment:

$ uname -a
Linux k2 3.2.9-12-desktop #1 SMP PREEMPT Thu Mar 1 17:31:01 UTC 2012 (ba1cb50) i686 i686 i386 GNU/Linux
$ lsb_release -a
LSB Version:    core-2.0-noarch:core-3.2-noarch:core-4.0-noarch:core-2.0-ia32:core-3.2-ia32:core-4.0-ia32:desktop-4.0-ia32:desktop-4.0-noarch:graphics-2.0-ia32:graphics-2.0-noarch:graphics-3.2-ia32:graphics-3.2-noarch:graphics-4.0-ia32:graphics-4.0-noarch
Distributor ID: SUSE LINUX
Description:    openSUSE 12.1 (i586)
Release:        12.1
Codename:       Asparagus

OpenSSL:

$ openssl version
OpenSSL 1.0.0e 6 Sep 2011

I compiled lua and luajit myself, because i thought that something is wrong with packages provided by distribution

$ lua -v
Lua 5.1.5  Copyright (C) 1994-2012 Lua.org, PUC-Rio

$ luajit -v
LuaJIT 2.0.0-beta9 -- Copyright (C) 2005-2011 Mike Pall. http://luajit.org/

System environment:

$ cc --version
cc (SUSE Linux) 4.6.2
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ ld --version
GNU ld (GNU Binutils; openSUSE 12.1) 2.21.1
Copyright 2011 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.

$ /lib/libc.so.6 
GNU C Library stable release version 2.14.1 (20111007), by Roland McGrath et al.
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Configured for i686-suse-linux.
Compiled by GNU CC version 4.6.2.
Compiled on a Linux 3.1.0 system on 2012-01-09.
Available extensions:
        crypt add-on version 2.1 by Michael Glad and others
        GNU Libidn by Simon Josefsson
        NoVersion patch for broken glibc 2.0 binaries
        Native POSIX Threads Library by Ulrich Drepper et al
        BIND-8.2.3-T5B
libc ABIs: UNIQUE IFUNC
For bug reporting instructions, please see:
<http://www.gnu.org/software/libc/bugs.html>

Code that crashes:

local openssl = require('openssl')

secret_key = "secret"
cipher = openssl.get_cipher("RC4")

num = 10000000
i = 1
while i <= num do
        i = i+1
        id = "something"
        encrypted = cipher:encrypt(id, secret_key);
end

Lua error:


$ lua a.lua
lua: malloc.c:3096: sYSMALLOc: Assertion (old_top == (((mbinptr) (((char *) &((av)->bins[((1) - 1) * 2])) - __builtin_offsetof (struct malloc_chunk, fd)))) && old_size == 0) || ((unsigned long) (old_size) >= (unsigned long)((((__builtin_offsetof (struct malloc_chunk, fd_nextsize))+((2 * (sizeof(size_t))) - 1)) & ~((2 * (sizeof(size_t))) - 1))) && ((old_top)->size & 0x1) && ((unsigned long)old_end & pagemask) == 0)' failed.
Aborted (core dumped)


Stack trace:

#0 0xb754e8c5 in raise () from /lib/libc.so.6
#1 0xb75501d5 in abort () from /lib/libc.so.6
#2 0xb758f294 in __malloc_assert () from /lib/libc.so.6
#3 0xb75921ec in _int_malloc () from /lib/libc.so.6
#4 0xb7593cdc in malloc () from /lib/libc.so.6
#5 0xb739b2bc in ?? () from /lib/libcrypto.so.1.0.0
#6 0xb739b94c in CRYPTO_malloc () from /lib/libcrypto.so.1.0.0
#7 0xb740d13c in lh_new () from /lib/libcrypto.so.1.0.0
#8 0xb739e99c in OBJ_NAME_init () from /lib/libcrypto.so.1.0.0
#9 0xb739ed05 in OBJ_NAME_add () from /lib/libcrypto.so.1.0.0
#10 0xb74177e8 in EVP_add_cipher () from /lib/libcrypto.so.1.0.0
#11 0xb741cb93 in OpenSSL_add_all_ciphers () from /lib/libcrypto.so.1.0.0
#12 0xb750f71d in luaopen_openssl () from ./openssl.so
#13 0x0804f76e in luaD_precall ()
#14 0x0804fb38 in luaD_call ()
#15 0x0804d4d7 in lua_call ()
#16 0x08065a08 in ll_require ()
#17 0x0804f76e in luaD_precall ()
#18 0x08058605 in luaV_execute ()
#19 0x0804fb88 in luaD_call ()
#20 0x0804c0e0 in f_call ()
#21 0x0804eeb2 in luaD_rawrunprotected ()
#22 0x0804fd20 in luaD_pcall ()
#23 0x0804d572 in lua_pcall ()
#24 0x0804b5f6 in docall ()
#25 0x0804be8c in pmain ()
#26 0x0804f76e in luaD_precall ()
#27 0x0804fb38 in luaD_call ()
#28 0x0804c0a8 in f_Ccall ()
#29 0x0804eeb2 in luaD_rawrunprotected ()
#30 0x0804fd20 in luaD_pcall ()
#31 0x0804d601 in lua_cpcall ()
#32 0x0804b22c in main ()


LuaJIT error

$ luajit a.lua
luajit: malloc.c:3096: sYSMALLOc: Assertion (old_top == (((mbinptr) (((char *) &((av)->bins[((1) - 1) * 2])) - __builtin_offsetof (struct malloc_chunk, fd)))) && old_size == 0) || ((unsigned long) (old_size) >= (unsigned long)((((__builtin_offsetof (struct malloc_chunk, fd_nextsize))+((2 * (sizeof(size_t))) - 1)) & ~((2 * (sizeof(size_t))) - 1))) && ((old_top)->size & 0x1) && ((unsigned long)old_end & pagemask) == 0)' failed.
Aborted (core dumped)


Stack trace:

#0 0xb75798c5 in raise () from /lib/libc.so.6
#1 0xb757b1d5 in abort () from /lib/libc.so.6
#2 0xb75ba294 in __malloc_assert () from /lib/libc.so.6
#3 0xb75bd1ec in _int_malloc () from /lib/libc.so.6
#4 0xb75becdc in malloc () from /lib/libc.so.6
#5 0xb73a22bc in ?? () from /lib/libcrypto.so.1.0.0
#6 0xb73a294c in CRYPTO_malloc () from /lib/libcrypto.so.1.0.0
#7 0xb741413c in lh_new () from /lib/libcrypto.so.1.0.0
#8 0xb73a599c in OBJ_NAME_init () from /lib/libcrypto.so.1.0.0
#9 0xb73a5d05 in OBJ_NAME_add () from /lib/libcrypto.so.1.0.0
#10 0xb741e7e8 in EVP_add_cipher () from /lib/libcrypto.so.1.0.0
#11 0xb7423b93 in OpenSSL_add_all_ciphers () from /lib/libcrypto.so.1.0.0
#12 0xb753971d in luaopen_openssl () from ./openssl.so
#13 0x080633c7 in ?? ()
#14 0x0808d9a8 in ?? ()
#15 0x080633c7 in ?? ()
#16 0x080528ad in lua_pcall ()
#17 0x0804ba46 in _start ()


The same code runs fine on Ubuntu 12.04 LTS beta x86_64 (64bit, openssl 1.0.1)... Is there any possibility that something is wrong on 32bit system?
@bfg
Copy link
Author

bfg commented Mar 28, 2012

Well, there is also similar problem on ubuntu 12.04 lts beta, 64bit, with custom compiled openresty (latest development version). Just adding

require "openssl"

To lua file results in a worker process crash.

*** glibc detected *** nginx: worker process: malloc(): memory corruption: 0x0000000001801da0 ***
2012/03/28 15:49:06 [alert] 26756#0: worker process 1984 exited on signal 9

@zhaozg
Copy link
Owner

zhaozg commented Mar 29, 2012

I'll check it in some days

@zhaozg
Copy link
Owner

zhaozg commented Apr 4, 2012

I fix a lots of warning when compile, but I not sure, this bug has been solved, so you can fetch last code to try, and I think I need do more work.

@bfg
Copy link
Author

bfg commented Apr 4, 2012

Nice, most of the warnings are gone. But script from above still crashes interpreter.

lua: malloc.c:3096: sYSMALLOc: Assertion `(old_top == (((mbinptr) (((char *) &((av)->bins[((1) - 1) * 2])) - __builtin_offsetof (struct malloc_chunk, fd)))) && old_size == 0) || ((unsigned long) (old_size) >= (unsigned long)((((__builtin_offsetof (struct malloc_chunk, fd_nextsize))+((2 * (sizeof(size_t))) - 1)) & ~((2 * (sizeof(size_t))) - 1))) && ((old_top)->size & 0x1) && ((unsigned long)old_end & pagemask) == 0)' failed.

Backtrace:

Core was generated by `lua a.lua'.
Program terminated with signal 6, Aborted.
#0  0xb75328c5 in raise () from /lib/libc.so.6
(gdb) bt
#0  0xb75328c5 in raise () from /lib/libc.so.6
#1  0xb75341d5 in abort () from /lib/libc.so.6
#2  0xb7573294 in __malloc_assert () from /lib/libc.so.6
#3  0xb75761ec in _int_malloc () from /lib/libc.so.6
#4  0xb7577cdc in malloc () from /lib/libc.so.6
#5  0xb73812bc in ?? () from /lib/libcrypto.so.1.0.0
#6  0xb738194c in CRYPTO_malloc () from /lib/libcrypto.so.1.0.0
#7  0xb73f313c in lh_new () from /lib/libcrypto.so.1.0.0
#8  0xb738499c in OBJ_NAME_init () from /lib/libcrypto.so.1.0.0
#9  0xb7384d05 in OBJ_NAME_add () from /lib/libcrypto.so.1.0.0
#10 0xb73fd7e8 in EVP_add_cipher () from /lib/libcrypto.so.1.0.0
#11 0xb7402b93 in OpenSSL_add_all_ciphers () from /lib/libcrypto.so.1.0.0
#12 0xb74f081f in luaopen_openssl (L=0x8073008) at src/openssl.c:869
#13 0x0804f76e in luaD_precall ()
#14 0x0804fb38 in luaD_call ()
#15 0x0804d4d7 in lua_call ()
#16 0x08065a08 in ll_require ()
#17 0x0804f76e in luaD_precall ()
#18 0x08058605 in luaV_execute ()
#19 0x0804fb88 in luaD_call ()
#20 0x0804c0e0 in f_call ()
#21 0x0804eeb2 in luaD_rawrunprotected ()
#22 0x0804fd20 in luaD_pcall ()
#23 0x0804d572 in lua_pcall ()
#24 0x0804b5f6 in docall ()
#25 0x0804be8c in pmain ()
#26 0x0804f76e in luaD_precall ()
#27 0x0804fb38 in luaD_call ()
#28 0x0804c0a8 in f_Ccall ()
#29 0x0804eeb2 in luaD_rawrunprotected ()
#30 0x0804fd20 in luaD_pcall ()
#31 0x0804d601 in lua_cpcall ()
#32 0x0804b22c in main ()

@bfg
Copy link
Author

bfg commented Apr 4, 2012

$ lua -e 'require "openssl"'
lua: malloc.c:3096: sYSMALLOc: Assertion `(old_top == (((mbinptr) (((char *) &((av)->bins[((1) - 1) * 2])) - __builtin_offsetof (struct malloc_chunk, fd)))) && old_size == 0) || ((unsigned long) (old_size) >= (unsigned long)((((__builtin_offsetof (struct malloc_chunk, fd_nextsize))+((2 * (sizeof(size_t))) - 1)) & ~((2 * (sizeof(size_t))) - 1))) && ((old_top)->size & 0x1) && ((unsigned long)old_end & pagemask) == 0)' failed.

backtrace:

#0  0xb75658c5 in raise () from /lib/libc.so.6
#1  0xb75671d5 in abort () from /lib/libc.so.6
#2  0xb75a6294 in __malloc_assert () from /lib/libc.so.6
#3  0xb75a91ec in _int_malloc () from /lib/libc.so.6
#4  0xb75aacdc in malloc () from /lib/libc.so.6
#5  0xb73b42bc in ?? () from /lib/libcrypto.so.1.0.0
#6  0xb73b494c in CRYPTO_malloc () from /lib/libcrypto.so.1.0.0
#7  0xb742613c in lh_new () from /lib/libcrypto.so.1.0.0
#8  0xb73b799c in OBJ_NAME_init () from /lib/libcrypto.so.1.0.0
#9  0xb73b7d05 in OBJ_NAME_add () from /lib/libcrypto.so.1.0.0
#10 0xb74307e8 in EVP_add_cipher () from /lib/libcrypto.so.1.0.0
#11 0xb7435b93 in OpenSSL_add_all_ciphers () from /lib/libcrypto.so.1.0.0
#12 0xb752381f in luaopen_openssl (L=0x8073008) at src/openssl.c:869
#13 0x0804f76e in luaD_precall ()
#14 0x0804fb38 in luaD_call ()
#15 0x0804d4d7 in lua_call ()
#16 0x08065a08 in ll_require ()
#17 0x0804f76e in luaD_precall ()
#18 0x08058605 in luaV_execute ()
#19 0x0804fb88 in luaD_call ()
#20 0x0804c0e0 in f_call ()
#21 0x0804eeb2 in luaD_rawrunprotected ()
#22 0x0804fd20 in luaD_pcall ()
#23 0x0804d572 in lua_pcall ()
#24 0x0804b5f6 in docall ()
#25 0x0804b698 in dostring ()
#26 0x0804bbdf in pmain ()
#27 0x0804f76e in luaD_precall ()
#28 0x0804fb38 in luaD_call ()
#29 0x0804c0a8 in f_Ccall ()
#30 0x0804eeb2 in luaD_rawrunprotected ()
#31 0x0804fd20 in luaD_pcall ()
#32 0x0804d601 in lua_cpcall ()
#33 0x0804b22c in main ()

@miko
Copy link

miko commented May 24, 2012

I have the same problem on ArchLinux, just requiring the module crashes the interpreter ("lua -l openssl").

$ openssl version
OpenSSL 1.0.1c 10 May 2012

$ cc --version
cc (GCC) 4.7.0 20120505 (prerelease)

$ ld --version
GNU ld (GNU Binutils) 2.22.0.20120323

$ /lib/libc.so.6
GNU C Library stable release version 2.15, by Roland McGrath et al.
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Compiled by GNU CC version 4.7.0 20120324 (prerelease).
Compiled on a Linux 3.3.0 system on 2012-03-29.
Available extensions:
crypt add-on version 2.1 by Michael Glad and others
GNU Libidn by Simon Josefsson
Native POSIX Threads Library by Ulrich Drepper et al
BIND-8.2.3-T5B
libc ABIs: UNIQUE IFUNC

(gdb) run t.lua
Starting program: /usr/bin/lua t.lua
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/libthread_db.so.1".
lua: malloc.c:2451: sYSMALLOc: Assertion `(old_top == (((mbinptr) (((char *) &((av)->bins[((1) - 1) * 2])) - __builtin_offsetof (struct malloc_chunk, fd)))) && old_size == 0) || ((unsigned long) (old_size) >= (unsigned long)((((__builtin_offsetof (struct malloc_chunk, fd_nextsize))+((2 * (sizeof(size_t))) - 1)) & ~((2 * (sizeof(size_t))) - 1))) && ((old_top)->size & 0x1) && ((unsigned long)old_end & pagemask) == 0)' failed.

Program received signal SIGABRT, Aborted.
0xb7fdd424 in __kernel_vsyscall ()
(gdb) bt
#0 0xb7fdd424 in __kernel_vsyscall ()
#1 0xb7d3224f in raise () from /lib/libc.so.6
#2 0xb7d33b53 in abort () from /lib/libc.so.6
#3 0xb7d75c59 in __malloc_assert () from /lib/libc.so.6
#4 0xb7d7890c in _int_malloc () from /lib/libc.so.6
#5 0xb7d7a6a8 in malloc () from /lib/libc.so.6
#6 0xb7b2d4cc in default_malloc_ex () from /usr/lib/libcrypto.so.1.0.0
#7 0xb7b2db7e in CRYPTO_malloc () from /usr/lib/libcrypto.so.1.0.0
#8 0xb7bb48dc in lh_new () from /usr/lib/libcrypto.so.1.0.0
#9 0xb7b3110c in OBJ_NAME_init () from /usr/lib/libcrypto.so.1.0.0
#10 0xb7b315f5 in OBJ_NAME_add () from /usr/lib/libcrypto.so.1.0.0
#11 0xb7bc2ff1 in EVP_add_cipher () from /usr/lib/libcrypto.so.1.0.0
#12 0xb7bc86d3 in OpenSSL_add_all_ciphers () from /usr/lib/libcrypto.so.1.0.0
#13 0xb7faf56c in luaopen_openssl (L=0x8074008) at src/openssl.c:809
#14 0x0804f867 in ?? ()
#15 0x0804fc8b in ?? ()
#16 0x0804d2a7 in lua_call ()
#17 0x0806853a in ?? ()
#18 0x0804f867 in ?? ()
#19 0x0805918b in ?? ()
#20 0x0804fce8 in ?? ()
#21 0x0804bd90 in _start ()

@zhaozg
Copy link
Owner

zhaozg commented May 24, 2012

@bfg @miko

I send this bugs to lua-mailing list, I hope this will help use to solve it.

@zhaozg
Copy link
Owner

zhaozg commented Aug 23, 2014

test pass 4aa7972

@zhaozg zhaozg closed this as completed Aug 23, 2014
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

3 participants