Giter VIP home page Giter VIP logo

pintosm's Issues

Booting fails due to 'struct integer_base' in stdio.c

First, thank you very much for your work. I found it is really helpful.

Symptom

On this command,

PintosM/src/threads $ make qemu-nox

I cannot get 'boot complete' sign. It just loops forever like this:

(...)
Pintos hda1
Loading............
Kernel command line:
Pintos booting with Pintos hda1
Loading............
Kernel command line:
Pintos booting with Pintos hda1
Loading............
Kernel command line:
Pintos booting with Pintos hda1
Loading............
(...)

Reason of the Symptom

After some debugging using gdb, I found running pintos on qemu makes error on formatting integer on printf function, for example in upper case, this line does not work properly:

printf ("Pintos booting with %'"PRIu32" kB RAM...\n",

And with even more debugging, I found struct integer_base base_* variables in PintosM/src/lib/stdio.c is assigned but do not have desired value in runtime.

They are defined like this in PintosM/src/lib/stdio.c:

struct integer_base 
  {
    int base;                   /* Base. */
    const char *digits;         /* Collection of digits. */
    int x;                      /* `x' character to use, for base 16 only. */
    int group;                  /* Number of digits to group with ' flag. */
  };

static const struct integer_base base_d = {10, "0123456789", 0, 3};
static const struct integer_base base_o = {8, "01234567", 0, 3};
static const struct integer_base base_x = {16, "0123456789abcdef", 'x', 4};
static const struct integer_base base_X = {16, "0123456789ABCDEF", 'X', 4};

But in runtime, using gdb:

 (gdb) l
 469     static void
 470     format_integer (uintmax_t value, bool is_signed, bool negative,
 471                     const struct integer_base *b,
 472                     const struct printf_conversion *c,
 473                     void (*output) (char, void *), void *aux)
 474     {
 475       char buf[64], *cp;            /* Buffer and current position. */
 476       int x;                        /* `x' character to use or 0 if none. */
 477       int sign;                     /* Sign character or 0 if none. */
 478       int precision;                /* Rendered precision. */
 (gdb) bt
 #0  format_integer (value=3968, is_signed=is_signed@entry=false, negative=false, b=0xc0039550 <base_d>, c=0xc000ef20, output=0xc002a41d <vprintf_helper>,
     aux=0xc000ef6c) at ../../lib/stdio.c:474
 #1  0xc002700c in __vprintf (format=<optimized out>, args=0xc000efa8 200226003300217004002300304, <incomplete sequence \357>,
     output=<optimized out>, aux=<optimized out>) at ../../lib/stdio.c:279
 #2  0xc002a575 in vprintf (format=0xc002e36c Pintos booting with %u kB RAM...\n", args=0xc000efa4 "\200\017") at ../../lib/kernel/console.c:131
 #3  0xc00268e8 in printf (format=0xc002e36c "Pintos booting with %u kB RAM...n) at ../../lib/stdio.c:85
 #4  0xc00204c0 in pintos_init () at ../../threads/init.c:94
 #5  0xc002015d in start () at ../../threads/start.S:180
 (gdb) p *b
  = {base = 0, digits = 0x0, x = 0, group = 0}
 (gdb) p base_d
  = {base = 0, digits = 0x0, x = 0, group = 0}

base_d is set to zero in runtime, and others too, which yields 'division by 0' error.

I don't know why this happened, and want to fix it properly. My guess is that the bug is from outside of the stdio.c (like assembly codes?) but not sure.

There is a simple work-around which ignores all printf function calls, with which I can successfully boot pintos, but I want to resolve this issue fundamentally.

test environment

$ uname -a
Linux ub-Virtual-Machine 4.15.0-45-generic #48-Ubuntu SMP Tue Jan 29 16:28:13 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

$ cat /etc/os-release 
NAME="Ubuntu"
VERSION="18.04.1 LTS (Bionic Beaver)"
(...)
 
$ gcc --version
gcc (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0
(...)
 
$ objdump -i | grep elf32-i386
elf32-i386
         elf64-x86-64 elf32-i386 elf32-iamcu elf32-x86-64 a.out-i386-linux
    i386 elf64-x86-64 elf32-i386 ----------- elf32-x86-64 a.out-i386-linux
 
$ qemu-system-i386 --version
QEMU emulator version 2.11.1(Debian 1:2.11+dfsg-1ubuntu7.9)
Copyright (c) 2003-2017 Fabrice Bellard and the QEMU Project developers

It is ubuntu VM on windows, but the symptom was exactly same in another ubuntu 18.04 host PC.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.