0

I have a library "libqscr.so", that I load into my program during the runtime using dlopen. It was working perfectly, after I rebooted my PC, dlopen started giving me this error:

*** Error in `/path/to/program': realloc(): invalid pointer: 0xbfffef5c ***

I've tried recompiling the library, but the problem remains. I've noticed that it only occurs when the path is correct, otherwise, null is returned. BTW, I'm running all this on Ubuntu 14.04.

EDIT: I noticed that this issue only happens with that specific library, others load fine.

EDIT2: So I've tracked the issue to the library, and even the function which is causing it. I've noticed that if I removed the setLength function, everything starts working fine:

alias Tqarray = Tqvar[];
Tqarray[string] vals;
struct Tqvar{
    string s;
    double d;
    bool ii = true;
}

Tqvar setLength(Tqlist args){
    Tqvar r = args.read(0);
    vals[r.s].length=to!uint(trunc(args.read(1).d));
    return r;
}

Any ideas why this is happening?

Yet another EDIT(3): I removed the trunc function call, and it is all working now. Any answer explaining why it is happening, I'll accept.

Max Alibaev
  • 681
  • 7
  • 17
Nafees
  • 509
  • 4
  • 16
  • Well if other libraries load fine, then it's probably the library itself that implements something invalid. Did you compile the library youself? – Bauss May 21 '16 at 08:29
  • I didn't even change a line in the library, it just stopped working, don't know why. – Nafees May 21 '16 at 08:30
  • Are the architectures compatible (Library and your application.) and how do you call it? There's a lot of factors that could cause such issues. – Bauss May 21 '16 at 08:31
  • Yes, both compiled/targetted at same architectures. compiled through DMD2. And I use extern(C) to export the functions. – Nafees May 21 '16 at 08:32
  • Well it most likely isn't when it loads, considering it complains about "realloc()" chances are you try to reallocate on a pointer that is freed. Just a guess, but from the error message it could be something like that – Bauss May 21 '16 at 08:34
  • 1
    Bauss, you were right, If I compile library in Release config, it just says segmentation fault, so something is wrong in the library. – Nafees May 21 '16 at 08:44

0 Answers0