<div dir="ltr"><div>It appears no syscall is generating EBADF.<br><br></div><div>Does writeln call into libc's printf() function?  That can return EBADF (bad file number) if the stream isn't enabled for writing.<br><br></div><div>I didn't look too closely (work issues) at the D code, but I did notice the D libraries are trying to define the internal structure of FILE.  It should be treated as an opaque structure.  I didn't look close enough to see if any D library code is trying to manipulate any of its fields (IF it is, that's very wrong).<br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jun 25, 2015 at 4:03 PM, flamencofantasy via Digitalmars-d <span dir="ltr"><<a href="mailto:digitalmars-d@puremagic.com" target="_blank">digitalmars-d@puremagic.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Thursday, 25 June 2015 at 20:26:05 UTC, Jason King wrote:<br>
</span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
The first thing I would suggest running the program via truss and see if<br>
any calls to write() are returning EBADF.. If so, see what fd# is being<br>
passed (or if something is calling close() on fd1).<br>
<br>
On Thu, Jun 25, 2015 at 2:57 PM, flamencofantasy via Digitalmars-d < <a href="mailto:digitalmars-d@puremagic.com" target="_blank">digitalmars-d@puremagic.com</a>> wrote:<br>
<br>
</span><div><div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Sunday, 17 May 2015 at 19:36:54 UTC, Joakim wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Tuesday, 5 May 2015 at 15:41:47 UTC, Joakim wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Tuesday, 5 May 2015 at 05:42:33 UTC, Kai Nacke wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
BTW: You can by-pass the Solaris ld by setting environment variable LD_ALTEXEC to the ld binary you want to use.<br>
<br>
</blockquote>
<br>
Thanks for the tip: I set that to the binutils ld and got almost all of druntime's tests to pass with a 64-bit binary.<br>
 I only had to comment out the additional druntime tests having to do with exceptions.  Maybe that's related to the link error flamencofantasy pasted.<br>
<br>
I also tried running the phobos unit tests, but I got a ton of link errors, seemingly for stuff that should be there.  I'll let someone else track those down.<br>
<br>
</blockquote>
<br>
Before I chuck this large SmartOS VM on my external backup, I thought I'd<br>
take another shot at getting the phobos tests running.  Turned out to be<br>
pretty easy and I started hacking around the test failures until it got too<br>
tedious, when the std.path tests wouldn't run because "Memory allocation<br>
failed."<br>
 Here's the last patch I used:<br>
<br>
<a href="https://gist.github.com/joakim-noah/6094789851ba1db1170b" rel="noreferrer" target="_blank">https://gist.github.com/joakim-noah/6094789851ba1db1170b</a><br>
<br>
Some notes:<br>
<br>
- I disabled the tests for std.datetime and std.parallelism in the test<br>
runner because they were both failing somewhere.<br>
- All it took to get the phobos test runner linked was to add all the<br>
additional necessary libraries that curl needed on Solaris to posix.mak.<br>
- getcwd will not accept a zero size on Solaris.<br>
- Solaris seems to have similar issues to Android with formatting NaN and<br>
hex in std.format.<br>
<br>
</blockquote>
<br>
Hello,<br>
<br>
This is my test program;<br>
<br>
import std.stdio;<br>
<br>
void main()<br>
{<br>
        try<br>
        {<br>
                writeln("Hello");<br>
        }<br>
        catch (Exception e)<br>
        {<br>
                import core.stdc.stdio;<br>
                printf(e.msg.ptr);<br>
        }<br>
}<br>
<br>
<br>
The output is;<br>
Bad file number<br>
<br>
It has to do with stdout not being valid but I am unable to figure out why<br>
by reading the source code.<br>
I am new to unix in general and SmartOS/Solaris in particular.<br>
<br>
Long story short my fairly large project which builds and runs flawlessly<br>
on Windows and Linux, compiles successfully on SmartOS with no warnings but<br>
any invocation of writeln (and relatives) throws the exception above.<br>
If anyone is willing to help I have a smart zone with ssh access I can<br>
provide you with so you can play.<br>
<br>
Thanks!<br>
</blockquote></div></div></blockquote>
<br>
Thanks, I've been trying truss and gdb but I wasn't able to spot anything useful.<br>
<br>
The exception is checked and thrown in user space so I don't think truss sees anything.<br>
<br>
But here is the full truss dump of the program above;<br>
<br>
[root@smartDmachine ~]# truss ./main<br>
execve("main", 0xFFFFFD7FFFDFFC88, 0xFFFFFD7FFFDFFC98)  argc = 1<br>
sysinfo(SI_MACHINE, "i86pc", 257)               = 6<br>
mmap(0x00000000, 56, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANON, 4294967295, 0) = 0xFFFFFD7FFF390000<br>
mmap(0x00000000, 4096, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANON, 4294967295, 0) = 0xFFFFFD7FFF380000<br>
mmap(0x00000000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON, 4294967295, 0) = 0xFFFFFD7FFF370000<br>
mmap(0x00000000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON, 4294967295, 0) = 0xFFFFFD7FFF360000<br>
memcntl(0xFFFFFD7FFF398000, 96976, MC_ADVISE, MADV_WILLNEED, 0, 0) = 0<br>
mmap(0x00000000, 4096, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANON, 4294967295, 0) = 0xFFFFFD7FFF350000<br>
memcntl(0x00400000, 6040, MC_ADVISE, MADV_WILLNEED, 0, 0) = 0<br>
resolvepath("/lib/amd64/ld.so.1", "/lib/amd64/ld.so.1", 1023) = 18<br>
getcwd("/root", 1018)                           = 0<br>
resolvepath("/root/main", "/root/main", 1023)   = 10<br>
stat("/root/main", 0xFFFFFD7FFFDFF960)          = 0<br>
open("/var/ld/64/ld.config", O_RDONLY)          = 3<br>
fstat(3, 0xFFFFFD7FFFDFF6C0)                    = 0<br>
mmap(0x00000000, 160, PROT_READ, MAP_SHARED, 3, 0) = 0xFFFFFD7FFF340000<br>
close(3)                                        = 0<br>
stat("/opt/local/lib//libpthread.so.1", 0xFFFFFD7FFFDFF050) Err#2 ENOENT<br>
stat("/opt/local/gcc47/x86_64-sun-solaris2.11/lib/amd64/libpthread.so.1", 0xFFFFFD7FFFDFF050) Err#2 ENOENT<br>
stat("/opt/local/gcc47/lib/amd64/libpthread.so.1", 0xFFFFFD7FFFDFF050) Err#2 ENOENT<br>
stat("/lib/64/libpthread.so.1", 0xFFFFFD7FFFDFF050) = 0<br>
resolvepath("/lib/64/libpthread.so.1", "/lib/amd64/libpthread.so.1", 1023) = 26<br>
open("/lib/64/libpthread.so.1", O_RDONLY)       = 3<br>
mmapobj(3, MMOBJ_INTERPRET, 0xFFFFFD7FFF350C80, 0xFFFFFD7FFFDFEBAC, 0x00000000) = 0<br>
close(3)                                        = 0<br>
mmap(0x00000000, 4096, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANON, 4294967295, 0) = 0xFFFFFD7FFF330000<br>
stat("/opt/local/lib//libm.so.2", 0xFFFFFD7FFFDFF050) Err#2 ENOENT<br>
stat("/opt/local/gcc47/x86_64-sun-solaris2.11/lib/amd64/libm.so.2", 0xFFFFFD7FFFDFF050) Err#2 ENOENT<br>
stat("/opt/local/gcc47/lib/amd64/libm.so.2", 0xFFFFFD7FFFDFF050) Err#2 ENOENT<br>
stat("/lib/64/libm.so.2", 0xFFFFFD7FFFDFF050)   = 0<br>
resolvepath("/lib/64/libm.so.2", "/lib/amd64/libm.so.2", 1023) = 20<br>
open("/lib/64/libm.so.2", O_RDONLY)             = 3<br>
mmapobj(3, MMOBJ_INTERPRET, 0xFFFFFD7FFF3309A0, 0xFFFFFD7FFFDFEBAC, 0x00000000) = 0<br>
close(3)                                        = 0<br>
mmap(0x00000000, 4096, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANON, 4294967295, 0) = 0xFFFFFD7FFF320000<br>
memcntl(0xFFFFFD7FFEED0000, 89056, MC_ADVISE, MADV_WILLNEED, 0, 0) = 0<br>
stat("/opt/local/lib//libc.so.1", 0xFFFFFD7FFFDFF050) Err#2 ENOENT<br>
stat("/opt/local/gcc47/x86_64-sun-solaris2.11/lib/amd64/libc.so.1", 0xFFFFFD7FFFDFF050) Err#2 ENOENT<br>
stat("/opt/local/gcc47/lib/amd64/libc.so.1", 0xFFFFFD7FFFDFF050) Err#2 ENOENT<br>
stat("/lib/64/libc.so.1", 0xFFFFFD7FFFDFF050)   = 0<br>
resolvepath("/lib/64/libc.so.1", "/lib/amd64/libc.so.1", 1023) = 20<br>
open("/lib/64/libc.so.1", O_RDONLY)             = 3<br>
mmapobj(3, MMOBJ_INTERPRET, 0xFFFFFD7FFF320A68, 0xFFFFFD7FFFDFEBAC, 0x00000000) = 0<br>
close(3)                                        = 0<br>
mmap(0x00000000, 4096, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANON, 4294967295, 0) = 0xFFFFFD7FFF170000<br>
memcntl(0xFFFFFD7FFF180000, 465912, MC_ADVISE, MADV_WILLNEED, 0, 0) = 0<br>
mmap(0x00010000, 24576, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANON|MAP_ALIGN, -1, 0) = 0xFFFFFD7FFF160000<br>
getcontext(0xFFFFFD7FFFDFF3B0)<br>
getrlimit(RLIMIT_STACK, 0xFFFFFD7FFFDFF710)     = 0<br>
getpid()                                        = 23127 [23126]<br>
lwp_private(0, 0, 0xFFFFFD7FFF162A80)           = 0x00000000<br>
setustack(0xFFFFFD7FFF162B28)<br>
lwp_cond_broadcast(0xFFFFFD7FFF1701A8)          = 0<br>
lwp_cond_broadcast(0xFFFFFD7FFF3201A8)          = 0<br>
lwp_cond_broadcast(0xFFFFFD7FFF3501A8)          = 0<br>
lwp_cond_broadcast(0xFFFFFD7FFF3301A8)          = 0<br>
sysi86(SI86FPSTART, 0xFFFFFD7FFFDFFC3C, 0x0000133F, 0x00001F80) = 0x00000001<br>
brk(0x0063E270)                                 = 0<br>
brk(0x00642270)                                 = 0<br>
time()                                          = 1435265935<br>
time()                                          = 1435265935<br>
sigfillset(0xFFFFFD7FFF319500)                  = 0<br>
schedctl()                                      = 0xFFFFFD7FFF15D000<br>
sigaction(SIGUSR1, 0xFFFFFD7FFFDFF8E0, 0x00000000) = 0<br>
sigaction(SIGUSR2, 0xFFFFFD7FFFDFF8E0, 0x00000000) = 0<br>
sysconfig(_CONFIG_SEM_VALUE_MAX)                = <a href="tel:2147483647" value="+12147483647" target="_blank">2147483647</a><br>
mmap(0x00000000, 1048576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON, 4294967295, 0) = 0xFFFFFD7FFF05C000<br>
brk(0x00642270)                                 = 0<br>
brk(0x00646270)                                 = 0<br>
brk(0x00646270)                                 = 0<br>
brk(0x0064A270)                                 = 0<br>
brk(0x0064A270)                                 = 0<br>
brk(0x0064E270)                                 = 0<br>
clock_getres(4, 0xFFFFFD7FFFDFF940)             = 0<br>
clock_getres(4, 0xFFFFFD7FFFDFF920)             = 0<br>
clock_gettime(4, 0xFFFFFD7FFFDFF930)            = 0<br>
priocntlsys(1, 0xFFFFFD7FFFDFF7B0, 3, 0xFFFFFD7FFFDFF8E8, 0) = 23127<br>
priocntlsys(1, 0xFFFFFD7FFFDFF7B0, 1, 0xFFFFFD7FFFDFF918, 0) = 4<br>
sysconfig(_CONFIG_PAGESIZE)                     = 4096<br>
sigaction(SIGSEGV, 0xFFFFFD7FFFDFF950, 0xFFFFFD7FFFDFFA58) = 0<br>
sigaction(SIGBUS, 0xFFFFFD7FFFDFF950, 0xFFFFFD7FFFDFFA78) = 0<br>
sigaction(SIGSEGV, 0xFFFFFD7FFFDFF940, 0x00000000) = 0<br>
sigaction(SIGBUS, 0xFFFFFD7FFFDFF940, 0x00000000) = 0<br>
mmap(0x00010000, 65536, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANON|MAP_ALIGN, 4294967295, 0) = 0xFFFFFD7FFF040000<br>
ioctl(1, TCGETA, 0xFFFFFD7FFFDFE670)            = 0<br>
fstat(1, 0xFFFFFD7FFFDFE5F0)                    = 0<br>
brk(0x0064E270)                                 = 0<br>
brk(0x00652270)                                 = 0<br>
munmap(0xFFFFFD7FFF05C000, 1048576)             = 0<br>
munmap(0x00000000, 0)                           Err#22 EINVAL<br>
lseek(0, 0, SEEK_CUR)                           = 6056<br>
 (Bad file number)write(1, "   ( B a d   f i l e   n".., 18)    = 18<br>
_exit(0)<br>
[root@smartDmachine ~]#<br>
<br>
<br>
<br>
<br>
</blockquote></div><br></div>