Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segfault when globbing on non-existing dir using raw Java interop #1055

Closed
borkdude opened this issue Nov 7, 2021 · 0 comments
Closed

Segfault when globbing on non-existing dir using raw Java interop #1055

borkdude opened this issue Nov 7, 2021 · 0 comments

Comments

@borkdude
Copy link
Collaborator

borkdude commented Nov 7, 2021

With bb this segfaults.

(ns dude
  (:import
   [java.io File]
   [java.nio.file FileSystems FileVisitor FileVisitResult Files Path])
  (:gen-class))

(defn match-paths
  "Match glob to paths under root and return a collection of Path objects"
  [^File root glob]
  (let [root-path (.toPath root)
        matcher (.getPathMatcher (FileSystems/getDefault) (str "glob:" glob))
        paths (volatile! [])
        visitor (reify FileVisitor
                  (visitFile [_ path attrs]
                    (when (.matches matcher (.relativize root-path ^Path path))
                      (vswap! paths conj path))
                    FileVisitResult/CONTINUE)
                  (visitFileFailed [_ path ex] FileVisitResult/CONTINUE)
                  (preVisitDirectory [_ _ _] FileVisitResult/CONTINUE)
                  (postVisitDirectory [_ _ _] FileVisitResult/CONTINUE))]
    (Files/walkFileTree root-path visitor)
    @paths))

(defn -main [& _xs]
  (prn (count (match-paths (File. "non-existing") "**"))))
$ ~/Dropbox/dev/clojure/babashka/bb -cp . -m dude

Printing Instructions (ip=0x00000001057225e2):
  0x00000001057225c2: 0xf8 0xff 0xff 0xff 0x48 0x23 0x33 0x49 0x8b 0x84 0x36 0x28 0x01 0x00 0x00 0x48
  0x00000001057225d2: 0x8b 0x71 0x18 0x49 0x8d 0x34 0x36 0x49 0x8d 0x14 0x3e 0x48 0x8b 0xfb 0xff 0xd0
  0x00000001057225e2: 0x90 0xe9 0x2b 0xfd 0xff 0xff 0x48 0x8b 0x5c 0x24 0x38 0x49 0x3b 0xde 0x0f 0x84
  0x00000001057225f2: 0xc7 0x01 0x00 0x00 0x48 0xc7 0xc7 0xf8 0xff 0xff 0xff 0x48 0x23 0x3b 0x49 0x8b

Top of stack (sp=0x00007ffeeb608220):
  0x00007ffeeb608220: 0x0000000900000111 0x00000001058dc01f
  0x00007ffeeb608230: 0x0000000109ebc288 0x000000010bc6c218
  0x00007ffeeb608240: 0x000000010cf81cb8 0x000000010cf79828
  0x00007ffeeb608250: 0x000000010cf85cc8 0x000000010cf7f768
  0x00007ffeeb608260: 0x000000010a6bc0a0 0x0000000105722196
  0x00007ffeeb608270: 0x0000000109ebc288 0x000000010cf79828
  0x00007ffeeb608280: 0x000000010cf7f768 0x0000000104d997e3
  0x00007ffeeb608290: 0x0000000109f08c68 0x0000000104eda112
  0x00007ffeeb6082a0: 0x000000090b2fc8e8 0x0000000105efa2ec
  0x00007ffeeb6082b0: 0x000000010cf7fb40 0x0000000104a06afc
  0x00007ffeeb6082c0: 0x000000010cf81cb8 0x000000010b2fc8e8
  0x00007ffeeb6082d0: 0x0000000109ebd088 0x000000010cf85798
  0x00007ffeeb6082e0: 0x000000010cf81cb8 0x000000010cf85678
  0x00007ffeeb6082f0: 0x0000000000d819a8 0x000000010cea8b30
  0x00007ffeeb608300: 0x000000010cf7fca0 0x0000000109900000
  0x00007ffeeb608310: 0x0000000300000001 0x0000004f0000004e
  0x00007ffeeb608320: 0x0000000200000001 0x0000000105efacd9
  0x00007ffeeb608330: 0x000000010a81ac88 0x000000010cea8b30
  0x00007ffeeb608340: 0x000000010cf7fca0 0x0000000105ff06b1
  0x00007ffeeb608350: 0x0000000000000050 0x0000000a00000000
  0x00007ffeeb608360: 0x0000000109f08c68 0x000000010cea8b30
  0x00007ffeeb608370: 0x000000010cf7f9b8 0x0000000105f914ba
  0x00007ffeeb608380: 0x0000000001ed5168 0x0000000104a5998e
  0x00007ffeeb608390: 0x000000010cf7f7a0 0x000000010cf7f940
  0x00007ffeeb6083a0: 0x000000010cf7f900 0x000000010cf7f810
  0x00007ffeeb6083b0: 0x000000010cdd0aa8 0x0000000105f11e7e
  0x00007ffeeb6083c0: 0xffffffff0000000c 0x0000000104a29943
  0x00007ffeeb6083d0: 0x000000010cdd0aa8 0x000000010cf7f810
  0x00007ffeeb6083e0: 0x000000010cf5f628 0x0000000105f8b2ce
  0x00007ffeeb6083f0: 0x000000010cf7ea50 0x000000010ceb00f0
  0x00007ffeeb608400: 0x000000010cdd0aa8 0x000000010cf7f810
  0x00007ffeeb608410: 0x000000010cf5f660 0x0000000105f8b1fc

Top frame info:
  TotalFrameSize in CodeInfoTable 80

Threads:
  0x00007f8d435064c0 STATUS_IN_NATIVE "Signal Dispatcher" - java.lang.Thread@0x000000010cb13200, daemon, stack(0x000070000155a000,0x00007000015da000)
  0x00007f8d43506380 STATUS_IN_JAVA (safepoints disabled) "main" - java.lang.Thread@0x000000010ac60368, stack(0x00007ffeeae0b000,0x00007ffeeb60b000)

VM thread locals for the failing thread 0x00007f8d43506380:
  0 (8 bytes): com.oracle.svm.jni.JNIThreadLocalEnvironment.jniFunctions = (bytes)
    0x00007f8d43506380: 0x000000010a26e010
  8 (8 bytes): com.oracle.svm.core.graal.snippets.StackOverflowCheckImpl.stackBoundaryTL = (Word) 1 (0x0000000000000001)
  16 (4 bytes): com.oracle.svm.core.thread.Safepoint.safepointRequested = (int) 2146661666 (0x7ff37522)
  20 (4 bytes): com.oracle.svm.core.thread.VMThreads$StatusSupport.statusTL = (int) 1 (0x00000001)
  24 (32 bytes): com.oracle.svm.core.genscavenge.ThreadLocalAllocation.regularTLAB = (bytes)
    0x00007f8d43506398: 0x000000010cf00000 0x000000010d000000
    0x00007f8d435063a8: 0x000000010cf8af90 0x0000000000000000
  56 (8 bytes): com.oracle.svm.core.thread.JavaThreads.currentThread = (Object) java.lang.Thread (0x000000010ac60368)
  64 (8 bytes): com.oracle.svm.core.stack.JavaFrameAnchors.lastAnchor = (Word) 0 (0x0000000000000000)
  72 (8 bytes): com.oracle.svm.core.heap.NoAllocationVerifier.openVerifiers = (Object) null
  80 (8 bytes): com.oracle.svm.core.identityhashcode.IdentityHashCodeSupport.hashCodeGeneratorTL = (Object) java.util.SplittableRandom (0x000000010cf6b1a8)
  88 (8 bytes): com.oracle.svm.core.snippets.ExceptionUnwind.currentException = (Object) null
  96 (8 bytes): com.oracle.svm.core.thread.ThreadingSupportImpl.activeTimer = (Object) null
  104 (8 bytes): com.oracle.svm.graal.isolated.IsolatedCompileClient.currentClient = (Object) null
  112 (8 bytes): com.oracle.svm.graal.isolated.IsolatedCompileContext.currentContext = (Object) null
  120 (8 bytes): com.oracle.svm.jni.JNIObjectHandles.handles = (Object) com.oracle.svm.core.handles.ThreadLocalHandles (0x000000010cb01250)
  128 (8 bytes): com.oracle.svm.jni.JNIThreadLocalPendingException.pendingException = (Object) null
  136 (8 bytes): com.oracle.svm.jni.JNIThreadLocalPinnedObjects.pinnedObjectsListHead = (Object) null
  144 (8 bytes): com.oracle.svm.jni.JNIThreadOwnedMonitors.ownedMonitors = (Object) null
  152 (8 bytes): com.oracle.svm.core.SubstrateDiagnostics.threadOnlyAttachedForCrashHandler = (bytes)
    0x00007f8d43506418: 0x0000000000000000
  160 (8 bytes): com.oracle.svm.core.thread.VMThreads.IsolateTL = (Word) 4455399424 (0x0000000109900000)
  168 (8 bytes): com.oracle.svm.core.thread.VMThreads.OSThreadHandleTL = (Word) 4531371520 (0x000000010e173e00)
  176 (8 bytes): com.oracle.svm.core.thread.VMThreads.OSThreadIdTL = (Word) 4531371520 (0x000000010e173e00)
  184 (8 bytes): com.oracle.svm.core.thread.VMThreads.StackBase = (Word) 140732847403008 (0x00007ffeeb60b000)
  192 (8 bytes): com.oracle.svm.core.thread.VMThreads.StackEnd = (Word) 140732839014400 (0x00007ffeeae0b000)
  200 (8 bytes): com.oracle.svm.core.thread.VMThreads.nextTL = (Word) 0 (0x0000000000000000)
  208 (8 bytes): com.oracle.svm.core.thread.VMThreads.unalignedIsolateThreadMemoryTL = (Word) 140244696458080 (0x00007f8d43506360)
  216 (4 bytes): com.oracle.svm.core.graal.snippets.StackOverflowCheckImpl.yellowZoneStateTL = (int) 2130640638 (0x7efefefe)
  220 (4 bytes): com.oracle.svm.core.snippets.ImplicitExceptions.implicitExceptionsAreFatal = (int) 0 (0x00000000)
  224 (4 bytes): com.oracle.svm.core.thread.ThreadingSupportImpl.currentPauseDepth = (int) 0 (0x00000000)
  228 (4 bytes): com.oracle.svm.core.thread.VMThreads$ActionOnExitSafepointSupport.actionTL = (int) 0 (0x00000000)
  232 (4 bytes): com.oracle.svm.core.thread.VMThreads$ActionOnTransitionToJavaSupport.actionTL = (int) 0 (0x00000000)
  236 (4 bytes): com.oracle.svm.core.thread.VMThreads$StatusSupport.safepointsDisabledTL = (int) 1 (0x00000001)

No VMOperation in progress

The 10 most recent VM operation status changes (oldest first):

Counters:

Java frame anchors for the failing thread 0x00007f8d43506380:
  No anchors

Stacktrace for the failing thread 0x00007f8d43506380:
  SP 0x00007ffeeb608220 IP 0x00000001057225e2  [image code] java.nio.file.Files.walkFileTree(Files.java:2813)
  SP 0x00007ffeeb608270 IP 0x0000000105722196  [image code] java.nio.file.Files.walkFileTree(Files.java:2882)
  SP 0x00007ffeeb608290 IP 0x0000000104d997e3  [image code] com.oracle.svm.core.reflect.ReflectionAccessorHolder.Files_walkFileTree_1d2a74e40d7feb33a0309c4253fdb0c15c3856d0(ReflectionAccessorHolder.java:0)
  SP 0x00007ffeeb6082a0 IP 0x0000000104eda112  [image code] com.oracle.svm.core.reflect.SubstrateMethodAccessor.invoke(SubstrateMethodAccessor.java:59)
  SP 0x00007ffeeb6082b0 IP 0x0000000105efa2ec  [image code] java.lang.reflect.Method.invoke(Method.java:568)
  SP 0x00007ffeeb6082b0 IP 0x0000000105efa2ec  [image code] sci.impl.Reflector.invokeMatchingMethod(Reflector.java:172)
  SP 0x00007ffeeb608330 IP 0x0000000105efacd9  [image code] sci.impl.Reflector.invokeStaticMethod(Reflector.java:337)
  SP 0x00007ffeeb608350 IP 0x0000000105ff06b1  [image code] sci.impl.interop$invoke_static_method.invokeStatic(interop.cljc:61)
  SP 0x00007ffeeb608380 IP 0x0000000105f914ba  [image code] sci.impl.evaluator$eval_static_method_invocation.invokeStatic(evaluator.cljc:176)
  SP 0x00007ffeeb6083c0 IP 0x0000000105f11e7e  [image code] sci.impl.analyzer$expand_dot$fn__2758.invoke(analyzer.cljc:718)
  SP 0x00007ffeeb6083f0 IP 0x0000000105f8b2ce  [image code] sci.impl.evaluator$eval.invokeStatic(evaluator.cljc:334)
  SP 0x00007ffeeb608420 IP 0x0000000105f8b1fc  [image code] sci.impl.evaluator$eval.invoke(evaluator.cljc:328)
  SP 0x00007ffeeb608430 IP 0x0000000105f8ff2c  [image code] sci.impl.evaluator$eval_let.invokeStatic(evaluator.cljc:76)
  SP 0x00007ffeeb608460 IP 0x0000000105f1ae9f  [image code] sci.impl.analyzer$expand_let_STAR_$fn__2637.invoke(analyzer.cljc:396)
  SP 0x00007ffeeb608470 IP 0x0000000105f8b2ce  [image code] sci.impl.evaluator$eval.invokeStatic(evaluator.cljc:334)
  SP 0x00007ffeeb6084a0 IP 0x0000000105fb6792  [image code] sci.impl.fns$fun$arity_2__1275.invoke(fns.cljc:149)
  SP 0x00007ffeeb6084d0 IP 0x00000001060e33aa  [image code] sci.impl.vars.SciVar.invoke(vars.cljc:325)
  SP 0x00007ffeeb6084f0 IP 0x0000000105f31a69  [image code] sci.impl.analyzer$return_call$fn__2974.invoke(analyzer.cljc:1036)
  SP 0x00007ffeeb608530 IP 0x0000000105f8b2ce  [image code] sci.impl.evaluator$eval.invokeStatic(evaluator.cljc:334)
  SP 0x00007ffeeb608560 IP 0x0000000105f31754  [image code] sci.impl.analyzer$return_call$fn__2970.invoke(analyzer.cljc:1036)
  SP 0x00007ffeeb608580 IP 0x0000000105f8b2ce  [image code] sci.impl.evaluator$eval.invokeStatic(evaluator.cljc:334)
  SP 0x00007ffeeb6085b0 IP 0x0000000105f31754  [image code] sci.impl.analyzer$return_call$fn__2970.invoke(analyzer.cljc:1036)
  SP 0x00007ffeeb6085d0 IP 0x0000000105f8b2ce  [image code] sci.impl.evaluator$eval.invokeStatic(evaluator.cljc:334)
  SP 0x00007ffeeb608600 IP 0x0000000105fbe3e0  [image code] sci.impl.fns$fun$varargs__1751.doInvoke(fns.cljc:90)
  SP 0x00007ffeeb608640 IP 0x0000000104a7886c  [image code] clojure.lang.RestFn.invoke(RestFn.java:397)
  SP 0x00007ffeeb608660 IP 0x00000001049cb16b  [image code] clojure.lang.AFn.applyToHelper(AFn.java:152)
  SP 0x00007ffeeb6087b0 IP 0x0000000104a732ea  [image code] clojure.lang.RestFn.applyTo(RestFn.java:132)
  SP 0x00007ffeeb6088a0 IP 0x00000001047ddb80  [image code] clojure.core$apply.invokeStatic(core.clj:667)
  SP 0x00007ffeeb6088c0 IP 0x00000001047dd9e9  [image code] clojure.core$apply.invoke(core.clj:662)
  SP 0x00007ffeeb6088d0 IP 0x00000001060e33aa  [image code] sci.impl.vars.SciVar.invoke(vars.cljc:325)
  SP 0x00007ffeeb6088f0 IP 0x0000000105f31a69  [image code] sci.impl.analyzer$return_call$fn__2974.invoke(analyzer.cljc:1036)
  SP 0x00007ffeeb608930 IP 0x0000000105f8b2ce  [image code] sci.impl.evaluator$eval.invokeStatic(evaluator.cljc:334)
  SP 0x00007ffeeb608960 IP 0x0000000105ff12a0  [image code] sci.impl.interpreter$eval_form.invokeStatic(interpreter.cljc:44)
  SP 0x00007ffeeb6089b0 IP 0x0000000105ff1604  [image code] sci.impl.interpreter$eval_string_STAR_.invokeStatic(interpreter.cljc:59)
  SP 0x00007ffeeb6089f0 IP 0x00000001047208b9  [image code] sci.core$eval_string_STAR_.invokeStatic(core.cljc:236)
  SP 0x00007ffeeb6089f0 IP 0x00000001047208b9  [image code] babashka.main$exec$fn__35212$fn__35213.invoke(main.clj:827)
  SP 0x00007ffeeb608a10 IP 0x00000001047219fb  [image code] babashka.main$exec$fn__35212.invoke(main.clj:827)
  SP 0x00007ffeeb608ab0 IP 0x00000001047296a5  [image code] babashka.main$exec.invokeStatic(main.clj:817)
  SP 0x00007ffeeb608c70 IP 0x000000010472c2aa  [image code] babashka.main$main.invokeStatic(main.clj:897)
  SP 0x00007ffeeb608ca0 IP 0x000000010472bfa5  [image code] babashka.main$main.doInvoke(main.clj:884)
  SP 0x00007ffeeb608cb0 IP 0x0000000104a733d9  [image code] clojure.lang.RestFn.applyTo(RestFn.java:137)
  SP 0x00007ffeeb608da0 IP 0x00000001047ddb80  [image code] clojure.core$apply.invokeStatic(core.clj:667)
  SP 0x00007ffeeb608dc0 IP 0x000000010471e2f7  [image code] babashka.main$_main.invokeStatic(main.clj:931)
  SP 0x00007ffeeb608e50 IP 0x000000010471d345  [image code] babashka.main$_main.doInvoke(main.clj:923)
  SP 0x00007ffeeb608e60 IP 0x0000000104a733d9  [image code] clojure.lang.RestFn.applyTo(RestFn.java:137)
  SP 0x00007ffeeb608f50 IP 0x0000000104739c5c  [image code] babashka.main.main(Unknown Source)
  SP 0x00007ffeeb608f70 IP 0x0000000104cb0e56  [image code] com.oracle.svm.core.JavaMainWrapper.runCore(JavaMainWrapper.java:147)
  SP 0x00007ffeeb608f70 IP 0x0000000104cb0e56  [image code] com.oracle.svm.core.JavaMainWrapper.run(JavaMainWrapper.java:183)
  SP 0x00007ffeeb608f70 IP 0x0000000104cb0e56  [image code] com.oracle.svm.core.code.IsolateEnterStub.JavaMainWrapper_run_5087f5482cc9a6abc971913ece43acb471d2631b(IsolateEnterStub.java:0)

VM mutexes:
  mutex "referencePendingList" is unlocked.
  mutex "thread" is unlocked.
  mutex "mainVMOperationControlWorkQueue" is unlocked.

Heap settings and statistics:
  Supports isolates: true
  Heap base: 0x0000000109900000
  Object reference size: 8
  Aligned chunk size: 1048576
  Incremental collections: 0
  Complete collections: 0

Native image heap boundaries:
  ReadOnly Primitives: 0x0000000109a01028 - 0x0000000109e9d750
  ReadOnly References: 0x0000000109e9d750 - 0x000000010a26df88
  ReadOnly Relocatables: 0x000000010a26e000 - 0x000000010a8c30b0
  Writable Primitives: 0x000000010a8c4000 - 0x000000010a9fdc60
  Writable References: 0x000000010a9fdc60 - 0x000000010bf231d8
  Writable Huge: 0x000000010c000030 - 0x000000010c08c0e0
  ReadOnly Huge: 0x000000010c08d030 - 0x000000010cadc7c8

Heap:
  Young generation:
    Eden:
      edenSpace:
        aligned: 0/0 unaligned: 0/0
    Survivors:

  Old generation:
    oldFromSpace:
      aligned: 0/0 unaligned: 0/0
    oldToSpace:
      aligned: 0/0 unaligned: 0/0

  Unused:
    aligned: 0/0

Fatal error: Virtual method call used an illegal vtable entry that was seen as unused by the static analysis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant