Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8310483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T19:28:36+00:00 2026-06-08T19:28:36+00:00

Edit: this seems to be a longrunning issue with no imminent solution: http://d.puremagic.com/issues/show_bug.cgi?id=8133 http://www.digitalmars.com/d/archives/digitalmars/D/Ideas_for_runtime_loading_of_shared_libraries._154126.html

  • 0

Edit: this seems to be a longrunning issue with no imminent solution:
http://d.puremagic.com/issues/show_bug.cgi?id=8133
http://www.digitalmars.com/d/archives/digitalmars/D/Ideas_for_runtime_loading_of_shared_libraries._154126.html
http://lists.puremagic.com/pipermail/dmd-internals/2011-December/002853.html

There seems to be a problem with starting the d runtime in a d dylib loaded in a c program. Whenever I call Runtime.initialize() i get a segfault.

C code:

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

int main() {
    void *library;
    int (*fptr)();
    library = dlopen("testlib.dylib", RTLD_LAZY);
    if(library == NULL)
        puts("couldn't load the library");
    else {
        *(void **)(&fptr) = dlsym(library,"number");
        if(fptr == NULL) {
        puts("couldn't load function");
        } 
        else {
            printf("the result is %d\n",(*fptr)());
        }
    }
    return(0);
}

compiled with gcc, no flags.

d code:

import core.runtime;

extern(C) int number() {
    Runtime.initialize();
    return(4);
}

compiled with dmd -shared

Backtrace:

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: 13 at address: 0x0000000000000000
0x000000010003de28 in __tls_get_addr ()
(gdb) bt
#0  0x000000010003de28 in __tls_get_addr ()
#1  0x000000010003cdfc in thread_attachThis ()
#2  0x000000010003ccb8 in thread_init ()
#3  0x000000010003e312 in gc_init ()
#4  0x0000000100044ff5 in rt_init ()
#5  0x000000010003b637 in D4core7runtime7Runtime10initializeFDFC6object9ThrowableZvZb ()
#6  0x0000000100034ee9 in number ()
#7  0x0000000100000e84 in main ()

All compilation and debugging done in OS X 10.7

Note: if the Runtime.initialize(); line is commented out, the library is loaded and runs correctly.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T19:28:38+00:00Added an answer on June 8, 2026 at 7:28 pm

    This is now fixed in the latest druntime from github

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This seems like such a simple question. I have several Edit boxes on my
EDIT: This issue is already submitted on Github. Changing the Act part to this
EDIT: This seems to be a problem with IE exclusively. Very simple to re-create,
Edit For VB 6 End Edit Hey this seems like it should be an
Working through this for fun: http://www.diku.dk/hjemmesider/ansatte/torbenm/Basics/ Example calculation of nullable and first uses a
EDIT: This seems to be happening on all pages on my application with any
Edit: This problem was down to me passing the wrong view to the Touch
edit This question is solved! Having something weird. I'm using html { font-size: 100%
Edit: this question is outdated. The jsonlite package flattens automatically. I am dealing with
EDIT: This post was originally specific to ASP.NET, but after thinking about it I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.