File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed
src/main/java/org/truffleruby/cext Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change 16
16
import org .truffleruby .collections .LongHashMap ;
17
17
import org .truffleruby .extra .ffi .Pointer ;
18
18
import org .truffleruby .language .NotProvided ;
19
-
20
19
import com .oracle .truffle .api .CompilerDirectives .CompilationFinal ;
21
20
import com .oracle .truffle .api .CompilerDirectives .TruffleBoundary ;
22
21
import com .oracle .truffle .api .object .DynamicObject ;
@@ -107,8 +106,11 @@ public synchronized void removeFromHandleMap(long handle) {
107
106
108
107
@ TruffleBoundary
109
108
public synchronized long createNativeHandle (DynamicObject wrapper ) {
110
- Pointer handlePointer = Pointer .malloc (8 );
109
+ Pointer handlePointer = Pointer .malloc (1 );
111
110
long handleAddress = handlePointer .getAddress ();
111
+ if ((handleAddress & 0x7 ) != 0 ) {
112
+ throw new RuntimeException ("unaligned malloc for native handle" );
113
+ }
112
114
Layouts .VALUE_WRAPPER .setHandle (wrapper , handleAddress );
113
115
addToHandleMap (handleAddress , wrapper );
114
116
addFinalizer (wrapper , handlePointer );
You can’t perform that action at this time.
0 commit comments