Building DMD on SmartOS

Jason King via Digitalmars-d digitalmars-d at puremagic.com
Thu Jun 25 20:38:43 PDT 2015


It appears no syscall is generating EBADF.

Does writeln call into libc's printf() function?  That can return EBADF
(bad file number) if the stream isn't enabled for writing.

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).

On Thu, Jun 25, 2015 at 4:03 PM, flamencofantasy via Digitalmars-d <
digitalmars-d at puremagic.com> wrote:

> On Thursday, 25 June 2015 at 20:26:05 UTC, Jason King wrote:
>
>> The first thing I would suggest running the program via truss and see if
>> any calls to write() are returning EBADF.. If so, see what fd# is being
>> passed (or if something is calling close() on fd1).
>>
>> On Thu, Jun 25, 2015 at 2:57 PM, flamencofantasy via Digitalmars-d <
>> digitalmars-d at puremagic.com> wrote:
>>
>>  On Sunday, 17 May 2015 at 19:36:54 UTC, Joakim wrote:
>>>
>>>  On Tuesday, 5 May 2015 at 15:41:47 UTC, Joakim wrote:
>>>>
>>>>  On Tuesday, 5 May 2015 at 05:42:33 UTC, Kai Nacke wrote:
>>>>>
>>>>>  BTW: You can by-pass the Solaris ld by setting environment variable
>>>>>> LD_ALTEXEC to the ld binary you want to use.
>>>>>>
>>>>>>
>>>>> 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.
>>>>>  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.
>>>>>
>>>>> 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.
>>>>>
>>>>>
>>>> Before I chuck this large SmartOS VM on my external backup, I thought
>>>> I'd
>>>> take another shot at getting the phobos tests running.  Turned out to be
>>>> pretty easy and I started hacking around the test failures until it got
>>>> too
>>>> tedious, when the std.path tests wouldn't run because "Memory allocation
>>>> failed."
>>>>  Here's the last patch I used:
>>>>
>>>> https://gist.github.com/joakim-noah/6094789851ba1db1170b
>>>>
>>>> Some notes:
>>>>
>>>> - I disabled the tests for std.datetime and std.parallelism in the test
>>>> runner because they were both failing somewhere.
>>>> - All it took to get the phobos test runner linked was to add all the
>>>> additional necessary libraries that curl needed on Solaris to posix.mak.
>>>> - getcwd will not accept a zero size on Solaris.
>>>> - Solaris seems to have similar issues to Android with formatting NaN
>>>> and
>>>> hex in std.format.
>>>>
>>>>
>>> Hello,
>>>
>>> This is my test program;
>>>
>>> import std.stdio;
>>>
>>> void main()
>>> {
>>>         try
>>>         {
>>>                 writeln("Hello");
>>>         }
>>>         catch (Exception e)
>>>         {
>>>                 import core.stdc.stdio;
>>>                 printf(e.msg.ptr);
>>>         }
>>> }
>>>
>>>
>>> The output is;
>>> Bad file number
>>>
>>> It has to do with stdout not being valid but I am unable to figure out
>>> why
>>> by reading the source code.
>>> I am new to unix in general and SmartOS/Solaris in particular.
>>>
>>> Long story short my fairly large project which builds and runs flawlessly
>>> on Windows and Linux, compiles successfully on SmartOS with no warnings
>>> but
>>> any invocation of writeln (and relatives) throws the exception above.
>>> If anyone is willing to help I have a smart zone with ssh access I can
>>> provide you with so you can play.
>>>
>>> Thanks!
>>>
>>
> Thanks, I've been trying truss and gdb but I wasn't able to spot anything
> useful.
>
> The exception is checked and thrown in user space so I don't think truss
> sees anything.
>
> But here is the full truss dump of the program above;
>
> [root at smartDmachine ~]# truss ./main
> execve("main", 0xFFFFFD7FFFDFFC88, 0xFFFFFD7FFFDFFC98)  argc = 1
> sysinfo(SI_MACHINE, "i86pc", 257)               = 6
> mmap(0x00000000, 56, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANON,
> 4294967295, 0) = 0xFFFFFD7FFF390000
> mmap(0x00000000, 4096, PROT_READ|PROT_WRITE|PROT_EXEC,
> MAP_PRIVATE|MAP_ANON, 4294967295, 0) = 0xFFFFFD7FFF380000
> mmap(0x00000000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON,
> 4294967295, 0) = 0xFFFFFD7FFF370000
> mmap(0x00000000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON,
> 4294967295, 0) = 0xFFFFFD7FFF360000
> memcntl(0xFFFFFD7FFF398000, 96976, MC_ADVISE, MADV_WILLNEED, 0, 0) = 0
> mmap(0x00000000, 4096, PROT_READ|PROT_WRITE|PROT_EXEC,
> MAP_PRIVATE|MAP_ANON, 4294967295, 0) = 0xFFFFFD7FFF350000
> memcntl(0x00400000, 6040, MC_ADVISE, MADV_WILLNEED, 0, 0) = 0
> resolvepath("/lib/amd64/ld.so.1", "/lib/amd64/ld.so.1", 1023) = 18
> getcwd("/root", 1018)                           = 0
> resolvepath("/root/main", "/root/main", 1023)   = 10
> stat("/root/main", 0xFFFFFD7FFFDFF960)          = 0
> open("/var/ld/64/ld.config", O_RDONLY)          = 3
> fstat(3, 0xFFFFFD7FFFDFF6C0)                    = 0
> mmap(0x00000000, 160, PROT_READ, MAP_SHARED, 3, 0) = 0xFFFFFD7FFF340000
> close(3)                                        = 0
> stat("/opt/local/lib//libpthread.so.1", 0xFFFFFD7FFFDFF050) Err#2 ENOENT
> stat("/opt/local/gcc47/x86_64-sun-solaris2.11/lib/amd64/libpthread.so.1",
> 0xFFFFFD7FFFDFF050) Err#2 ENOENT
> stat("/opt/local/gcc47/lib/amd64/libpthread.so.1", 0xFFFFFD7FFFDFF050)
> Err#2 ENOENT
> stat("/lib/64/libpthread.so.1", 0xFFFFFD7FFFDFF050) = 0
> resolvepath("/lib/64/libpthread.so.1", "/lib/amd64/libpthread.so.1", 1023)
> = 26
> open("/lib/64/libpthread.so.1", O_RDONLY)       = 3
> mmapobj(3, MMOBJ_INTERPRET, 0xFFFFFD7FFF350C80, 0xFFFFFD7FFFDFEBAC,
> 0x00000000) = 0
> close(3)                                        = 0
> mmap(0x00000000, 4096, PROT_READ|PROT_WRITE|PROT_EXEC,
> MAP_PRIVATE|MAP_ANON, 4294967295, 0) = 0xFFFFFD7FFF330000
> stat("/opt/local/lib//libm.so.2", 0xFFFFFD7FFFDFF050) Err#2 ENOENT
> stat("/opt/local/gcc47/x86_64-sun-solaris2.11/lib/amd64/libm.so.2",
> 0xFFFFFD7FFFDFF050) Err#2 ENOENT
> stat("/opt/local/gcc47/lib/amd64/libm.so.2", 0xFFFFFD7FFFDFF050) Err#2
> ENOENT
> stat("/lib/64/libm.so.2", 0xFFFFFD7FFFDFF050)   = 0
> resolvepath("/lib/64/libm.so.2", "/lib/amd64/libm.so.2", 1023) = 20
> open("/lib/64/libm.so.2", O_RDONLY)             = 3
> mmapobj(3, MMOBJ_INTERPRET, 0xFFFFFD7FFF3309A0, 0xFFFFFD7FFFDFEBAC,
> 0x00000000) = 0
> close(3)                                        = 0
> mmap(0x00000000, 4096, PROT_READ|PROT_WRITE|PROT_EXEC,
> MAP_PRIVATE|MAP_ANON, 4294967295, 0) = 0xFFFFFD7FFF320000
> memcntl(0xFFFFFD7FFEED0000, 89056, MC_ADVISE, MADV_WILLNEED, 0, 0) = 0
> stat("/opt/local/lib//libc.so.1", 0xFFFFFD7FFFDFF050) Err#2 ENOENT
> stat("/opt/local/gcc47/x86_64-sun-solaris2.11/lib/amd64/libc.so.1",
> 0xFFFFFD7FFFDFF050) Err#2 ENOENT
> stat("/opt/local/gcc47/lib/amd64/libc.so.1", 0xFFFFFD7FFFDFF050) Err#2
> ENOENT
> stat("/lib/64/libc.so.1", 0xFFFFFD7FFFDFF050)   = 0
> resolvepath("/lib/64/libc.so.1", "/lib/amd64/libc.so.1", 1023) = 20
> open("/lib/64/libc.so.1", O_RDONLY)             = 3
> mmapobj(3, MMOBJ_INTERPRET, 0xFFFFFD7FFF320A68, 0xFFFFFD7FFFDFEBAC,
> 0x00000000) = 0
> close(3)                                        = 0
> mmap(0x00000000, 4096, PROT_READ|PROT_WRITE|PROT_EXEC,
> MAP_PRIVATE|MAP_ANON, 4294967295, 0) = 0xFFFFFD7FFF170000
> memcntl(0xFFFFFD7FFF180000, 465912, MC_ADVISE, MADV_WILLNEED, 0, 0) = 0
> mmap(0x00010000, 24576, PROT_READ|PROT_WRITE|PROT_EXEC,
> MAP_PRIVATE|MAP_ANON|MAP_ALIGN, -1, 0) = 0xFFFFFD7FFF160000
> getcontext(0xFFFFFD7FFFDFF3B0)
> getrlimit(RLIMIT_STACK, 0xFFFFFD7FFFDFF710)     = 0
> getpid()                                        = 23127 [23126]
> lwp_private(0, 0, 0xFFFFFD7FFF162A80)           = 0x00000000
> setustack(0xFFFFFD7FFF162B28)
> lwp_cond_broadcast(0xFFFFFD7FFF1701A8)          = 0
> lwp_cond_broadcast(0xFFFFFD7FFF3201A8)          = 0
> lwp_cond_broadcast(0xFFFFFD7FFF3501A8)          = 0
> lwp_cond_broadcast(0xFFFFFD7FFF3301A8)          = 0
> sysi86(SI86FPSTART, 0xFFFFFD7FFFDFFC3C, 0x0000133F, 0x00001F80) =
> 0x00000001
> brk(0x0063E270)                                 = 0
> brk(0x00642270)                                 = 0
> time()                                          = 1435265935
> time()                                          = 1435265935
> sigfillset(0xFFFFFD7FFF319500)                  = 0
> schedctl()                                      = 0xFFFFFD7FFF15D000
> sigaction(SIGUSR1, 0xFFFFFD7FFFDFF8E0, 0x00000000) = 0
> sigaction(SIGUSR2, 0xFFFFFD7FFFDFF8E0, 0x00000000) = 0
> sysconfig(_CONFIG_SEM_VALUE_MAX)                = 2147483647
> mmap(0x00000000, 1048576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON,
> 4294967295, 0) = 0xFFFFFD7FFF05C000
> brk(0x00642270)                                 = 0
> brk(0x00646270)                                 = 0
> brk(0x00646270)                                 = 0
> brk(0x0064A270)                                 = 0
> brk(0x0064A270)                                 = 0
> brk(0x0064E270)                                 = 0
> clock_getres(4, 0xFFFFFD7FFFDFF940)             = 0
> clock_getres(4, 0xFFFFFD7FFFDFF920)             = 0
> clock_gettime(4, 0xFFFFFD7FFFDFF930)            = 0
> priocntlsys(1, 0xFFFFFD7FFFDFF7B0, 3, 0xFFFFFD7FFFDFF8E8, 0) = 23127
> priocntlsys(1, 0xFFFFFD7FFFDFF7B0, 1, 0xFFFFFD7FFFDFF918, 0) = 4
> sysconfig(_CONFIG_PAGESIZE)                     = 4096
> sigaction(SIGSEGV, 0xFFFFFD7FFFDFF950, 0xFFFFFD7FFFDFFA58) = 0
> sigaction(SIGBUS, 0xFFFFFD7FFFDFF950, 0xFFFFFD7FFFDFFA78) = 0
> sigaction(SIGSEGV, 0xFFFFFD7FFFDFF940, 0x00000000) = 0
> sigaction(SIGBUS, 0xFFFFFD7FFFDFF940, 0x00000000) = 0
> mmap(0x00010000, 65536, PROT_READ|PROT_WRITE|PROT_EXEC,
> MAP_PRIVATE|MAP_ANON|MAP_ALIGN, 4294967295, 0) = 0xFFFFFD7FFF040000
> ioctl(1, TCGETA, 0xFFFFFD7FFFDFE670)            = 0
> fstat(1, 0xFFFFFD7FFFDFE5F0)                    = 0
> brk(0x0064E270)                                 = 0
> brk(0x00652270)                                 = 0
> munmap(0xFFFFFD7FFF05C000, 1048576)             = 0
> munmap(0x00000000, 0)                           Err#22 EINVAL
> lseek(0, 0, SEEK_CUR)                           = 6056
>  (Bad file number)write(1, "   ( B a d   f i l e   n".., 18)    = 18
> _exit(0)
> [root at smartDmachine ~]#
>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20150625/a8d861e1/attachment-0001.html>


More information about the Digitalmars-d mailing list