[PATCH] vm: fix unwrap_and_set_field()

2009-10-09 Thread Tomek Grabiec
'This' pointer was not passed to vm_call_method_this_a() in args which
caused a SIGSEGV inside that function.

Signed-off-by: Tomek Grabiec 
---
 vm/call.c   |1 +
 vm/reflection.c |6 --
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/vm/call.c b/vm/call.c
index a33e6a7..cc2f84d 100644
--- a/vm/call.c
+++ b/vm/call.c
@@ -83,6 +83,7 @@ unsigned long vm_call_method_this_a(struct vm_method *method,
void *target;
 
target = this->class->vtable.native_ptr[method->virtual_index];
+   assert(args != NULL);
assert(args[0] == (unsigned long) this);
 
return call_method_a(method, target, args);
diff --git a/vm/reflection.c b/vm/reflection.c
index 5ce258d..c7fc9e5 100644
--- a/vm/reflection.c
+++ b/vm/reflection.c
@@ -627,6 +627,8 @@ jint native_field_get_modifiers_internal(struct vm_object 
*this)
 static int unwrap_and_set_field(void *field_ptr, enum vm_type type,
struct vm_object *value)
 {
+   unsigned long args[] = { (unsigned long) value };
+
switch (type) {
case J_REFERENCE:
*(jobject *) field_ptr = value;
@@ -641,11 +643,11 @@ static int unwrap_and_set_field(void *field_ptr, enum 
vm_type type,
 * returned by ireturn anyway.
 */
*(long *) field_ptr = 
vm_call_method_this_a(vm_java_lang_Number_intValue,
-   value, NULL);
+   value, args);
return 0;
case J_FLOAT:
*(jfloat *) field_ptr = (jfloat) 
vm_call_method_this_a(vm_java_lang_Number_floatValue,
-  value, 
NULL);
+  value, 
args);
return 0;
case J_LONG:
case J_DOUBLE:
-- 
1.6.0.4


--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
___
Jatovm-devel mailing list
Jatovm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jatovm-devel


Re: [PATCH] cafebabe: fix bug in cafebabe_stream_close()

2009-10-09 Thread Vegard Nossum
2009/10/9 Tomek Grabiec :
> The bracket was misplaced causing close() to use wrong file descriptor.
> This led to the following error message for tetris:
> .: Fatal IO error 9 (Bad file descriptor) on X server :0.0.
>
> CC: Vegard Nossum 
> Signed-off-by: Tomek Grabiec 
> ---
>  cafebabe/src/cafebabe/stream.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/cafebabe/src/cafebabe/stream.c b/cafebabe/src/cafebabe/stream.c
> index 2d45484..79b1f9c 100644
> --- a/cafebabe/src/cafebabe/stream.c
> +++ b/cafebabe/src/cafebabe/stream.c
> @@ -103,7 +103,7 @@ cafebabe_stream_close(struct cafebabe_stream *s)
>
>        /* We try not to leak file descriptors. */
>        do {
> -               if (close(s->fd == -1)) {
> +               if (close(s->fd) == -1) {
>                        if (errno == EINTR)
>                                continue;
>
> --
> 1.6.0.4
>
>

Wowowow, what a crazy bug!

Thanks a bunch.


Vegard

--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
___
Jatovm-devel mailing list
Jatovm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jatovm-devel


[penberg/jato] 617630: cafebabe: fix bug in cafebabe_stream_close()

2009-10-09 Thread noreply
Branch: refs/heads/master
Home:   http://github.com/penberg/jato

Commit: 617630bb062b5231666bc3e0f4415bd65b685e6c

http://github.com/penberg/jato/commit/617630bb062b5231666bc3e0f4415bd65b685e6c
Author: Tomek Grabiec 
Date:   2009-10-09 (Fri, 09 Oct 2009)

Changed paths:
  M cafebabe/src/cafebabe/stream.c

Log Message:
---
cafebabe: fix bug in cafebabe_stream_close()

The bracket was misplaced causing close() to use wrong file descriptor.
This led to the following error message for tetris:
.: Fatal IO error 9 (Bad file descriptor) on X server :0.0.

CC: Vegard Nossum 
Signed-off-by: Tomek Grabiec 
Signed-off-by: Pekka Enberg 


Commit: 71a1efd104e0c36bb75da8818e801489a8e11d8c

http://github.com/penberg/jato/commit/71a1efd104e0c36bb75da8818e801489a8e11d8c
Author: Tomek Grabiec 
Date:   2009-10-09 (Fri, 09 Oct 2009)

Changed paths:
  M vm/call.c
  M vm/reflection.c

Log Message:
---
vm: fix call_virtual_method()

'This' pointer must be added to args manually. vm_call_method_this_a()
expects that it is already in args to avoid unnecessary copying.

Signed-off-by: Tomek Grabiec 
Signed-off-by: Pekka Enberg 



--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
___
Jatovm-devel mailing list
Jatovm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jatovm-devel


[PATCH] vm: fix call_virtual_method()

2009-10-09 Thread Tomek Grabiec
'This' pointer must be added to args manually. vm_call_method_this_a()
expects that it is already in args to avoid unnecessary copying.

Signed-off-by: Tomek Grabiec 
---
 vm/call.c   |6 +-
 vm/reflection.c |3 ++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/vm/call.c b/vm/call.c
index eaf2b4f..a33e6a7 100644
--- a/vm/call.c
+++ b/vm/call.c
@@ -80,7 +80,11 @@ unsigned long vm_call_method_this_a(struct vm_method *method,
struct vm_object *this,
unsigned long *args)
 {
-   void *target = this->class->vtable.native_ptr[method->virtual_index];
+   void *target;
+
+   target = this->class->vtable.native_ptr[method->virtual_index];
+   assert(args[0] == (unsigned long) this);
+
return call_method_a(method, target, args);
 }
 
diff --git a/vm/reflection.c b/vm/reflection.c
index 80db700..5ce258d 100644
--- a/vm/reflection.c
+++ b/vm/reflection.c
@@ -736,7 +736,8 @@ call_virtual_method(struct vm_method *vmm, struct vm_object 
*o,
 {
unsigned long args[vmm->args_count];
 
-   if (marshall_call_arguments(vmm, args, args_array))
+   args[0] = (unsigned long) o;
+   if (marshall_call_arguments(vmm, args + 1, args_array))
return NULL;
 
return (struct vm_object *) vm_call_method_this_a(vmm, o, args);
-- 
1.6.0.4


--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
___
Jatovm-devel mailing list
Jatovm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jatovm-devel


[PATCH] cafebabe: fix bug in cafebabe_stream_close()

2009-10-09 Thread Tomek Grabiec
The bracket was misplaced causing close() to use wrong file descriptor.
This led to the following error message for tetris:
.: Fatal IO error 9 (Bad file descriptor) on X server :0.0.

CC: Vegard Nossum 
Signed-off-by: Tomek Grabiec 
---
 cafebabe/src/cafebabe/stream.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/cafebabe/src/cafebabe/stream.c b/cafebabe/src/cafebabe/stream.c
index 2d45484..79b1f9c 100644
--- a/cafebabe/src/cafebabe/stream.c
+++ b/cafebabe/src/cafebabe/stream.c
@@ -103,7 +103,7 @@ cafebabe_stream_close(struct cafebabe_stream *s)
 
/* We try not to leak file descriptors. */
do {
-   if (close(s->fd == -1)) {
+   if (close(s->fd) == -1) {
if (errno == EINTR)
continue;
 
-- 
1.6.0.4


--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
___
Jatovm-devel mailing list
Jatovm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jatovm-devel