cloudius-systems / osv

OSv, a new operating system for the cloud.
osv.io
Other
4.11k stars 605 forks source link

Unable to use a boot a simple java 8 osv image #280

Closed posix4e closed 10 years ago

posix4e commented 10 years ago

posix4e@posix4e-Satellite-S55-A:~/project/osv8test$ capstan build Building osv8test... Fetching cloudius/osv-openjdk8/index.yaml...172 bytes downloaded. Fetching cloudius/osv-openjdk8/osv-openjdk8.qemu.gz...119406592 bytes downloaded. posix4e@posix4e-Satellite-S55-A:~/project/osv8test$ capstan images Name Description Version Created
cloudius/osv-openjdk8 OpenJDK 8/OSv base image for developers v0.07-45-g9d30d58 2014-04-23T15:18:13 osv8test posix4e@posix4e-Satellite-S55-A:~/project/osv8test$ capstan run Created instance: i1398285368 OSv v0.07-45-g9d30d58 Assertion failed: data.uio_resid == 0 (/home/penberg/osv/fs/fs.cc: read: 27)

[backtrace] 0x3c1397 <read(boost::intrusiveptr, void, unsigned long, unsigned long)+135> 0x32897c <elf::file::read(unsigned long, void_, unsigned long)+60> 0x328f2e elf::file::load_elf_header()+30 0x32b755 <elf::file::file(elf::program&, boost::intrusive_ptr, std::string)+101> 0x32dee3 <elf::program::getlibrary(std::string, std::vector<std::string, std::allocator >)+883> 0x3ba473 <osv::run(std::string, int, char*, int)+131> 0x3ba8bf <osv::run(std::string, std::vector<std::string, std::allocator >, int)+575> 0x20d535 <run_main(std::vector<std::string, std::allocator > const&)+245> 0x20f0df <do_mainthread(void)+1023> 0x4008a5 <sync+69> 0x3a4f1a <thread_main_c+26> 0x362345 <thread_main+7> qemu: terminating on signal 15 from pid 3241

posix4e@posix4e-Satellite-S55-A:~/project/osv8test$ cat Capstanfile base: cloudius/osv-openjdk8 cmdline: java -cp osv8test-1.0-SNAPSHOT-jar-with-dependencies.jar Java8Test build: mvn compile assembly:single files: /osv8test-1.0-SNAPSHOT-jar-with-dependencies.jar: target/osv8test-1.0-SNAPSHOT-jar-with-dependencies.jar posix4e@posix4e-Satellite-S55-A:~/project/osv8test$ cat pom.xml <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

4.0.0
<groupId>osv8test</groupId>
<artifactId>osv8test</artifactId>
<version>1.0-SNAPSHOT</version>

<build>
    <plugins>
        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <configuration>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
            </configuration>
        </plugin>
    </plugins>
</build>

posix4e@posix4e-Satellite-S55-A:~/project/osv8test$ cat Capstanfile .idea/ osv8test.iml pom.xml src/ target/
posix4e@posix4e-Satellite-S55-A:~/project/osv8test$ cat src/ main/ test/ posix4e@posix4e-Satellite-S55-A:~/project/osv8test$ cat src/main/ java/ resources/ posix4e@posix4e-Satellite-S55-A:~/project/osv8test$ cat src/main/java/Java8Test.java /**

avikivity commented 10 years ago

Can you attach the files? github ate some of the contents (esp. pom.xml) so I can't reproduce

posix4e commented 10 years ago

Wow we got avi and quick! Let me bundle it up for you. https://www.dropbox.com/s/zpqqfy5e6vxu1ig/osv8test.tar.gz

dorlaor commented 10 years ago

On Thu, Apr 24, 2014 at 12:25 AM, Alex Newman notifications@github.comwrote:

Wow we got avi and quick! Let me bundle it up for you.

Wow, we response from Alex, blazing fast!

https://www.dropbox.com/s/zpqqfy5e6vxu1ig/osv8test.tar.gz

Reply to this email directly or view it on GitHubhttps://github.com/cloudius-systems/osv/issues/280#issuecomment-41216838 .

penberg commented 10 years ago

It's reproducible here as well:

[penberg@localhost osv8test]$ capstan run
Building osv8test...
Created instance: i1398288968
OSv v0.07-45-g9d30d58
Assertion failed: data.uio_resid == 0 (/home/penberg/osv/fs/fs.cc: read: 27)

[backtrace]
0x3c1397 <read(boost::intrusive_ptr<file>, void*, unsigned long, unsigned long)+135>
0x32897c <elf::file::read(unsigned long, void*, unsigned long)+60>
0x328f2e <elf::file::load_elf_header()+30>
0x32b755 <elf::file::file(elf::program&, boost::intrusive_ptr<file>, std::string)+101>
0x32dee3 <elf::program::get_library(std::string, std::vector<std::string, std::allocator<std::string> >)+883>
0x3ba473 <osv::run(std::string, int, char**, int*)+131>
0x3ba8bf <osv::run(std::string, std::vector<std::string, std::allocator<std::string> >, int*)+575>
0x20d535 <run_main(std::vector<std::string, std::allocator<std::string> > const&)+245>
0x20f0df <do_main_thread(void*)+1023>
0x4008a5 <sync+69>
0x3a4f1a <thread_main_c+26>
0x362345 <thread_main+7>
avikivity commented 10 years ago

Problem is, capstan images are undebuggable because there is no way to extract loader.elf. I'll try to reproduce without capstan.

penberg commented 10 years ago

I used run.py to debug it. :smile:

The problem is in Capstanfile command line. Fixing it up to:

cmdline: /java.so -cp osv8test-1.0-SNAPSHOT-jar-with-dependencies.jar Java8Test

makes the image work. OSv should probably produce a better error message here.

penberg commented 10 years ago

@avikivity BTW, it's trivial to build a matching loader.elf based on the version number.

avikivity commented 10 years ago

Nice out of the box thinking, I was going to spend hours to find out the same thing

penberg commented 10 years ago

@posix4e Can you confirm that the suggested cmdline fix above makes things work for you?

We should keep the issue open until OSv produces a meaningful error message for this, though.

avikivity commented 10 years ago

Well you can try to build a matching one, but it's unlikely to be exact bit-for-bit.

gcc recently got some support for reproducible builds, but we probably need to invest some effort to make it work, and it won't work if the compilers aren't exactly matched.

penberg commented 10 years ago

@avikivity Sure. Fortunately it was good enough for this case.

If we change Capstan packaging to be file based, it's much easier to retrieve loader.elf as well (because it will always be sitting in our S3 bucket).

posix4e commented 10 years ago

wfm

glommer commented 10 years ago

On Thu, Apr 24, 2014 at 1:38 AM, Pekka Enberg notifications@github.comwrote:

It's reproducible here as well:

[penberg@localhost osv8test]$ capstan run Building osv8test... Created instance: i1398288968 OSv v0.07-45-g9d30d58 Assertion failed: data.uio_resid == 0 (/home/penberg/osv/fs/fs.cc: read: 27)

[backtrace] 0x3c1397 <read(boost::intrusiveptr, void, unsigned long, unsigned long)+135> 0x32897c <elf::file::read(unsigned long, void_, unsigned long)+60> 0x328f2e elf::file::load_elf_header()+30

what baffles me here is that there is only one read in load_elf_header, and that is reading a fixed size (sizeof(_ehdr))

0x32b755 <elf::file::file(elf::program&, boost::intrusive_ptr, std::string)+101> 0x32dee3 <elf::program::getlibrary(std::string, std::vector<std::string, std::allocator >)+883> 0x3ba473 <osv::run(std::string, int, char*, int)+131> 0x3ba8bf <osv::run(std::string, std::vector<std::string, std::allocator >, int)+575> 0x20d535 <run_main(std::vector<std::string, std::allocator > const&)+245> 0x20f0df <do_mainthread(void)+1023> 0x4008a5 <sync+69> 0x3a4f1a <thread_main_c+26> 0x362345 <thread_main+7>

Reply to this email directly or view it on GitHubhttps://github.com/cloudius-systems/osv/issues/280#issuecomment-41218229 .

avikivity commented 10 years ago

Yes, we'll have to consider whether we keep symbols in a separate file, or in the main file, and have capstan strip the files before embedding them.

avikivity commented 10 years ago

@glommer, the read failed since it was reading from a directory, that's all

glommer commented 10 years ago

On Thu, Apr 24, 2014 at 1:54 AM, Avi Kivity notifications@github.comwrote:

@glommer https://github.com/glommer, the read failed since it was reading from a directory, that's all

saw all that now. You guys are too fast.

Reply to this email directly or view it on GitHubhttps://github.com/cloudius-systems/osv/issues/280#issuecomment-41219739 .

avikivity commented 10 years ago

Just @posix4e and @penberg. I was going for the old fashioned way of diving in with the debugger.

nyh commented 10 years ago

On Thu, Apr 24, 2014 at 12:44 AM, Pekka Enberg notifications@github.comwrote:

I used run.py to debug it. [image: :smile:]

The problem is in Capstanfile command line. Fixing it up to:

cmdline: /java.so -cp osv8test-1.0-SNAPSHOT-jar-with-dependencies.jar Java8Test

makes the image work. OSv should probably produce a better error message here.

I think it is this bug: https://github.com/cloudius-systems/osv/issues/94

Reply to this email directly or view it on GitHubhttps://github.com/cloudius-systems/osv/issues/280#issuecomment-41218760 .

Nadav Har'El nyh@cloudius-systems.com

nyh commented 10 years ago

On Thu, Apr 24, 2014 at 12:54 AM, Avi Kivity notifications@github.comwrote:

@glommer https://github.com/glommer, the read failed since it was reading from a directory, that's all

Right - see https://github.com/cloudius-systems/osv/issues/94

Reply to this email directly or view it on GitHubhttps://github.com/cloudius-systems/osv/issues/280#issuecomment-41219739 .

Nadav Har'El nyh@cloudius-systems.com

penberg commented 10 years ago

@avikivity @nyh So what is the right course of action here? Which API call should fail gracely? We really need to fix up that assertion because it's very easy to trigger by users now.

nyh commented 10 years ago

As I explained in issue #94, the API that needs to be fixed is fs.cc's read() and write(). Those should not assert(), but rather fail in a graceful way, e.g., with an exception. We can and probably should catch this exception in elf.cc when we use this API, but even if we don't, the "unhandled exception" error will at least be clearer than a weird "assertion failure".

Please close this issue (#280) as a duplicate of #94. (and #94 should be fixed - I can do it if you don't plan to).

penberg commented 10 years ago

@nyh #280 is already closed.

Feel free to fix up #94. :wink:

nyh commented 10 years ago

Will do. There's so much discussion on #280, I didn't realized someone already closed it ;-)