praveenvvstgy / crack-language

Automatically exported from code.google.com/p/crack-language
Other
0 stars 0 forks source link

Compiler aborts on Ubuntu 12.04 #96

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
This is on 64bit.

As of version 21dbd579e541 on 2/20 I get this whenever the crack or crackc 
binaries are run:

$> ./crack -l lib test/test_math.crk
terminate called after throwing an instance of 'spug::Exception'
  what():  std::exception
Aborted (core dumped)

The gdb backtrace:
Starting program: /home/conrad/Download/crack-language/crack-language-tip/crack 
-l lib test/test_math.crk
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
terminate called after throwing an instance of 'spug::Exception'
  what():  std::exception

Program received signal SIGABRT, Aborted.
0x00007ffff63e5475 in __GI_raise (sig=<optimized out>)
    at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
64  ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0  0x00007ffff63e5475 in __GI_raise (sig=<optimized out>)
    at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#1  0x00007ffff63e8bdb in __GI_abort () at abort.c:91
#2  0x00007ffff6a3769d in __gnu_cxx::__verbose_terminate_handler() ()
   from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#3  0x00007ffff6a35846 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#4  0x00007ffff6a35873 in std::terminate() ()
   from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#5  0x00007ffff6a3596e in __cxa_throw ()
   from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#6  0x00007ffff727ad8f in builder::mvll::LLVMBuilder::createExternFunc (
    this=0x75eee0, context=..., flags=model::FuncDef::noFlags, name=..., 
    returnType=0x619ef0, receiverType=0x0, args=..., cfunc=0x7ffff5ecec50, 
    symbolName=0x0)
    at /home/conrad/Download/crack-language/crack-language-tip/builder/llvm/LLVMBuilder.cc:1495
#7  0x00007ffff71f7473 in crack::ext::Func::finish (this=0x7ec900)
    at /home/conrad/Download/crack-language/crack-language-tip/ext/Func.cc:101
#8  0x00007ffff71f20ef in crack::ext::Module::finish (this=0x7fffffffd2d0)
    at /home/conrad/Download/crack-language/crack-language-tip/ext/Module.cc:169
#9  0x00007ffff7202cb3 in model::Construct::initExtensionModule (
    this=0x612cd0, canonicalName=..., compileFunc=
    0x7ffff5c94ff3 <crack_runtime_cinit(crack::ext::Module*)>, 
    initFunc=0x7ffff5c94fed <crack_runtime_rinit()>)
    at /home/conrad/Download/crack-language/crack-language-tip/model/Construct.cc:317
#10 0x00007ffff720306a in model::Construct::loadSharedLib (this=0x612cd0, 
    path=..., moduleNameBegin=..., moduleNameEnd=..., canonicalName=...)
    at /home/conrad/Download/crack-language/crack-language-tip/model/Construct.cc:367
#11 0x00007ffff72039b7 in model::Construct::loadModule (this=0x612cd0, 
    moduleNameBegin=..., moduleNameEnd=..., canonicalName=...)
    at /home/conrad/Download/crack-language/crack-language-tip/model/Construct.cc:460
#12 0x00007ffff7201d0b in model::Construct::loadBuiltinModules (this=0x612cd0)
    at /home/conrad/Download/crack-language/crack-language-tip/model/Construct.cc:238
#13 0x00007ffff7301dc3 in Crack::init (this=0x7fffffffdce0)
    at /home/conrad/Download/crack-language/crack-language-tip/Crack.cc:81
#14 0x00007ffff7301ef8 in Crack::runScript (this=0x7fffffffdce0, src=..., 
    name=...)
    at /home/conrad/Download/crack-language/crack-language-tip/Crack.cc:91
#15 0x0000000000408ead in main (argc=4, argv=0x7fffffffe108)
    at /home/conrad/Download/crack-language/crack-language-tip/crack_main.cc:256

Original issue reported on code.google.com by Conrad.S...@gmail.com on 20 Feb 2012 at 5:47

Attachments:

GoogleCodeExporter commented 9 years ago
Another data point: dladdr() fails when it tries to load the math functions for 
double precision numbers.

If I print out functions getting registered in Math.cc, I get e.g.
Added function sin64(angle)=0x7faa5f74ec50

and then in LLVMBuilder::createExternFunc:

Looking up function sin64: 0x7faa5f74ec50
Unable to locate symbol for extern function: sin64

Original comment by Conrad.S...@gmail.com on 9 Mar 2012 at 9:10

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
A simple demonstration looks like this:

module.cc:

#include <math.h>
#include <stdio.h>

typedef double (OneFuncDouble)(double);
OneFuncDouble *one_funcs_double[]= { sin, cos, tan, NULL };

extern "C" {
    void **module_init(){
        static void* func_array[4];

        for (int i=0; i<4; i++){
            func_array[i] = (void*)one_funcs_double[i];
            if (one_funcs_double[i])
                printf("Registering symbol %p\n", (void*)one_funcs_double[i]);
        }

        return func_array;
    }
}

main.cc:

#include <dlfcn.h>
#include <stdio.h>

typedef void **(init_func)();

void **test_init(){
    static void *retval[] = {NULL};
    return retval;
}

int main(int argc, char **argv){
    void *module = dlopen("module.so", RTLD_NOW);
    init_func *myfunc;
    myfunc = &test_init;

    if (module){
        init_func *module_init = (init_func *)dlsym(module, "module_init");
        void **func_array = module_init();
        Dl_info symInfo;
        for (int i=0; func_array[i]; i++){
            if (dladdr(func_array[i], &symInfo)){
                if (symInfo.dli_sname)
                    printf("Found symbol %s\n", symInfo.dli_fname, symInfo.dli_sname);
                else
                    printf("ERROR: symbol for %p not found\n", func_array[i]);
            }
        }
    }
    else printf("Failed to load module\n");

    return 0;
}

Makefile:

all: module.so test_module

test_module: main.o
    g++ -fPIC $< -o $@ -ldl

module.o: module.cc
    g++ -fPIC -c $< -o $@

module.so: module.o
    g++ -fPIC -shared -Wl,-soname,module.so -o $@ $<

Original comment by Conrad.S...@gmail.com on 16 Mar 2012 at 4:58

GoogleCodeExporter commented 9 years ago

Original comment by Conrad.S...@gmail.com on 23 May 2012 at 6:28