Luckily I found out that this issue was caused by 1 special .so I had loaded 
automatically with LD_PRELOAD.
It was "libusb-driver.so" used by Xilinx Impact tool for communication with 
JTAG.
So with this library preloaded this simple test (built with "gcc test.c") 
crashes on the second "getc":
=========
#include <stdio.h>
char * filename = "luac.out";

int main (void)
{
        FILE* f;
        int c;

        f = fopen(filename, "r");
        if (f == NULL) {
                printf("Cannot open file %s\n", filename);
                return -1;
        }
        printf("File %s opened successfully\n", filename);
        c = getc(f);
        printf("c: %x\n", c);

        f = freopen(filename, "rb", f);
        if (f == NULL) {
                printf("Cannot re-open file %s in binary mode\n", filename);
                return -1;
        }
        printf("File %s re-opened in binary mode successfully\n", filename);
        c = getc(f);
        printf("c: %x\n", c);

        if (filename)
                fclose(f);
        return 0;
}
=========

If I disable library preload application gets executed without problems.
Moreover if I build this test statically everything will work as well.

So it is definitely not a problem in Lua.
Might be eglibc or dynamic linker.

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1136432

Title:
  luaL_loadfile segfault in _IO_file_underflow

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/lua5.1/+bug/1136432/+subscriptions

-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to