Skip to content

BridJ (via JNAerator studio) fails to process simple code with includes throwing 'OutOfMemory' #205

Closed

Description

@lazyval

Here is the snippet of header file:

#include <iostream>

void printSome(int argc, int xs[]);

int intTest(int arg);

Pretty simple, yeah, but looks like BridJ has to parse out so after a while it fails. Here is the output of log:

/usr/include/c++/4.4.5/iostream:13:0: error: File not found: bits/c++config.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/iosfwd:13:0: error: File not found: bits/c++config.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/bits/stringfwd.h:14:0: error: File not found: bits/c++config.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/cwchar:18:0: error: File not found: bits/c++config.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/cstddef:18:0: error: File not found: bits/c++config.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/cstddef:19:0: error: File not found: stddef.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/exception:11:0: error: File not found: bits/c++config.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/bits/stl_algobase.h:38:0: error: File not found: bits/c++config.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/bits/functexcept.h:12:0: error: File not found: bits/c++config.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/bits/cpp_type_traits.h:14:0: error: File not found: bits/c++config.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/ext/type_traits.h:12:0: error: File not found: bits/c++config.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/bits/move.h:12:0: error: File not found: bits/c++config.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/bits/concept_check.h:13:0: error: File not found: bits/c++config.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/bits/stl_iterator_base_types.h:42:0: error: File not found: bits/c++config.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/cstdio:18:0: error: File not found: bits/c++config.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/stdio.h:28:0: error: File not found: stddef.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/_G_config.h:8:0: error: File not found: stddef.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/wchar.h:31:0: error: File not found: stddef.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/libio.h:35:0: error: File not found: stdarg.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/bits/localefwd.h:14:0: error: File not found: bits/c++config.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/bits/localefwd.h:15:0: error: File not found: bits/c++locale.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/cctype:18:0: error: File not found: bits/c++config.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/ext/atomicity.h:12:0: error: File not found: bits/c++config.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/ext/atomicity.h:13:0: error: File not found: bits/gthr.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/ext/atomicity.h:14:0: error: File not found: bits/atomic_word.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/string:13:0: error: File not found: bits/c++config.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/bits/allocator.h:25:0: error: File not found: bits/c++allocator.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/streambuf:13:0: error: File not found: bits/c++config.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/cwctype:18:0: error: File not found: bits/c++config.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/bits/locale_facets.h:15:0: error: File not found: bits/ctype_base.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/bits/locale_facets.h:1256:0: error: File not found: bits/ctype_inline.h in . /usr/include /usr/include/c++/4.4.5
Exception for /usr/include/c++/4.4.5/ios at line 1128:java.util.concurrent.ExecutionException: java.lang.Exception: java.lang.OutOfMemoryError: Java heap space
java.util.concurrent.ExecutionException: java.lang.Exception: java.lang.OutOfMemoryError: Java heap space
    at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:262)
    at java.util.concurrent.FutureTask.get(FutureTask.java:119)
    at com.ochafik.lang.jnaerator.JNAeratorParser.parseSlices(JNAeratorParser.java:177)
    at com.ochafik.lang.jnaerator.JNAeratorParser.parse(JNAeratorParser.java:213)
    at com.ochafik.lang.jnaerator.JNAerator.parseSources(JNAerator.java:1119)
    at com.ochafik.lang.jnaerator.JNAerator.jnaerate(JNAerator.java:837)
    at com.ochafik.lang.jnaerator.studio.JNAeratorStudio$14.run(JNAeratorStudio.java:607)
Caused by: java.lang.Exception: java.lang.OutOfMemoryError: Java heap space
    at com.ochafik.lang.jnaerator.JNAeratorParser$1.call(JNAeratorParser.java:147)
    at com.ochafik.lang.jnaerator.JNAeratorParser$1.call(JNAeratorParser.java:136)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:636)
Caused by: java.lang.OutOfMemoryError: Java heap space
----------
1. WARNING in file:///test/_IO_marker.java (at line 17)
    public _IO_marker(Pointer pointer) {
                      ^^^^^^^
Pointer is a raw type. References to generic type Pointer<T> should be parameterized
----------
2. WARNING in file:///test/_IO_marker.java (at line 18)
    super(pointer);
          ^^^^^^^
Type safety: The expression of type Pointer needs unchecked conversion to conform to Pointer<? extends StructObject>
----------
----------
3. WARNING in file:///test/_G_fpos64_t.java (at line 17)
    public _G_fpos64_t(Pointer pointer) {
                       ^^^^^^^
Pointer is a raw type. References to generic type Pointer<T> should be parameterized
----------
4. WARNING in file:///test/_G_fpos64_t.java (at line 18)
    super(pointer);
          ^^^^^^^
Type safety: The expression of type Pointer needs unchecked conversion to conform to Pointer<? extends StructObject>
----------
----------
5. WARNING in file:///test/_G_fpos_t.java (at line 17)
    public _G_fpos_t(Pointer pointer) {
                     ^^^^^^^
Pointer is a raw type. References to generic type Pointer<T> should be parameterized
----------
6. WARNING in file:///test/_G_fpos_t.java (at line 18)
    super(pointer);
          ^^^^^^^
Type safety: The expression of type Pointer needs unchecked conversion to conform to Pointer<? extends StructObject>
----------
----------
7. WARNING in file:///test/mbstate_t.java (at line 18)
    public mbstate_t(Pointer pointer) {
                     ^^^^^^^
Pointer is a raw type. References to generic type Pointer<T> should be parameterized
----------
8. WARNING in file:///test/mbstate_t.java (at line 19)
    super(pointer);
          ^^^^^^^
Type safety: The expression of type Pointer needs unchecked conversion to conform to Pointer<? extends StructObject>
----------
----------
9. WARNING in file:///test/TestLibrary.java (at line 619)
    return (Pointer<_IO_FILE >)BridJ.getNativeLibrary("test").getSymbolPointer("stdin").as(DefaultParameterizedType.paramType(Pointer.class, _IO_FILE.class)).get();
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Type safety: Unchecked cast from Object to Pointer<_IO_FILE>
----------
10. WARNING in file:///test/TestLibrary.java (at line 650)
    return (Pointer<_IO_FILE >)BridJ.getNativeLibrary("test").getSymbolPointer("stdout").as(DefaultParameterizedType.paramType(Pointer.class, _IO_FILE.class)).get();
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Type safety: Unchecked cast from Object to Pointer<_IO_FILE>
----------
11. WARNING in file:///test/TestLibrary.java (at line 680)
    return (Pointer<_IO_FILE >)BridJ.getNativeLibrary("test").getSymbolPointer("stderr").as(DefaultParameterizedType.paramType(Pointer.class, _IO_FILE.class)).get();
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Type safety: Unchecked cast from Object to Pointer<_IO_FILE>
----------
12. WARNING in file:///test/TestLibrary.java (at line 728)
    return (Pointer<Pointer<Byte > >)BridJ.getNativeLibrary("test").getSymbolPointer("sys_errlist").as(DefaultParameterizedType.paramType(Pointer.class, DefaultParameterizedType.paramType(Pointer.class, Byte.class))).get();
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Type safety: Unchecked cast from Object to Pointer<Pointer<Byte>>
----------
----------
13. WARNING in file:///test/__mbstate_t.java (at line 19)
    public __mbstate_t(Pointer pointer) {
                       ^^^^^^^
Pointer is a raw type. References to generic type Pointer<T> should be parameterized
----------
14. WARNING in file:///test/__mbstate_t.java (at line 20)
    super(pointer);
          ^^^^^^^
Type safety: The expression of type Pointer needs unchecked conversion to conform to Pointer<? extends StructObject>
----------
15. WARNING in file:///test/__mbstate_t.java (at line 57)
    public __value_union(Pointer pointer) {
                         ^^^^^^^
Pointer is a raw type. References to generic type Pointer<T> should be parameterized
----------
16. WARNING in file:///test/__mbstate_t.java (at line 58)
    super(pointer);
          ^^^^^^^
Type safety: The expression of type Pointer needs unchecked conversion to conform to Pointer<? extends StructObject>
----------
----------
17. WARNING in file:///test/_IO_FILE.java (at line 19)
    public _IO_FILE(Pointer pointer) {
                    ^^^^^^^
Pointer is a raw type. References to generic type Pointer<T> should be parameterized
----------
18. WARNING in file:///test/_IO_FILE.java (at line 20)
    super(pointer);
          ^^^^^^^
Type safety: The expression of type Pointer needs unchecked conversion to conform to Pointer<? extends StructObject>
----------
19. ERROR in file:///test/_IO_FILE.java (at line 525)
    @Array({15 * 4 - 4 * org.bridj.Pointer.SIZE - com.ochafik.lang.jnaerator.runtime.NativeSize.SIZE}) 
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The value for annotation attribute Array.value must be a constant expression
----------
----------
20. WARNING in file:///test/__locale_struct.java (at line 19)
    public __locale_struct(Pointer pointer) {
                           ^^^^^^^
Pointer is a raw type. References to generic type Pointer<T> should be parameterized
----------
21. WARNING in file:///test/__locale_struct.java (at line 20)
    super(pointer);
          ^^^^^^^
Type safety: The expression of type Pointer needs unchecked conversion to conform to Pointer<? extends StructObject>
----------
----------
22. WARNING in file:///test/__fsid_t.java (at line 18)
    public __fsid_t(Pointer pointer) {
                    ^^^^^^^
Pointer is a raw type. References to generic type Pointer<T> should be parameterized
----------
23. WARNING in file:///test/__fsid_t.java (at line 19)
    super(pointer);
          ^^^^^^^
Type safety: The expression of type Pointer needs unchecked conversion to conform to Pointer<? extends StructObject>
----------
23 problems (1 error, 22 warnings)

I don't care about warnings, but this one error is confusing.
I've tried to specify more memory to JNAerator appending -Xmx2g but even with 2g of ram result is the same. Is there some workaround?

My environment is
Ubuntu 10.10 x86 / JNAerator 0.9.9-SNAPSHOT
java version "1.6.0_20"
OpenJDK Runtime Environment (IcedTea6 1.9.10) (6b20-1.9.10-0ubuntu1~10.10.2)

Activity

  1. ochafik commented on Dec 12, 2011

    @ochafik
    Member

    Hello om-nom-nom,

    Thanks a lot for your bug report and sorry for the late response.
    Unfortunately there are still quite a few C++ parsing bugs in JNAerator's grammar.

    I've already added some obvious misses (like parsing delete[] !) and fixed some issues (std headers use __in as function argument name, but COM uses it as a modifier : had to make JNAerator's grammar even more context-aware), but it's still not parsing your sample fine. Please bear with me while I progress on it (I'll let you know of my progress here).

    Cheers

  2. ochafik commented on Dec 12, 2011

    @ochafik
    Member

    (FYI, you can download the latest development version of JNAerator with these fixes from here : http://nativelibs4java.sourceforge.net/maven/com/jnaerator/jnaerator/0.9.10-SNAPSHOT/ )

  3. ochafik commented on Mar 16, 2015

    @ochafik
    Member

    This issue was moved to nativelibs4java/JNAerator#21

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions