2!:13 was a concept I invented a few minutes ago.
And, yes, I could probably do this in a library. so I started on that. I
went into a linux instance and in j602/bin I created a file named errno.c
which contains the text:
#include <errno.h>
int get_errno() {
return errno;
}
Then:
~/j602/bin$ CFLAGS=-fPIC make errno.o
cc -fPIC -c -o errno.o errno.c
~/j602/bin$ gcc -shared -Wl,-soname,liberrno.so.1 -o liberrno.so.1.0.0
errno.o
~/j602/bin$ ./jconsole
require 'dll'
'liberrno.so.1.0.0 get_errno n' cd ''
|domain error: cd
| 'liberrno.so.1.0.0 get_errno n' cd''
cder''
1 0
(file not found)
But changing the file reference to an absolute path did not help.
Meanwhile, my other strategy paid off, ... sort of:
I found that if I attach to the jconsole having a problem, using strace,
that the interface error stops happening. So that very definitely points
the finger away from J and at the underlying OS. (10k of trace text,
though, for just 2!:0 '/bin/true' - imagine running that on half a dozen
machines for hours of a time on each, to try to isolate the problem. Maybe
I need to just bite the bullet and do exactly that. But I keep hoping for
something that doesn't risk crashing the entire OS instance from disk full
errors or whatever.)
Debugging is very much like detective work. You build a trail of clues and
build up a picture of what is happening based on the clues you find. It
requires a certain amount of paranoia, and suspicion, and guesswork, and so
on. And you learn a lot, doing it (though sometimes you do not realize some
of the lessons until later).
Looks like this one is going to require a bit more work, though. And since
my underlying assumptions are suspect (they are always suspect in
investigatory work) I sort of have to keep in mind the distinct possibility
that I'm an idiot and have overlooked an entirely obvious approach.
Thanks,
--
Raul
On Thu, Mar 13, 2014 at 10:13 AM, Joe Bogner <[email protected]> wrote:
> Yes, I am interested, so thanks for sharing. I don't see 2!:13 in the
> gpl src or in the dictionary. Wouldn't it be possible to write a
> library and call it from j to return errno? Perhaps more work than
> it's worth
>
> On Thu, Mar 13, 2014 at 10:06 AM, Raul Miller <[email protected]>
> wrote:
> > I'm inclined to lay the blame for this one on the OS.
> >
> > The defect in J is that there's no good way of getting at errno.
> >
> >
> http://www.openbsd.org/cgi-bin/man.cgi?query=system&apropos=0&sektion=3&manpath=OpenBSD+Current&arch=i386&format=html
> >
> > I imagine that 2!:13 should return the value of errno.
> >
> > For now, though, I think I know how to get at that value. I spent way too
> > much time grovelling through disassembled code and register dumps in gdb
> > last night - there's something about the way libc is implemented that I
> do
> > not understand (and the i386 architecture is a pain to work with, at
> least
> > for me), but I think I know how to get at the underlying fault, the next
> > time this happens.
> >
> > I should be a lot better at this, but the focus of my work at usatoday
> has
> > spoiled me for this kind of thing, and in many ways I feel like I'm a
> > beginner again, on a variety of technical fronts. On the positive side,
> > though, I imagine that people can learn from my posts here. (Only those
> > that are interested, of course - people's interests vary over quite a
> wide
> > range.)
> >
> > Thanks,
> >
> > --
> > Raul
> >
> >
> >
> >
> > On Thu, Mar 13, 2014 at 8:10 AM, Joe Bogner <[email protected]> wrote:
> >
> >> Not sure if it helps, but I ran this for 3 hours this morning and
> >> didn't have any errrors:
> >>
> >> go=: 3 : 0
> >> for_i. i. 1e7 do.
> >> 2!:0 'date'
> >> 2!:0 'sleep .1'
> >> 2!:0 'date >/tmp/f1;:'
> >> end.
> >> )
> >>
> >> go''
> >>
> >> JVERSION
> >> Engine: j701/2011-01-10/11:25
> >> Library: 7.01.088
> >> Platform: Linux 64
> >> Installer: j701a_linux64.sh
> >> InstallPath: /home/joebo/j64-701
> >>
> >>
> >> On Wed, Mar 12, 2014 at 10:08 PM, Raul Miller <[email protected]>
> >> wrote:
> >> > I'm not sure why that ' > ' is five characters instead of three.
> >> Probably
> >> > it was specified as 3 characters with spaces surrounding the '>' but
> that
> >> > got interpreted as three spaces followed by '> '.
> >> >
> >> > In any event, it's just: command string followed by ' > ' followed
> by
> >> > temporary file name.
> >> >
> >> > Meanwhile, it would have been more useful if it had been
> >> '>',tmpfilename,'
> >> > ',command -- that way if the command had a redirect in it, it would
> just
> >> > work. As it is, one must do something a little extra to redirect to a
> >> file
> >> >
> >> > Anyways, here's an example of the problem in action:
> >> >
> >> > |interface error: spawn
> >> > |spawn[:0]
> >> > 2!:0 'date >/tmp/f1;:'
> >> > |interface error
> >> > | 2!:0'date >/tmp/f1;:'
> >> > ^D
> >> > real 121m42.418s
> >> > user 71m39.468s
> >> > sys 12m58.545s
> >> > ~$ ls -lart /tmp
> >> > total 8
> >> > drwxr-xr-x 23 root root 4096 Mar 9 14:12 ..
> >> > drwxrwxrwt 2 root root 4096 Mar 13 01:19 .
> >> >
> >> > And, here's an example of successfully redirecting to a file:
> >> >
> >> > 2!:0 'date >/tmp/f2;:'
> >> >
> >> > The ;: at the end of the command string terminates the command with
> the
> >> > redirect and follows it with an empty command which does nothing. The
> >> > redirect then takes effect on that command (thus 2!:0 returns
> nothing).
> >> >
> >> > ~$ cat /tmp/f2
> >> > Thu Mar 13 02:04:09 UTC 2014
> >> >
> >> > Anyways, I've got jconsole running under gdb, and I'll see if the C
> >> > debugger can tell me anything about the problem.
> >> >
> >> > Thanks,
> >> >
> >> > --
> >> > Raul
> >> >
> >> >
> >> >
> >> > On Wed, Mar 12, 2014 at 9:27 PM, Joe Bogner <[email protected]>
> wrote:
> >> >
> >> >> On Wed, Mar 12, 2014 at 9:16 PM, Joe Bogner <[email protected]>
> >> wrote:
> >> >> > I can't figure out by looking at it how the tmpnam gets
> >> >> > added to the system command. I'm used to seeing popen
> >> >> >
> >> >> >
> >> >>
> >>
> https://github.com/openj/core/blob/18fd23bbdc2f50770eb3047e978cd5e4e3b47039/xh.c#L39
> >> >> >
> >> >>
> >> >> Scratch that, I figured out how it gets added. It's appending it to
> >> >> the end of the pointer. The number 5 still has me confused and the "
> >
> >> >> ". Anyways, I don't think this is helping unless it has something to
> >> >> do with 5 and exceeding the number of temporary files or something
> >> >> like that. Probably a false trail of thought
> >> >>
> ----------------------------------------------------------------------
> >> >> For information about J forums see
> http://www.jsoftware.com/forums.htm
> >> >>
> >> > ----------------------------------------------------------------------
> >> > For information about J forums see
> http://www.jsoftware.com/forums.htm
> >> ----------------------------------------------------------------------
> >> For information about J forums see http://www.jsoftware.com/forums.htm
> >>
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm