jayduhon / inferno-os

Automatically exported from code.google.com/p/inferno-os
2 stars 0 forks source link

asm: "Segmentation fault" on input without source definitoin #243

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
As I can see the asm/ assembler is not documented anywhere. Reading the manual 
let me assume that disdump is the reverse operation of what asm would do, i.e., 
something like 'disdump some.dis | asm' I would have assumed produced the 
original. Of course this is not the case but after reading asm/asm.y and trying 
with a simple file that is according to the grammar:
ret

causes asm to produce nothing but "Segmentation fault".

What is the expected output? What do you see instead?

Something else that "Segmentation fault".

Which operating system are you using?

Ubuntu Linux.

Please provide any additional information below.

The following is one possible fix:

diff -r bcd3cb9be2a0 asm/asm.h
--- a/asm/asm.h Sat Sep 25 14:04:43 2010 +0100
+++ b/asm/asm.h Thu Nov 25 14:49:06 2010 +0200
@@ -123,7 +123,7 @@
 void excs(int);
 void exc(int, int, int, int, int, int);
 void etab(String*, int);
-void source(String*);
+void source(char*);

 int    yyparse(void);
 int    yylex(void);
diff -r bcd3cb9be2a0 asm/asm.y
--- a/asm/asm.y Sat Sep 25 14:04:43 2010 +0100
+++ b/asm/asm.y Thu Nov 25 14:49:06 2010 +0200
@@ -247,7 +247,7 @@
    }
    | TOKSRC TSTRING
    {
-       source($2);
+       source($2->string);
    }
    ;

diff -r bcd3cb9be2a0 asm/assem.c
--- a/asm/assem.c   Sat Sep 25 14:04:43 2010 +0100
+++ b/asm/assem.c   Thu Nov 25 14:49:06 2010 +0200
@@ -666,7 +666,7 @@
 }

 void
-source(String *s)
+source(char *s)
 {
-   srcpath = s->string;
+   srcpath = s;
 }
diff -r bcd3cb9be2a0 asm/lex.c
--- a/asm/lex.c Sat Sep 25 14:04:43 2010 +0100
+++ b/asm/lex.c Thu Nov 25 14:49:06 2010 +0200
@@ -78,6 +78,7 @@
    if(argc != 1)
        usage();
    file = argv[0];
+   source(file);
    bin = Bopen(file, OREAD);
    if(bin == 0) {
        nerr++;

Original issue reported on code.google.com by jani.lah...@gmail.com on 25 Nov 2010 at 12:51

GoogleCodeExporter commented 9 years ago
that's indeed rather poor form.

Original comment by Charles....@gmail.com on 25 Nov 2010 at 1:35

GoogleCodeExporter commented 9 years ago
committed changeset 463:12f5a6906e6c
pushing to https://Charles.Forsyth:***@inferno-os.googlecode.com/hg

Original comment by Charles....@gmail.com on 25 Nov 2010 at 2:34