Re: Program exited with code -11 when calling

2020-06-30 Thread Anthony via Digitalmars-d-learn

On Wednesday, 1 July 2020 at 05:47:16 UTC, Anthony wrote:

On Wednesday, 1 July 2020 at 05:33:48 UTC, H. S. Teoh wrote:
On Wed, Jul 01, 2020 at 05:04:28AM +, Anthony via 
Digitalmars-d-learn wrote: [...]

auto str_utf8 = str.toUTF8();
bson_error_t error

auto bson = bson_new_from_json(cast(const 
uint8_t*)str_utf8.ptr, -1,

&error);


I get a "Program exited with code -11" message.
Does anyone know what I'm doing wrong?


D strings are generally not null-terminated (except for 
literals). Before passing them to a C function you need to add 
a trailing null. Try using std.conv.toStringz instead of 
casting the pointer yourself.



T


Thanks H. S. Teoh.
Hmm, still same result though.


import std.string;

auto str = toStringz("{\"a\":1}");

bson_error_t error;

bson_new_from_json(str, -1, &error);




extern(C) {
...
bson_t* bson_new_from_json(const char* data, long len, 
bson_error_t* error);

}


Noob mistake:
I declared an array that should be of fixed size.

struct bson_error_t {

char[] message;
};

Should be:

struct bson_error_t {

char[504] message;
};

:/


Re: Program exited with code -11 when calling

2020-06-30 Thread Kagamin via Digitalmars-d-learn
bson_t* bson_new_from_json(in char* data, long len, bson_error_t* 
error);


string str_utf8 = "{\"a\":1}";
bson_error_t error;

auto bson = bson_new_from_json(str_utf8.ptr, str_utf8.length, 
&error);


You have a wrong declaration for bson_error_t too.


Re: Program exited with code -11 when calling

2020-06-30 Thread Anthony via Digitalmars-d-learn

On Wednesday, 1 July 2020 at 05:33:48 UTC, H. S. Teoh wrote:
On Wed, Jul 01, 2020 at 05:04:28AM +, Anthony via 
Digitalmars-d-learn wrote: [...]

auto str_utf8 = str.toUTF8();
bson_error_t error

auto bson = bson_new_from_json(cast(const 
uint8_t*)str_utf8.ptr, -1,

&error);


I get a "Program exited with code -11" message.
Does anyone know what I'm doing wrong?


D strings are generally not null-terminated (except for 
literals). Before passing them to a C function you need to add 
a trailing null. Try using std.conv.toStringz instead of 
casting the pointer yourself.



T


Thanks H. S. Teoh.
Hmm, still same result though.


import std.string;

auto str = toStringz("{\"a\":1}");

bson_error_t error;

bson_new_from_json(str, -1, &error);




extern(C) {
...
bson_t* bson_new_from_json(const char* data, long len, 
bson_error_t* error);

}


Re: Program exited with code -11 when calling

2020-06-30 Thread Anthony via Digitalmars-d-learn

On Wednesday, 1 July 2020 at 05:09:47 UTC, Cym13 wrote:

On Wednesday, 1 July 2020 at 05:04:28 UTC, Anthony wrote:

I'm trying to convert this c function:

bson_t *bson_new_from_json (const uint8_t *data, ssize_t len, 
bson_error_t *error);



Into a D function. This is my attempt:
extern(C) {
struct bson_t;
struct bson_error_t;

bson_t* bson_new_from_json(const uint8_t* data, long len, 
bson_error_t* error);

}

However when I try it, for example:

auto str_utf8 = str.toUTF8();
bson_error_t error

auto bson = bson_new_from_json(cast(const 
uint8_t*)str_utf8.ptr, -1, &error);



I get a "Program exited with code -11" message.
Does anyone know what I'm doing wrong?

Thanks


I don't know the exact function you are trying to use, but -11 
means "segmentation fault" on linux. This means that your 
program is trying to read or write a memory location that it is 
not supposed to. This typically happens during buffer overflows 
and similar memory corruption bugs.


One thing that jumps to me is the -1 in your call instead of 
the length. Without knowing the C function's implementation I 
would expect it to mean either "read before the array" which 
would be a buffer overflow or to have the special meaning of 
"deduce the string size yourself". In that last case I would 
expect bson_new_from_json to expect a NUL-terminated array, but 
I don't know if your UTF8 array is NUL-terminated.



Thanks for getting back to me.

Yeah I figured it was a segmentation fault, however, I don't know 
exactly how to pinpoint where this is happening. I'm wondering if 
there's anything wrong with how I'm casting the data since 
everything is self contained (assuming bson_new_from_json is 
correct since it works using c directly).


void foo() {
import std.utf;
import core.stdc.stdint;

auto str_utf8 = "{\"a\":1}";
bson_error_t error;

bson_new_from_json(cast(uint8_t*)str_utf8, 
(cast(uint8_t[])str_utf8).length, &error);

}



Re -1 in the call: Apparently it uses strlen() to deduce the 
size. However, I tried explicitly state the array length but had 
no luck.





Re: Program exited with code -11 when calling

2020-06-30 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Jul 01, 2020 at 05:04:28AM +, Anthony via Digitalmars-d-learn wrote:
[...]
> auto str_utf8 = str.toUTF8();
> bson_error_t error
> 
> auto bson = bson_new_from_json(cast(const uint8_t*)str_utf8.ptr, -1,
> &error);
> 
> 
> I get a "Program exited with code -11" message.
> Does anyone know what I'm doing wrong?

D strings are generally not null-terminated (except for literals).
Before passing them to a C function you need to add a trailing null. Try
using std.conv.toStringz instead of casting the pointer yourself.


T

-- 
A programming language should be a toolbox for the programmer to draw upon, not 
a minefield of dangerous explosives that you have to very carefully avoid 
touching in the wrong way.


Re: Program exited with code -11 when calling

2020-06-30 Thread Cym13 via Digitalmars-d-learn

On Wednesday, 1 July 2020 at 05:04:28 UTC, Anthony wrote:

I'm trying to convert this c function:

bson_t *bson_new_from_json (const uint8_t *data, ssize_t len, 
bson_error_t *error);



Into a D function. This is my attempt:
extern(C) {
struct bson_t;
struct bson_error_t;

bson_t* bson_new_from_json(const uint8_t* data, long len, 
bson_error_t* error);

}

However when I try it, for example:

auto str_utf8 = str.toUTF8();
bson_error_t error

auto bson = bson_new_from_json(cast(const 
uint8_t*)str_utf8.ptr, -1, &error);



I get a "Program exited with code -11" message.
Does anyone know what I'm doing wrong?

Thanks


I don't know the exact function you are trying to use, but -11 
means "segmentation fault" on linux. This means that your program 
is trying to read or write a memory location that it is not 
supposed to. This typically happens during buffer overflows and 
similar memory corruption bugs.


One thing that jumps to me is the -1 in your call instead of the 
length. Without knowing the C function's implementation I would 
expect it to mean either "read before the array" which would be a 
buffer overflow or to have the special meaning of "deduce the 
string size yourself". In that last case I would expect 
bson_new_from_json to expect a NUL-terminated array, but I don't 
know if your UTF8 array is NUL-terminated.


Program exited with code -11 when calling

2020-06-30 Thread Anthony via Digitalmars-d-learn

I'm trying to convert this c function:

bson_t *bson_new_from_json (const uint8_t *data, ssize_t len, 
bson_error_t *error);



Into a D function. This is my attempt:
extern(C) {
struct bson_t;
struct bson_error_t;

bson_t* bson_new_from_json(const uint8_t* data, long len, 
bson_error_t* error);

}

However when I try it, for example:

auto str_utf8 = str.toUTF8();
bson_error_t error

auto bson = bson_new_from_json(cast(const uint8_t*)str_utf8.ptr, 
-1, &error);



I get a "Program exited with code -11" message.
Does anyone know what I'm doing wrong?

Thanks



Re: Program exited with code -11

2019-09-18 Thread Adam D. Ruppe via Digitalmars-d-learn

On Wednesday, 18 September 2019 at 13:36:30 UTC, Arjan wrote:

On Wednesday, 18 September 2019 at 13:22:03 UTC, Danny Arends

"Program exited with code -11"


Not signal 11? On unix/linux I assume?


Same thing. This is a segmentation fault.

Compile the program with the -g switch to dmd, then run it inside 
the gdb program



gdb --args ./your_program any_args_to_your_program

the hit the "r" command to run and when it crashes, it will tell 
you where. probably a null pointer.


Re: Program exited with code -11

2019-09-18 Thread Danny Arends via Digitalmars-d-learn

On Wednesday, 18 September 2019 at 13:36:30 UTC, Arjan wrote:
On Wednesday, 18 September 2019 at 13:22:03 UTC, Danny Arends 
wrote:

Hey all,

"Program exited with code -11"


Not signal 11? On unix/linux I assume?


It's on linux yes...

No idea if it is a signal or an exitcode, the only indication is 
the text:

"Program exited with code -11"



Re: Program exited with code -11

2019-09-18 Thread Arjan via Digitalmars-d-learn
On Wednesday, 18 September 2019 at 13:22:03 UTC, Danny Arends 
wrote:

Hey all,

"Program exited with code -11"


Not signal 11? On unix/linux I assume?




Program exited with code -11

2019-09-18 Thread Danny Arends via Digitalmars-d-learn

Hey all,

I have written some code to analyze massive gzipped files (using 
std.iopipe), tested it on small subsets of the gzip files, and 
everything works using small 20 to 50 Mb files.


However when I try to run the code on 2.7 Gb file sizes the 
program always crashes with the following error:


"Program exited with code -11"

No other messages, did anyone ever encounter something like this 
before / got any ideas on how to figure out what is wrong ?


Danny




Re: Program exited with code -11

2015-11-26 Thread Alex via Digitalmars-d-learn
On Thursday, 26 November 2015 at 08:15:02 UTC, Rikki Cattermole 
wrote:
You forgot to load the pointers to the functions in the shared 
library :)


https://github.com/DerelictOrg/DerelictSFML2


OMG. I am embarrassed. Thank you very much.


Re: Program exited with code -11

2015-11-26 Thread Rikki Cattermole via Digitalmars-d-learn

On 26/11/15 9:12 PM, Alex wrote:

Hello guys.

I am beginner with D and a hobbyist in general when it comes to
programming. I am following an SFML tutorial in C++ and trying to
"translate it" to D (at least the parts I think I understand). I am
using Derelict SFML2 bindgings to CSFML.

First I tried to do it procedural way and it works fine:

http://pastebin.com/6PjRCUHp

Then I tried an OOP way as per tutorial:

app.d =

module app;
import notquiteciv.game;

void main()
{
 Game game = new Game();

 game.gameLoop();
}

game.d = http://pastebin.com/ps9mMxGf

When I run "dub run" or "dub run --force", I get this:

Running ./notquiteciv
Program exited with code -11

$ lldb ./notquiteciv (run)

Process 81278 launched: './notquiteciv' (x86_64)
Process 81278 stopped
* thread #1: tid = 0x14dae3, 0x, queue =
'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
 frame #0: 0x
error: memory read failed for 0x0

I am stuck. Can you give me a hint regarding this?

Thank you.



You forgot to load the pointers to the functions in the shared library :)

https://github.com/DerelictOrg/DerelictSFML2


Program exited with code -11

2015-11-26 Thread Alex via Digitalmars-d-learn

Hello guys.

I am beginner with D and a hobbyist in general when it comes to 
programming. I am following an SFML tutorial in C++ and trying to 
"translate it" to D (at least the parts I think I understand). I 
am using Derelict SFML2 bindgings to CSFML.


First I tried to do it procedural way and it works fine:

http://pastebin.com/6PjRCUHp

Then I tried an OOP way as per tutorial:

app.d =

module app;
import notquiteciv.game;

void main()
{
Game game = new Game();

game.gameLoop();
}

game.d = http://pastebin.com/ps9mMxGf

When I run "dub run" or "dub run --force", I get this:

Running ./notquiteciv
Program exited with code -11

$ lldb ./notquiteciv (run)

Process 81278 launched: './notquiteciv' (x86_64)
Process 81278 stopped
* thread #1: tid = 0x14dae3, 0x, queue = 
'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, 
address=0x0)

frame #0: 0x
error: memory read failed for 0x0

I am stuck. Can you give me a hint regarding this?

Thank you.


Re: Program exited with code -11

2015-06-24 Thread weaselcat via Digitalmars-d-learn

On Wednesday, 24 June 2015 at 07:52:10 UTC, Charles Hawkins wrote:

On Wednesday, 24 June 2015 at 06:54:57 UTC, weaselcat wrote:
On Tuesday, 23 June 2015 at 06:50:28 UTC, Charles Hawkins 
wrote:

[...]


you can instruct dub to use other compilers with the 
--compiler option

valid options include dmd,ldc,gdc,gdmd,ldmd


Ah, a "sort of" hidden option.  I've only been typing "dub" and 
thus, "dub --help".  Didn't think to do "dub build --help".


Is there a quick way to get gdc to recognize 
std.experimental.logger?  I'm already spoiled by it.  Choosing 
between it and a backtrace is difficult.


I believe it's available as a dub package albeit outdated, should 
be roughly similar though.


Re: Program exited with code -11

2015-06-24 Thread Charles Hawkins via Digitalmars-d-learn

On Wednesday, 24 June 2015 at 06:54:57 UTC, weaselcat wrote:

On Tuesday, 23 June 2015 at 06:50:28 UTC, Charles Hawkins wrote:

On Tuesday, 23 June 2015 at 03:31:37 UTC, weaselcat wrote:
On Tuesday, 23 June 2015 at 03:29:14 UTC, Charles Hawkins 
wrote:

[...]


Try to compile with either ldc or gdc and the -g flag, it 
should give you a backtrace. dmd seems to not like linux wrt 
backtraces.


Thanks.  I wish!  I haven't had any success in compiling with 
anything but dub.  gdc, dmd, rdmd always give me "module mylib 
is in file 'mylib.d' which cannot be read" on my "import 
mylib;" statement.  I've tried every permutation of -I and -L 
that I can think of.  It almost appears that one either uses 
dub for everything or nothing and I'm getting pretty 
frustrated with it as well.  Perhaps I should just go back to 
old-fashioned make files?


you can instruct dub to use other compilers with the --compiler 
option

valid options include dmd,ldc,gdc,gdmd,ldmd


Ah, a "sort of" hidden option.  I've only been typing "dub" and 
thus, "dub --help".  Didn't think to do "dub build --help".


Is there a quick way to get gdc to recognize 
std.experimental.logger?  I'm already spoiled by it.  Choosing 
between it and a backtrace is difficult.


Re: Program exited with code -11

2015-06-23 Thread weaselcat via Digitalmars-d-learn

On Tuesday, 23 June 2015 at 06:50:28 UTC, Charles Hawkins wrote:

On Tuesday, 23 June 2015 at 03:31:37 UTC, weaselcat wrote:
On Tuesday, 23 June 2015 at 03:29:14 UTC, Charles Hawkins 
wrote:

[...]


Try to compile with either ldc or gdc and the -g flag, it 
should give you a backtrace. dmd seems to not like linux wrt 
backtraces.


Thanks.  I wish!  I haven't had any success in compiling with 
anything but dub.  gdc, dmd, rdmd always give me "module mylib 
is in file 'mylib.d' which cannot be read" on my "import 
mylib;" statement.  I've tried every permutation of -I and -L 
that I can think of.  It almost appears that one either uses 
dub for everything or nothing and I'm getting pretty frustrated 
with it as well.  Perhaps I should just go back to 
old-fashioned make files?


you can instruct dub to use other compilers with the --compiler 
option

valid options include dmd,ldc,gdc,gdmd,ldmd


Re: Program exited with code -11

2015-06-23 Thread Charles Hawkins via Digitalmars-d-learn

On Tuesday, 23 June 2015 at 11:18:07 UTC, anonymous wrote:

On Tuesday, 23 June 2015 at 07:57:26 UTC, Charles Hawkins wrote:

Sigh.  I'm probably doing something stupid.  I tried full 
paths:

dmd -I+/home/charles/projects/d/mylib/source/mylib/ myprog.d


What's that plus sign doing there? Looks wrong.


/home/charles/projects/d/mylib/build/libmylib.a
Same result.
myprog.d(4) Error: module mylib is in file 'mylib.d' which 
cannot be read

Statement in myprog is:
import mylib;


Hey, I was right!  Something stupid!  I really don't think I made 
it up.  Either I copied from some example that was in error, or 
was looking at something for another language (I've been looking 
at several lately) that added to a search path.  In any event, I 
was obviously confused.


Thanks, all!  I think I'm back on track now.  In fact, I've got 
several test programs working with my library.  It isn't so large 
that compiling it every time was that big of a deal, but nice to 
know I don't have to.


Re: Program exited with code -11

2015-06-23 Thread anonymous via Digitalmars-d-learn

On Tuesday, 23 June 2015 at 07:57:26 UTC, Charles Hawkins wrote:


Sigh.  I'm probably doing something stupid.  I tried full paths:
dmd -I+/home/charles/projects/d/mylib/source/mylib/ myprog.d


What's that plus sign doing there? Looks wrong.


/home/charles/projects/d/mylib/build/libmylib.a
Same result.
myprog.d(4) Error: module mylib is in file 'mylib.d' which 
cannot be read

Statement in myprog is:
import mylib;




Re: Program exited with code -11

2015-06-23 Thread Charles Hawkins via Digitalmars-d-learn
Try to compile with either ldc or gdc and the -g flag, it 
should give you a backtrace. dmd seems to not like linux wrt 
backtraces.


...I haven't had any success in compiling with anything but 
dub.  gdc, dmd, rdmd always give me "module mylib is in file 
'mylib.d' which cannot be read" on my "import mylib;" 
statement. ...


in dmd you have to pass
- the .lib/.a files a source
- the path to the lib source with '-I'. Sometimes when the 
path is not well indicated you get the error you talk about. 
This is because the '-I' path must follow carefully the 
structure of the lib, e.g


'import myLib.package.moduleThis':
the '-I' must point to the folder that contains the folder 
'myLib'.

...
dmd -I+/home/charles/projects/d/mylib/source/mylib/ myprog.d 
/home/charles/projects/d/mylib/build/libmylib.a

Same result.
myprog.d(4) Error: module mylib is in file 'mylib.d' which 
cannot be read

Statement in myprog is:
import mylib;
...


I used -v to imitate what dub is doing and that works, except 
that I don't see any reference to the compiled library itself.  
Apparently it is recompiling the library as well, which defeats 
the main purpose of having a library in the first place.


And gdc doesn't seem to recognize std.experimental.logger which 
is what I used in converting all my debugging code.  Sigh.


Re: Program exited with code -11

2015-06-23 Thread Baz via Digitalmars-d-learn

On Tuesday, 23 June 2015 at 07:25:05 UTC, Baz wrote:

in dmd you have to pass
- the .lib/.a files a source


I meant "as source", actually. you pass the .lib or .a file 
without switch as if it's a main source.




Re: Program exited with code -11

2015-06-23 Thread Charles Hawkins via Digitalmars-d-learn
Ok, I think I've answered my own question.  dub -v tells me what 
I need to know.  Looks like I need to do a separate compile & 
link, make file like, just like the old days, or have a very 
complicated command line.  However, if there is a simple way to 
do the above, which it seems there should be, please let me know.


Re: Program exited with code -11

2015-06-23 Thread Charles Hawkins via Digitalmars-d-learn

On Tuesday, 23 June 2015 at 07:25:05 UTC, Baz wrote:

On Tuesday, 23 June 2015 at 06:50:28 UTC, Charles Hawkins wrote:

On Tuesday, 23 June 2015 at 03:31:37 UTC, weaselcat wrote:
On Tuesday, 23 June 2015 at 03:29:14 UTC, Charles Hawkins 
wrote:
Thanks, Adam.  I'm coming from OCaml and haven't seen a seg 
fault in years.  Didn't recognize it. :D  Hopefully I can 
figure it out from here.


Try to compile with either ldc or gdc and the -g flag, it 
should give you a backtrace. dmd seems to not like linux wrt 
backtraces.


Thanks.  I wish!  I haven't had any success in compiling with 
anything but dub.  gdc, dmd, rdmd always give me "module mylib 
is in file 'mylib.d' which cannot be read" on my "import 
mylib;" statement.  I've tried every permutation of -I and -L 
that I can think of.  It almost appears that one either uses 
dub for everything or nothing and I'm getting pretty 
frustrated with it as well.  Perhaps I should just go back to 
old-fashioned make files?


in dmd you have to pass
- the .lib/.a files a source
- the path to the lib source with '-I'. Sometimes when the path 
is not well indicated you get the error you talk about. This is 
because the '-I' path must follow carefully the structure of 
the lib, e.g


'import myLib.package.moduleThis':
the '-I' must point to the folder that contains the folder 
'myLib'.


Sigh.  I'm probably doing something stupid.  I tried full paths:
dmd -I+/home/charles/projects/d/mylib/source/mylib/ myprog.d 
/home/charles/projects/d/mylib/build/libmylib.a

Same result.
myprog.d(4) Error: module mylib is in file 'mylib.d' which cannot 
be read

Statement in myprog is:
import mylib;

I used tab expansion so I'm confident everything is spelled 
correctly.  Since dub will compile it, I also tried copying and 
pasting its entry from the local packages file (leaves off the 
"source/mylib/").  Is there a way to find out what command dub is 
passing to dmd?


Re: Program exited with code -11

2015-06-23 Thread Baz via Digitalmars-d-learn

On Tuesday, 23 June 2015 at 06:50:28 UTC, Charles Hawkins wrote:

On Tuesday, 23 June 2015 at 03:31:37 UTC, weaselcat wrote:
On Tuesday, 23 June 2015 at 03:29:14 UTC, Charles Hawkins 
wrote:
Thanks, Adam.  I'm coming from OCaml and haven't seen a seg 
fault in years.  Didn't recognize it. :D  Hopefully I can 
figure it out from here.


Try to compile with either ldc or gdc and the -g flag, it 
should give you a backtrace. dmd seems to not like linux wrt 
backtraces.


Thanks.  I wish!  I haven't had any success in compiling with 
anything but dub.  gdc, dmd, rdmd always give me "module mylib 
is in file 'mylib.d' which cannot be read" on my "import 
mylib;" statement.  I've tried every permutation of -I and -L 
that I can think of.  It almost appears that one either uses 
dub for everything or nothing and I'm getting pretty frustrated 
with it as well.  Perhaps I should just go back to 
old-fashioned make files?


in dmd you have to pass
- the .lib/.a files a source
- the path to the lib source with '-I'. Sometimes when the path 
is not well indicated you get the error you talk about. This is 
because the '-I' path must follow carefully the structure of the 
lib, e.g


'import myLib.package.moduleThis':
the '-I' must point to the folder that contains the folder 
'myLib'.





Re: Program exited with code -11

2015-06-22 Thread Charles Hawkins via Digitalmars-d-learn

On Tuesday, 23 June 2015 at 03:31:37 UTC, weaselcat wrote:

On Tuesday, 23 June 2015 at 03:29:14 UTC, Charles Hawkins wrote:
Thanks, Adam.  I'm coming from OCaml and haven't seen a seg 
fault in years.  Didn't recognize it. :D  Hopefully I can 
figure it out from here.


Try to compile with either ldc or gdc and the -g flag, it 
should give you a backtrace. dmd seems to not like linux wrt 
backtraces.


Thanks.  I wish!  I haven't had any success in compiling with 
anything but dub.  gdc, dmd, rdmd always give me "module mylib is 
in file 'mylib.d' which cannot be read" on my "import mylib;" 
statement.  I've tried every permutation of -I and -L that I can 
think of.  It almost appears that one either uses dub for 
everything or nothing and I'm getting pretty frustrated with it 
as well.  Perhaps I should just go back to old-fashioned make 
files?


Re: Program exited with code -11

2015-06-22 Thread weaselcat via Digitalmars-d-learn

On Tuesday, 23 June 2015 at 03:29:14 UTC, Charles Hawkins wrote:
Thanks, Adam.  I'm coming from OCaml and haven't seen a seg 
fault in years.  Didn't recognize it. :D  Hopefully I can 
figure it out from here.


Try to compile with either ldc or gdc and the -g flag, it should 
give you a backtrace. dmd seems to not like linux wrt backtraces.


Re: Program exited with code -11

2015-06-22 Thread Charles Hawkins via Digitalmars-d-learn
Thanks, Adam.  I'm coming from OCaml and haven't seen a seg fault 
in years.  Didn't recognize it. :D  Hopefully I can figure it out 
from here.


Re: Program exited with code -11

2015-06-22 Thread Adam D. Ruppe via Digitalmars-d-learn

On Tuesday, 23 June 2015 at 02:45:24 UTC, Adam D. Ruppe wrote:

128 == -1


I'm sorry, I need to stop posting these things without thinking. 
-1 is actually 255 when you cast it, but I'm pretty sure the 
shell just does that subtraction from 128 because of the signal 
reservation codes. I stand by the rest of the post...


Re: Program exited with code -11

2015-06-22 Thread Adam D. Ruppe via Digitalmars-d-learn

On Tuesday, 23 June 2015 at 02:34:17 UTC, Charles Hawkins wrote:

How do I find out what that means?


Many return codes have a meaning in the linux documentation:

http://www.tldp.org/LDP/abs/html/exitcodes.html#EXITCODESREF

(it lists them as unsigned, but you got a signed result. 128 == 
-1, so -11 falls under the 128+ section in that table)



-11 means it exited with signal 11. Do "man 7 signal" in linux to 
get the signal documentation overview. One of the lines there is:


   SIGSEGV  11   CoreInvalid memory reference


Signal #11 is segmentation fault.



Since you're a D newbie, I'm guessing you made the mistake of 
forgetting to new a class before using it:


class Foo {}

void main() {
   Foo foo;
   foo.something(); // this will segfault, killing the program
}


That's different than C++, D's classes are more like Java. You 
need to:


Foo foo = new Foo();

or

auto foo = new Foo();

so it isn't a null reference.


Program exited with code -11

2015-06-22 Thread Charles Hawkins via Digitalmars-d-learn

My first attempt at a significant D program and I'm getting:
Error executing command run:
Program exited with code -11

How do I find out what that means?