Charles Cui | 3 May 06:56 2016

next steps for GSOC 2016

Hi Christos and Martin,

     I have set up my environments for development.
I guess the next step is to start to be familiar with the code
base of the POSIX test benchmarks and related kernel subsystems
in NetBSD. I think a lot of problems will be found during this phase.
Does this plan sound good? Let me know if you have new thoughts and suggestions.

Thanks, Charles

Charles Cui | 30 Apr 02:03 2016

Re: honor to join NetBSD community

Hi Patrick,

   To answer your questions, I build gnome at
/usr/pkgsrc/meta-pkgs/gnome  folder, and run make clean install.
Following are detailed info.  KDE4 also has building errors.

===> Cleaning for gnome-2.26.2nb4

===> Skipping vulnerability checks.

WARNING: No /var/db/pkg/pkg-vulnerabilities file found.

WARNING: To fix run: `/usr/pkg/sbin/pkg_admin -K /var/db/pkg

===> Installing dependencies for gnome-2.26.2nb4


The supported build options for gnome are:


The currently selected options are:


You can select which build options to use by setting PKG_DEFAULT_OPTIONS

or the following variable.  Its current value is shown:
(Continue reading)

Terry Moore | 28 Apr 03:52 2016

RE: NetBSD GUI practice and experience

(Changed subject to match content)

> On Apr 27,  6:11pm, charles.cui1984 <at> (Charles Cui) wrote:
> -- Subject: Re: honor to join NetBSD community
> | 2. How do you work in netbsd, do you use GUI (like xwindow, or gnome)?
> | If so, which
> | do you recommend? I installed Xwindows several times, but seems have
> | some problems.
> It depends. Right now I am typing on OS/X using Xquartz connected to a
> NetBSD box via ssh a few miles away. I run X on NetBSD too, but my NetBSD
> laptop is old and heavy and runs hot :-)

I run NetBSD in a VM on my primary Windows laptop using VMware -- works
great. It's not "supported" by VMware, but I have very few problems. You
could probably use VMware Player for a free solution. I have not tried
VirtualBox. I only need 256M of RAM in the VM to do very large edit and
compile sessions (but I am not doing kernel builds, so I can't comment on
whether that would be enough memory for your work).  (In fact, I ran with
only 160M of RAM for many years.) Because it needs so little RAM for my
shell/edit/compile/transform workload, I don't notice that it's present. I
can't say that about the other VMs I have to run.

I have used XWin32 and Cygwin X to connect to a desktop manager running on
NetBSD; I've also used a desktop and xdm(1) (so I'm talking directly to an
XServer running on NetBSD through the VMware virtual console. I tend to
stick with remoting in with X because it's a little more convenient. 

Only significant headache with using X from the host desktop to a VM is that
(Continue reading)

Charles Cui | 28 Apr 03:11 2016

Re: honor to join NetBSD community

Hi guys,

   Right now I can build a customized NetBSD kernel + userland from sources.
The document is pretty clear and I got it by following those steps.
However, in terms
of the working environments, I have 3 specific questions to ask.
1. I noticed that netbsd community use CVS for version control, I am
familiar with git,
and can learn CVS. Also I noticed that there are actually git repo at
github which hosts
the netbsd source code, and seems there is an automatic transfer when
one pushes to
CVS repo. I am wondering what's the prefer way to add code, CVS,
git(send pull request
to github) or patch.
2. How do you work in netbsd, do you use GUI (like xwindow, or gnome)?
If so, which
do you recommend? I installed Xwindows several times, but seems have
some problems.
3. What tools do you use to view kernel code? do you use IDE or just
Actually, it is hard to look the code, jump to the declaration or
usages because netbsd
has a huge code base. I am looking for a way to work efficiently with
netbsd, your
best practices would be helpful.

Thanks, Charles

2016-04-25 9:39 GMT-07:00 Charles Cui <charles.cui1984 <at>>:
(Continue reading)

Charles Cui | 24 Apr 22:26 2016

Re: honor to join NetBSD community

Thanks Martin for your reply!

2016-04-24 13:13 GMT-07:00 Martin Husemann <martin <at>>:
> On Sun, Apr 24, 2016 at 01:00:12PM -0700, Charles Cui wrote:
>>  Another thing is my mentor
>> for this project, mentors listed in the website are crispytoast and
>> martin, while I contacted mainly with christos previously.
> Hi Charles, welcome to GSoC 2016 with NetBSD and good luck for the project!
> I will be on a business trip next week, so may answer emails with
> some delay.
> I am in CEST timezone (UTC+2) otherwise (next week it'll be London).
> Martin

Charles Cui | 24 Apr 22:00 2016

honor to join NetBSD community

Hi Christos and NetBSD community,

     Thanks for selecting me for GSOC this year. It 's my honor to join NetBSD
community and contribute my code! I will try my best to complete the task.
In terms of work needs to be done in the current stage
(community communications), I think I can start to prepare kinds of
things for coding, including to be familiar with code base of the
benchmark and netbsd kernel(related parts), and programming tools.
Does this sounds good? Another thing is my mentor
for this project, mentors listed in the website are crispytoast and
martin, while I contacted mainly with christos previously. Can I have
the email addresses for
my mentors (so that it is easy to consult their advices)?

Thanks, Charles.

Timo Buhrmester | 24 Apr 15:50 2016

gprof segfaults in mcount

I can no longer profile programs with gprof on i386, NetBSD 7.99.26.
The test case is a hello world program:
| #include <stdio.h>
| int
| main(void)
| {
| 	puts("hello world");
| 	return 0;
| }

which is compiled using cc -g -pg -o helloworld helloworld.c

Here's what happens:

$ gdb ./helloworld
(gdb) run
Starting program: /home/fstd/helloworld 

Program received signal SIGSEGV, Segmentation fault.
0x0805046e in mcount ()
(gdb) bt
#0  0x0805046e in mcount ()
#1  0x08068388 in _libc_init ()
#2  0x080481ea in ___start ()
#3  0x080480f8 in _start ()
(gdb) info registers 
eax            0x0	0
ecx            0x8074740	134694720
(Continue reading)

Kamil Rytarowski | 23 Apr 18:06 2016

sem_open(2) and ENAMETOOLONG

The sem_open(2) function call reports an error for a too long name and
sets errno:

[ENAMETOOLONG]     The name argument is too long.

I noted in the kernel that the limit is SEM_MAX_NAMELEN:

do_ksem_open(struct lwp *l, const char *semname, int oflag, mode_t mode,
     unsigned int value, intptr_t *idp, copyout_t docopyout)
        char name[SEM_MAX_NAMELEN + 1];
        proc_t *p = l->l_proc;
        ksem_t *ksnew = NULL, *ks;
        file_t *fp;
        intptr_t id;
        int fd, error;

        error = copyinstr(semname, name, sizeof(name), NULL);
        if (error) {
                return error;

 -- sys/kern/uipc_sem.c

The limit is held privately in the kernel:

sys/kern/uipc_sem.c:#define     SEM_MAX_NAMELEN         14

I read in the POSIX resources that the limit is defined by PATH_MAX or
(Continue reading)

Kamil Rytarowski | 22 Apr 13:27 2016

pthread2lwp API

I need to extract lwp (lwpid_t) from arbitrary -- and not the current
one --  POSIX thread (pthread_t). I need to access sysctl(7)
interfaces for lwp and read its properties with a given pthread_t.

In my current use-case is to access l_rtime_sec and l_rtime_usec from
 struct kinfo_lwp.

I don't see a way to do it cleanly, something different than reading
opaque pthread_t pointer and accessing rawly pt_lid at some offset.

FreeBSD has similar interface, but only working for the current thread:

and thread id = pid: syscall(__NR_gettid)

Maybe something like it:
int pthread_tolwp_np(pthread_t, lwpid_t*);
int pthread_fromlwp_np(pthread_t*, lwpid_t);

When error - return value != 0 and set errno.
Emmanuel Dreyfus | 18 Apr 09:17 2016

dlopen fails from static binary


On netbsd-6, using dlopen in a static binary will return NULL without 
setting errno.

It seems wrong. Is dlopen really supposed ot fail when called from 
static binary? In that case errno should be set, but to what value?
Or perhaps we could support dlopen from static binary?

Example program:

$ cat test.c                                                                   
#include <stdio.h>
#include <dlfcn.h>
#include <errno.h>
#include <err.h>

        void *dlh;

        errno = 0xdeadbeef;
        dlh = dlopen("/usr/lib/security/", RTLD_NOW);
        if (dlh == NULL)
                err(1, "dlopen failed");

        printf("success (%p)\n", dlh);
        return 0;
(Continue reading)

Kamil Rytarowski | 9 Apr 03:35 2016

Translate signal to C++ exception

I'm stuck with .Net porting to NetBSD, with the need to throw C++
exceptions from a signal handler (SIGSEGV).

I have found similar use-case in gcc/libjava and freebsd (dummy?) code
there. It was abstracted into a segvcatch library (wip/segvcatch).

I'm failing to make it work on NetBSD (release 7.0). This blocks me
from porting dotnet stack.

Thank you in advance,

I'm aware of the danger of this approach, for now I need to make it
just work. I cannot rewrite the dotnet code to use atomics etc.

For now all I need is to make segvcatch work on NetBSD.