Comment 7 for bug 1136432

Revision history for this message
Alexey Brodkin (alexey-brodkin) wrote :

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.