Jump to page: 1 2
Thread overview
vibe.d - cannot allocate memory in static TLS block
Aug 27, 2015
ddos
Aug 27, 2015
Rikki Cattermole
Aug 27, 2015
ddos
Aug 27, 2015
John Colvin
Aug 27, 2015
John Colvin
Aug 27, 2015
ddos
Aug 27, 2015
ddos
Aug 27, 2015
John Colvin
Aug 27, 2015
ddos
Aug 27, 2015
John Colvin
Aug 27, 2015
ddos
Aug 27, 2015
ddos
Aug 27, 2015
ddos
Aug 28, 2015
ddos
August 27, 2015
when i import the vibe.d module my project it dies with the error message "cannot allocate memory in static TLS block"

compiled as dynamic library on debian x86

"name": "alice",
"description": "A minimal D application.",
"copyright": "Copyright © 2015, dom",
"authors": ["dom"],
"targetType": "dynamicLibrary",
"dflags": ["-fPIC"],
"dependencies": {
	"ddbc": "~>0.2.24",
	"zmqd": "~>1.0.0-alpha",
	"msgpack-rpc": "~>0.1.1",
        "vibe-d": "~>0.7.19"
}

import vibe.d; is enough to cause the error
i don't really know what TLS is, but can i avoid it somehow?

rgds, dominik
August 27, 2015
On 27/08/15 9:06 PM, ddos wrote:
> when i import the vibe.d module my project it dies with the error
> message "cannot allocate memory in static TLS block"
>
> compiled as dynamic library on debian x86
>
> "name": "alice",
> "description": "A minimal D application.",
> "copyright": "Copyright © 2015, dom",
> "authors": ["dom"],
> "targetType": "dynamicLibrary",
> "dflags": ["-fPIC"],
> "dependencies": {
>      "ddbc": "~>0.2.24",
>      "zmqd": "~>1.0.0-alpha",
>      "msgpack-rpc": "~>0.1.1",
>          "vibe-d": "~>0.7.19"
> }
>
> import vibe.d; is enough to cause the error
> i don't really know what TLS is, but can i avoid it somehow?
>
> rgds, dominik

TLS = Thread Local Memory.

Also 0.7.19 is quite an old version of vibe.d.
Perhaps try 0.7.24 which is the last stable release (0.7.25 is in alpha according to git tags).
August 27, 2015
On Thursday, 27 August 2015 at 09:10:59 UTC, Rikki Cattermole wrote:
> Perhaps try 0.7.24 which is the last stable release (0.7.25 is in alpha according to git tags).

thx rikki, but sadly the newer version didn't solve my problems
August 27, 2015
On Thursday, 27 August 2015 at 09:06:54 UTC, ddos wrote:
> when i import the vibe.d module my project it dies with the error message "cannot allocate memory in static TLS block"
>
> compiled as dynamic library on debian x86
>
> "name": "alice",
> "description": "A minimal D application.",
> "copyright": "Copyright © 2015, dom",
> "authors": ["dom"],
> "targetType": "dynamicLibrary",
> "dflags": ["-fPIC"],
> "dependencies": {
> 	"ddbc": "~>0.2.24",
> 	"zmqd": "~>1.0.0-alpha",
> 	"msgpack-rpc": "~>0.1.1",
>         "vibe-d": "~>0.7.19"
> }
>
> import vibe.d; is enough to cause the error
> i don't really know what TLS is, but can i avoid it somehow?
>
> rgds, dominik

Firstly, try with up-to-date vibe.d and zmqd.

What happens if you remove some of those dependencies? If you remove targetType dynamicLibrary? Is it just vibe.d on it's own that is causing the problem, or is it a combination?
August 27, 2015
On Thursday, 27 August 2015 at 11:33:02 UTC, John Colvin wrote:
> On Thursday, 27 August 2015 at 09:06:54 UTC, ddos wrote:
>> when i import the vibe.d module my project it dies with the error message "cannot allocate memory in static TLS block"
>>
>> compiled as dynamic library on debian x86
>>
>> "name": "alice",
>> "description": "A minimal D application.",
>> "copyright": "Copyright © 2015, dom",
>> "authors": ["dom"],
>> "targetType": "dynamicLibrary",
>> "dflags": ["-fPIC"],
>> "dependencies": {
>> 	"ddbc": "~>0.2.24",
>> 	"zmqd": "~>1.0.0-alpha",
>> 	"msgpack-rpc": "~>0.1.1",
>>         "vibe-d": "~>0.7.19"
>> }
>>
>> import vibe.d; is enough to cause the error
>> i don't really know what TLS is, but can i avoid it somehow?
>>
>> rgds, dominik
>
> Firstly, try with up-to-date vibe.d and zmqd.
>
> What happens if you remove some of those dependencies? If you remove targetType dynamicLibrary? Is it just vibe.d on it's own that is causing the problem, or is it a combination?

P.S. this would be better asked in http://forum.dlang.org/group/learn or http://forum.rejectedsoftware.com
August 27, 2015
On Thursday, 27 August 2015 at 11:34:36 UTC, John Colvin wrote:
> P.S. this would be better asked in http://forum.dlang.org/group/learn or http://forum.rejectedsoftware.com

made a thread before on the vibe forum too, see here http://forum.rejectedsoftware.com/groups/rejectedsoftware.vibed/thread/26343/

On Thursday, 27 August 2015 at 11:34:36 UTC, John Colvin wrote:
> Firstly, try with up-to-date vibe.d and zmqd.
> What happens if you remove some of those dependencies? If you remove targetType dynamicLibrary? Is it just vibe.d on it's own that is causing the problem, or is it a combination?

thx for the input, i've pulled out a smaller testing example from my codebase using only vibe as a dependency. if i compile this code as executable everything works as expected. Compiling it as a dynamicLibrary fails when the library is loaded.

if this is of any help, that is the program the shared library is loaded into
https://github.com/IceNinjaman/CoD4X17a_testing/
the used compile script: https://github.com/IceNinjaman/CoD4X17a_testing/blob/master/build_cod4x17a_elf_nopunkbuster.sh

{
  "name": "vibefailtest",
  "description": "A minimal D application.",
  "copyright": "Copyright © 2015, vagrant",
  "authors": ["vagrant"],
  "targetType": "dynamicLibrary",
  "dependencies": {
    "vibe-d": "~>0.7.25-alpha.1",
  },
  "versions": ["VibeCustomMain"]
}

import std.stdio;
import vibe.d;

struct version_t
{
    int major;
    int minor;
}

align(1) struct pluginInfo_t{             // To be used in OnInfoRequest
align(1):
    version_t handlerVersion; // Requested plugin handler version - mandatory field
    version_t pluginVersion;  // Version of your plugin - optional
    char[64] fullName;        // Full plugin name, short name is the filename without extension - optional
    char[128] shortDescription; // Describe in a few words what this plugin does - optional
    char[1024] longDescription; // Full description - optional
}

extern (C) void OnInfoRequest(pluginInfo_t *info)
{
  info.handlerVersion = version_t(2, 302);
  info.pluginVersion = version_t(0, 1);
}

extern (C) int OnInit()
{
  printf(">>>>>>>> init\n");
  return 0;
}

void main(){
  OnInit();
}
August 27, 2015
removing the import vibe.d is enough to make it work as a shared library
August 27, 2015
On Thursday, 27 August 2015 at 13:08:18 UTC, ddos wrote:
> On Thursday, 27 August 2015 at 11:34:36 UTC, John Colvin wrote:
>> P.S. this would be better asked in http://forum.dlang.org/group/learn or http://forum.rejectedsoftware.com
>
> made a thread before on the vibe forum too, see here http://forum.rejectedsoftware.com/groups/rejectedsoftware.vibed/thread/26343/
>
> On Thursday, 27 August 2015 at 11:34:36 UTC, John Colvin wrote:
>> Firstly, try with up-to-date vibe.d and zmqd.
>> What happens if you remove some of those dependencies? If you remove targetType dynamicLibrary? Is it just vibe.d on it's own that is causing the problem, or is it a combination?
>
> thx for the input, i've pulled out a smaller testing example from my codebase using only vibe as a dependency. if i compile this code as executable everything works as expected. Compiling it as a dynamicLibrary fails when the library is loaded.
>
> if this is of any help, that is the program the shared library is loaded into
> https://github.com/IceNinjaman/CoD4X17a_testing/
> the used compile script: https://github.com/IceNinjaman/CoD4X17a_testing/blob/master/build_cod4x17a_elf_nopunkbuster.sh
>
> {
>   "name": "vibefailtest",
>   "description": "A minimal D application.",
>   "copyright": "Copyright © 2015, vagrant",
>   "authors": ["vagrant"],
>   "targetType": "dynamicLibrary",
>   "dependencies": {
>     "vibe-d": "~>0.7.25-alpha.1",
>   },
>   "versions": ["VibeCustomMain"]
> }
>
> import std.stdio;
> import vibe.d;
>
> struct version_t
> {
>     int major;
>     int minor;
> }
>
> align(1) struct pluginInfo_t{             // To be used in OnInfoRequest
> align(1):
>     version_t handlerVersion; // Requested plugin handler version - mandatory field
>     version_t pluginVersion;  // Version of your plugin - optional
>     char[64] fullName;        // Full plugin name, short name is the filename without extension - optional
>     char[128] shortDescription; // Describe in a few words what this plugin does - optional
>     char[1024] longDescription; // Full description - optional
> }
>
> extern (C) void OnInfoRequest(pluginInfo_t *info)
> {
>   info.handlerVersion = version_t(2, 302);
>   info.pluginVersion = version_t(0, 1);
> }
>
> extern (C) int OnInit()
> {
>   printf(">>>>>>>> init\n");
>   return 0;
> }
>
> void main(){
>   OnInit();
> }

I think your problem is that you need to initialise the D runtime. Perhaps adding a call to http://dlang.org/phobos/core_runtime.html#.Runtime.initialize inside OnInit will solve it for you. Also, remember to terminate the runtime when the plugin is unloaded.
August 27, 2015
On Thursday, 27 August 2015 at 15:16:25 UTC, John Colvin wrote:
> I think your problem is that you need to initialise the D runtime. Perhaps adding a call to http://dlang.org/phobos/core_runtime.html#.Runtime.initialize inside OnInit will solve it for you. Also, remember to terminate the runtime when the plugin is unloaded.

i thought about that too, but that wasn't the case ( unless i fucked something up ). nothing from my example gets executed, the crash happens i think when the library is loaded. just in case i've also added runtime.initialize also to the vibe main. also if the runtime.initialize would be missing that would mean my executable example should crash, but the executable test works just fine.
August 27, 2015
On Thursday, 27 August 2015 at 15:40:20 UTC, ddos wrote:
> On Thursday, 27 August 2015 at 15:16:25 UTC, John Colvin wrote:
>> I think your problem is that you need to initialise the D runtime. Perhaps adding a call to http://dlang.org/phobos/core_runtime.html#.Runtime.initialize inside OnInit will solve it for you. Also, remember to terminate the runtime when the plugin is unloaded.
>
> i thought about that too, but that wasn't the case ( unless i fucked something up ). nothing from my example gets executed, the crash happens i think when the library is loaded.

Ok, yes, that isn't it then.

> just in case i've also added runtime.initialize also to the vibe main. also if the runtime.initialize would be missing that would mean my executable example should crash, but the executable test works just fine.

Unless I misunderstand what you're doing, the executable test would be initialising the runtime anyway, it's put in by the compiler when building an executable.


The only other thing I can think of is: have you tried removing the main from your code, while still defining VibeCustomMain?
« First   ‹ Prev
1 2