Hey Sergey

On Tue, Feb 14, 2023 at 8:49 AM Sergey Bugaev <buga...@gmail.com> wrote:

> This line in configure logs has always bugged me; of course GNU MIG
> supports "retcode" (as in, does not report an error upon seeing it).
> Today I happened to have journalctl -f opened at the time I ran
> ../configure, and accidentally found out why this happens:
>
> kernel: traps: x86_64-gnu-migc[177175] trap divide error ip:40befb
> sp:7ffc84726920 error:0 in x86_64-gnu-migcom[401000+10000]
>
> oh noes!
>
> $ coredumpctl debug
> <snip>
> Core was generated by
> `/home/sergey/dev/crosshurd64/bin/../libexec/x86_64-gnu-migcom -n'.
> Program terminated with signal SIGFPE, Arithmetic exception.
> #0  0x000000000040befb in itVarArrayDecl (number=0, old=0xb285e0) at
> ../type.c:632
> 632             it->itNumber = (2048 / bytes) * it->itNumber;
> (gdb) bt
> #0  0x000000000040befb in itVarArrayDecl (number=0, old=0xb285e0) at
> ../type.c:632
> #1  0x00000000004059ef in yyparse () at ../parser.y:474
> #2  0x00000000004012c9 in main (argc=<optimized out>, argv=<optimized
> out>) at ../migcom.c:218
> (gdb) p bytes
> $1 = 0
> (gdb) p *old
> $2 = {itName = 0x0, itNext = 0x0, itTypeSize = 0, itPadSize = 0,
> itMinTypeSize = 0, itAlignment = 0, itInName = 0, itOutName = 0,
> itSize = 0, itNumber = 1, itInLine = true, itLongForm = false,
>   itDeallocate = d_NO, itInNameStr = 0x0, itOutNameStr = 0x0, itFlags
> = 0, itStruct = true, itString = false, itVarArray = false,
> itIndefinite = false, itKernelPort = false, itElement = 0x0,
>   itUserType = 0x0, itServerType = 0x0, itTransType = 0x0, itInTrans =
> 0x0, itInTransPayload = 0x0, itOutTrans = 0x0, itDestructor = 0x0}
>
> That type doesn't look right! But then I looked at the configure log
> and found this:
>
> configure:4633: checking whether x86_64-gnu-mig supports the retcode
> keyword
> configure:4650: CC=x86_64-gnu-gcc x86_64-gnu-mig -n conftest.defs 1>&5
> "/home/sergey/dev/crosshurd64/include/mach/std_types.defs", line 32:
> Basic types not initialized when looking up type int32_t. Did you
> forget to define the subsystem?
> "/home/sergey/dev/crosshurd64/include/mach/std_types.defs", line 33:
> Basic types not initialized when looking up type int64_t. Did you
> forget to define the subsystem?
> "/home/sergey/dev/crosshurd64/include/mach/std_types.defs", line 34:
> Basic types not initialized when looking up type boolean_t. Did you
> forget to define the subsystem?
> "/home/sergey/dev/crosshurd64/include/mach/std_types.defs", line 35:
> Basic types not initialized when looking up type unsigned. Did you
> forget to define the subsystem?
> "/home/sergey/dev/crosshurd64/include/mach/std_types.defs", line 36:
> Basic types not initialized when looking up type uint32_t. Did you
> forget to define the subsystem?
> "/home/sergey/dev/crosshurd64/include/mach/std_types.defs", line 37:
> Basic types not initialized when looking up type uint64_t. Did you
> forget to define the subsystem?
> "/home/sergey/dev/crosshurd64/include/mach/x86_64/machine_types.defs",
> line 45: Basic types not initialized when looking up type uint32_t.
> Did you forget to define the subsystem?
> "/home/sergey/dev/crosshurd64/include/mach/x86_64/machine_types.defs",
> line 45: type 'uint32_t' not defined
> "/home/sergey/dev/crosshurd64/include/mach/x86_64/machine_types.defs",
> line 45: Basic types not initialized when looking up type natural_t.
> Did you forget to define the subsystem?
> "/home/sergey/dev/crosshurd64/include/mach/x86_64/machine_types.defs",
> line 54: Basic types not initialized when looking up type int32_t. Did
> you forget to define the subsystem?
> "/home/sergey/dev/crosshurd64/include/mach/x86_64/machine_types.defs",
> line 54: type 'int32_t' not defined
> "/home/sergey/dev/crosshurd64/include/mach/x86_64/machine_types.defs",
> line 54: Basic types not initialized when looking up type integer_t.
> Did you forget to define the subsystem?
> "/home/sergey/dev/crosshurd64/include/mach/x86_64/machine_types.defs",
> line 65: Basic types not initialized when looking up type uint64_t.
> Did you forget to define the subsystem?
> "/home/sergey/dev/crosshurd64/include/mach/x86_64/machine_types.defs",
> line 65: type 'uint64_t' not defined
> "/home/sergey/dev/crosshurd64/include/mach/x86_64/machine_types.defs",
> line 65: Basic types not initialized when looking up type
> rpc_long_natural_t. Did you forget to define the subsystem?
> "/home/sergey/dev/crosshurd64/include/mach/x86_64/machine_types.defs",
> line 66: Basic types not initialized when looking up type int64_t. Did
> you forget to define the subsystem?
> "/home/sergey/dev/crosshurd64/include/mach/x86_64/machine_types.defs",
> line 66: type 'int64_t' not defined
> "/home/sergey/dev/crosshurd64/include/mach/x86_64/machine_types.defs",
> line 66: Basic types not initialized when looking up type
> rpc_long_integer_t. Did you forget to define the subsystem?
> "/home/sergey/dev/crosshurd64/include/mach/x86_64/machine_types.defs",
> line 78: Basic types not initialized when looking up type
> rpc_long_natural_t. Did you forget to define the subsystem?
> "/home/sergey/dev/crosshurd64/include/mach/x86_64/machine_types.defs",
> line 78: type 'rpc_long_natural_t' not defined
> "/home/sergey/dev/crosshurd64/include/mach/x86_64/machine_types.defs",
> line 85: Basic types not initialized when looking up type
> long_natural_t. Did you forget to define the subsystem?
> "/home/sergey/dev/crosshurd64/include/mach/x86_64/machine_types.defs",
> line 91: Basic types not initialized when looking up type
> rpc_long_integer_t. Did you forget to define the subsystem?
> "/home/sergey/dev/crosshurd64/include/mach/x86_64/machine_types.defs",
> line 91: type 'rpc_long_integer_t' not defined
> "/home/sergey/dev/crosshurd64/include/mach/x86_64/machine_types.defs",
> line 98: Basic types not initialized when looking up type
> long_integer_t. Did you forget to define the subsystem?
> "/home/sergey/dev/crosshurd64/include/mach/x86_64/machine_types.defs",
> line 103: Basic types not initialized when looking up type uint64_t.
> Did you forget to define the subsystem?
> "/home/sergey/dev/crosshurd64/include/mach/x86_64/machine_types.defs",
> line 103: type 'uint64_t' not defined
> "/home/sergey/dev/crosshurd64/include/mach/x86_64/machine_types.defs",
> line 103: Basic types not initialized when looking up type
> rpc_phys_addr_t. Did you forget to define the subsystem?
> "/home/sergey/dev/crosshurd64/include/mach/std_types.defs", line 42:
> Basic types not initialized when looking up type int. Did you forget
> to define the subsystem?
> "/home/sergey/dev/crosshurd64/include/mach/std_types.defs", line 42:
> type 'int' not defined
> "/home/sergey/dev/crosshurd64/include/mach/std_types.defs", line 42:
> Basic types not initialized when looking up type kern_return_t. Did
> you forget to define the subsystem?
> "/home/sergey/dev/crosshurd64/include/mach/std_types.defs", line 45:
> Basic types not initialized when looking up type pointer_t. Did you
> forget to define the subsystem?
> "/home/sergey/dev/crosshurd64/include/mach/std_types.defs", line 54:
> Basic types not initialized when looking up type mach_port_t. Did you
> forget to define the subsystem?
> "/home/sergey/dev/crosshurd64/include/mach/std_types.defs", line 55:
> Basic types not initialized when looking up type mach_port_t. Did you
> forget to define the subsystem?
> "/home/sergey/dev/crosshurd64/include/mach/std_types.defs", line 55:
> type 'mach_port_t' not defined
> /home/sergey/dev/crosshurd64/bin/x86_64-gnu-mig: line 132: 177174 Done
>                    x86_64-gnu-gcc -E -x c conftest.defs
>      177175 Floating point exception(core dumped) |
> /home/sergey/dev/crosshurd64/bin/../libexec/x86_64-gnu-migcom -n
> configure:4653: $? = 136
> configure:4661: result: no
>
> So, lots of "Basic types not initialized when looking up type ... Did
> you forget to define the subsystem?"
>
> The test file, found inside aclocal.m4, is:
>
> #include <mach/std_types.defs>
> #include <mach/mach_types.defs>
> subsystem foobar 1000;
> type reply_port_t = polymorphic | MACH_MSG_TYPE_PORT_SEND_ONCE
>         ctype: mach_port_t;
> simpleroutine foobar_reply (
>         reply_port: reply_port_t;
>         err: kern_return_t, RetCode);
>
> and that of course defines "subsystem foobar". But -- it includes the
> standard headers first, and only defines the subsystem later. Unlike
> how the Mach and Hurd headers do it. Hence, the wall of errors.
>
> This would be trivial to fix by flipping the line order in aclocal.m4
> (in each repo that vendors it...), but maybe MIG should actually
> support this? What does it need the subsystem for anyway, when parsing
> type defs? Apple's MIG supports this, too.
>

>From what I remember, I fixed a bug where we were initializing the basic
types twice (see
https://git.savannah.gnu.org/cgit/hurd/mig.git/commit/?id=f51fc836c5b690f5448e76196dd40bdb55957a11)
and so the type initialization is now made after knowing the subsystem
since for the kernel ports could be 8-bytes, while in user mode they are
4-bytes (they are port names).

I suggest we fix this in the short term and eventually once we have a
better message layout for 64 bits, we can align all port descriptors to be
8-bytes like we did for mach_msg_header_t and then mig can compute the port
size statically again.

Flavio


> Sergey
>
>

Reply via email to