[CLJ-47] GC Issue 43: Dead code in generated bytecode Created: 17/Jun/09 Updated: 08/Oct/10 |
|
| Status: | Open |
| Project: | Clojure |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | Approved Backlog |
| Type: | Defect | ||
| Reporter: | Anonymous | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Approval: | Vetted |
| Description |
Reported by Levente.Santha, Jan 11, 2009 The bug was described in detail in this thread: http://groups.google.com/ group/clojure/browse_thread/thread/81ba15d7e9130441 For clojure.core$last__2954.invoke the correct bytecode would be (notice the removed "goto 65" after "41: goto 0"): public java.lang.Object invoke(java.lang.Object) throws java.lang.Exception; Code: 0: getstatic #22; //Field const__0:Lclojure/lang/Var; 3: invokevirtual #37; //Method clojure/lang/Var.get:()Ljava/lang/ Object; 6: checkcast #39; //class clojure/lang/IFn 9: aload_1 10: invokeinterface #41, 2; //InterfaceMethod clojure/lang/IFn.invoke: (Ljava/lang/Object;)Ljava/lang/Object; 15: dup 16: ifnull 44 19: getstatic #47; //Field java/lang/Boolean.FALSE:Ljava/lang/ Boolean; 22: if_acmpeq 45 25: getstatic #22; //Field const__0:Lclojure/lang/Var; 28: invokevirtual #37; //Method clojure/lang/Var.get:()Ljava/lang/ Object; 31: checkcast #39; //class clojure/lang/IFn 34: aload_1 35: invokeinterface #41, 2; //InterfaceMethod clojure/lang/IFn.invoke: (Ljava/lang/Object;)Ljava/lang/Object; 40: astore_1 41: goto 0 44: pop 45: getstatic #26; //Field const__1:Lclojure/lang/Var; 48: invokevirtual #37; //Method clojure/lang/Var.get:()Ljava/lang/ Object; 51: checkcast #39; //class clojure/lang/IFn 54: aload_1 55: aconst_null 56: astore_1 57: invokeinterface #41, 2; //InterfaceMethod clojure/lang/IFn.invoke: (Ljava/lang/Object;)Ljava/lang/Object; 62: areturn Our JIT reported incorrect stack size along the basic block introduced by the unneeded goto. The bug was present in SVN rev 1205. |
| Comments |
| Comment by Assembla Importer [ 08/Oct/10 10:21 AM ] |
|
Converted from http://www.assembla.com/spaces/clojure/tickets/47 |
| Comment by Assembla Importer [ 08/Oct/10 10:21 AM ] |
|
richhickey said: Updating tickets (#8, #19, #30, #31, #126, #17, #42, #47, #50, #61, #64, #69, #71, #77, #79, #84, #87, #89, #96, #99, #103, #107, #112, #113, #114, #115, #118, #119, #121, #122, #124) |
| Comment by Assembla Importer [ 08/Oct/10 10:21 AM ] |
|
aredington said: This appears to still be a problem with the generated bytecode in 1.3.0. Examining the bytecode for last, the problem has moved to invokeStatic: <pre> Line number 22 is an unreachable goto given the prior goto on line 19. |
[CLJ-274] cannot close over mutable fields (in deftype) Created: 23/Feb/10 Updated: 01/Oct/10 |
|
| Status: | Open |
| Project: | Clojure |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | Backlog |
| Type: | Defect | ||
| Reporter: | Anonymous | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Approval: | Vetted |
| Description |
|
Simplest case: user=> java.lang.IllegalArgumentException: Cannot assign to non-mutable: val (NO_SOURCE_FILE:5) Functions should be able to mutate mutable fields in their surrounding deftype (just like inner classes do in Java). Filed as bug, because the loop special form expands into a fn form sometimes: user=> |
| Comments |
| Comment by Assembla Importer [ 01/Oct/10 9:35 AM ] |
|
Converted from http://www.assembla.com/spaces/clojure/tickets/274 |
| Comment by Assembla Importer [ 01/Oct/10 9:35 AM ] |
|
donmullen said: Updated each run to [_] for new syntax. Now gives exception listed. |
| Comment by Assembla Importer [ 01/Oct/10 9:35 AM ] |
|
richhickey said: We're not going to allow closing over mutable fields. Instead we'll have to generate something other than fn for loops et al used as expressions. Not going to come before cinc |
[CLJ-124] GC Issue 120: Determine mechanism for controlling automatic shutdown of Agents, with a default policy and mechanism for changing that policy as needed Created: 17/Jun/09 Updated: 12/Apr/13 |
|
| Status: | Open |
| Project: | Clojure |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | Release 1.6 |
| Type: | Enhancement | Priority: | Major |
| Reporter: | Chas Emerick | Assignee: | Chas Emerick |
| Resolution: | Unresolved | Votes: | 3 |
| Labels: | None | ||
| Approval: | Vetted |
| Waiting On: | Rich Hickey |
| Description |
Reported by cemer...@snowtide.com, Jun 01, 2009 There has been intermittent chatter over the past months from a couple of people on the group (e.g. http://groups.google.com/group/clojure/browse_thread/thread/409054e3542adc1f) and in #clojure about some clojure scripts hanging, either for a constant time (usually reported as a minute or so with no CPU util) or seemingly forever (or until someone kills the process). I just hit a similar situation in our compilation process, which invokes clojure.lang.Compile from ant. The build process for this particular project had taken 15 second or so, but after adding a couple of pmap calls, that build time jumped to ~1:15, with roughly zero CPU utilization over the course of that last minute. Adding a call to Agent.shutdown() in the finally block in clojure.lang.Compile/main resolved the problem; a patch including this change is attached. I wouldn't suspect anyone would have any issues with such a change. ----- In general, it doesn't seem like everyone should keep tripping over this problem in different directions. It's a very difficult thing to debug if you're not attuned to how clojure's concurrency primitives work under the hood, and I would bet that newer users would be particularly affected. After discussion in #clojure, rhickey suggested adding a *auto-shutdown-agents* var, which: - if true when exiting one of the main entry points (clojure.main, or the legacy script/repl entry points), Agent.shutdown() would be called, allowing for the clean exit of the application - would be bound by default to true - could be easily set to false for anyone with an advanced use-case that requires agents to remain active after the main thread of the application exits. This would obviously not help anyone initializing clojure from a different entry point, but this may represent the best compromise between least-surprise and maximal functionality for advanced users. ------ In addition to the above, it perhaps might be worthwhile to change the keepalive values used to create the Threadpools used by c.l.Actor's Executors. Currently, Actor uses a default thread pool executor, which results in a 60s keepalive. Lowering this to something much smaller (1s? 5s?) would additionally minimize the impact of Agent's threadpools on Java applications that embed clojure directly (and would therefore not benefit from *auto-shutdown-agents* as currently conceived, leading to puzzling 'hanging' behaviour). I'm not in a position to determine what impact this would have on performance due to thread churn, but it would at least minimize what would be perceived as undesirable behaviour by users that are less familiar with the implementation details of Agent and code that depends on it. Comment 1 by cemer...@snowtide.com, Jun 01, 2009 Just FYI, I'd be happy to provide patches for either of the suggestions mentioned above... |
| Comments |
| Comment by Assembla Importer [ 24/Aug/10 12:45 AM ] |
|
Converted from http://www.assembla.com/spaces/clojure/tickets/124 |
| Comment by Assembla Importer [ 24/Aug/10 12:45 AM ] |
|
oranenj said: [file:a56S2ow4ur3O2PeJe5afGb] |
| Comment by Assembla Importer [ 24/Aug/10 12:45 AM ] |
|
richhickey said: Updating tickets (#8, #19, #30, #31, #126, #17, #42, #47, #50, #61, #64, #69, #71, #77, #79, #84, #87, #89, #96, #99, #103, #107, #112, #113, #114, #115, #118, #119, #121, #122, #124) |
| Comment by Assembla Importer [ 24/Aug/10 12:45 AM ] |
|
cemerick said: (In [[r:fa3d24973fc415b35ae6ec8d84b61ace76bd4133]]) Add a call to Agent.shutdown() at the end of clojure.lang.Compile/main Refs #124 Signed-off-by: Chouser <chouser@n01se.net> Branch: master |
| Comment by Assembla Importer [ 24/Aug/10 12:45 AM ] |
|
chouser@n01se.net said: I'm closing this ticket to because the attached patch solves a specific problem. I agree that the idea of an auto-shutdown-agents var sounds like a positive compromise. If Rich wants a ticket to track that issue, I think it'd be best to open a new ticket (and perhaps mention this one there) rather than use this ticket to track further changes. |
| Comment by Assembla Importer [ 24/Aug/10 12:45 AM ] |
|
scgilardi said: With both Java 5 and Java 6 on Mac OS X 10.5 Leopard I'm getting an error when compiling with this change present. Java 1.5.0_19 For example, when building clojure using "ant" from within my clone of the clojure repo: [java] java.security.AccessControlException: access denied (java.lang.RuntimePermission modifyThread) I reproduced this on two Mac OS X 10.5 machines. I'm not aware of having any enhanced security policies along these lines on my machines. The compile goes fine for me with Java 1.6.0_0 on an Ubuntu box. |
| Comment by Assembla Importer [ 24/Aug/10 12:45 AM ] |
|
chouser@n01se.net said: I had only tested it on my ubuntu box – looks like that was openjdk 1.6.0_0. I'll test again with sun-java5 and sun-java6. |
| Comment by Assembla Importer [ 24/Aug/10 12:45 AM ] |
|
chouser@n01se.net said: 1.6.0_13 worked fine for me on ubuntu, but 1.5.0_18 generated an the exception Steve pasted. Any suggestions? Should this patch be backed out until someone has a fix? |
| Comment by Assembla Importer [ 24/Aug/10 12:45 AM ] |
|
achimpassen said: [file:aqn0IGxZSr3RUGeJe5aVNr] |
| Comment by Assembla Importer [ 24/Aug/10 12:45 AM ] |
|
chouser@n01se.net said: With Achim's patch, clojure compiles for me on ubuntu using java 1.5.0_18 from sun, and still works on 1.6.0_13 sun and 1.6.0_0 openjdk. I don't know anything about ant or the security error, but this is looking good to me. |
| Comment by Assembla Importer [ 24/Aug/10 12:45 AM ] |
|
achimpassen said: It works for me on 1.6.0_13 and 1.5.0_19 (32 and 64 bit) on OS X 10.5.7. |
| Comment by Assembla Importer [ 24/Aug/10 12:45 AM ] |
|
chouser@n01se.net said: (In [[r:895b39dabc17b3fd766fdbac3b0757edb0d4b60d]]) Rev fa3d2497 causes compile to fail on some VMs – back it out. Refs #124 Branch: master |
| Comment by Assembla Importer [ 24/Aug/10 12:45 AM ] |
|
mikehinchey said: I got the same compile error on both 1.5.0_11 and 1.6.0_14 on Windows. Achim's patch fixes both. See the note for "permissions" on http://ant.apache.org/manual/CoreTasks/java.html . I assume ThreadPoolExecutor.shutdown is the problem, it would shutdown the main Ant thread, so Ant disallows that. Forking avoids the permissions limitation. In addition, since the build error still resulted in "BUILD SUCCESSFUL", I think failonerror="true" should also be added to the java call so the build would totally fail for such an error. |
| Comment by Assembla Importer [ 24/Aug/10 12:45 AM ] |
|
chouser@n01se.net said: I don't know if the <java fork=true> patch is a good idea or not, or if there's a better way to solve the original problem. Chas, I'm kicking back to you, but I guess if you don't want it you can reassign to "nobody". |
| Comment by Assembla Importer [ 24/Aug/10 12:45 AM ] |
|
richhickey said: Updating tickets (#8, #42, #113, #2, #20, #94, #96, #104, #119, #124, #127, #149, #162) |
| Comment by Assembla Importer [ 24/Aug/10 12:45 AM ] |
|
shoover said: I'd like to suggest an alternate approach. There are already well-defined and intuitive ways to block on agents and futures. Why not deprecate shutdown-agents and force users to call await and deref if they really want to block? In the pmap situation one would have to evaluate the pmap form. The System.exit problem goes away if you configure the threadpools to use daemon threads (call new ThreadPoolExecutor and pass a thread factory that creates threads and sets daemon to true). That way the user has an explicit means of blocking and System.exit won't hang. |
| Comment by Assembla Importer [ 24/Aug/10 12:45 AM ] |
|
alexdmiller said: I blogged about these issues at: I think that:
|
| Comment by Alexander Taggart [ 11/Jul/11 9:33 PM ] |
|
Rich, what is the intention behind using non-daemon threads in the agent pools? If it is because daemon threads could terminate before their work is complete, would it be acceptable to add a shutdown hook to ensure against such premature termination? Such a shutdown hook could call Agent.shutdown(), then awaitTermination() on the pools. |
| Comment by Christopher Redinger [ 27/Nov/12 3:47 PM ] |
|
Moving this ticket out of approval "OK" status, and dropping the priority. These were Assembla import defaults. Also, Chas gets to be the Reporter now. |
| Comment by Chas Emerick [ 27/Nov/12 5:56 PM ] |
|
Heh, blast from the past. The comment import appears to have set their timestamps to the date of the import, so the conversation is pretty hard to follow, and obviously doesn't benefit from the intervening years of experience. In addition, there have been plenty of changes to agents, including some recent enhancements that address some of the pain points that Alex Miller mentioned above. I propose closing this as 'invalid' or whatever, and opening one or more new issues to track whatever issues still persist (presumably based on fresh ML discussion, etc). |
| Comment by Andy Fingerhut [ 27/Nov/12 6:11 PM ] |
|
Rereading the original description of this ticket, without reading all of the comments that follow, that description is still right on target for the behavior of latest Clojure master today. People send messages to the Clojure Google group every couple of months hitting this issue, and one even filed CLJ-959 because of hitting it. I have updated the examples on ClojureDocs.org for future, and also for pmap and clojure.java.shell/sh which use future in their implementations, to warn people about this and explain that they should call (shutdown-agents), but making it unnecessary to call shutdown-agents would be even better, at least as the default behavior. It sounds fine to me to provide a way for experts on thread behavior to change that default behavior if they need to. |
[CLJ-420] Some compiler exceptions erroneously using REPL line numbers. Created: 08/Aug/10 Updated: 12/Apr/13 |
|
| Status: | Open |
| Project: | Clojure |
| Component/s: | None |
| Affects Version/s: | Approved Backlog |
| Fix Version/s: | Release 1.6 |
| Type: | Defect | Priority: | Major |
| Reporter: | Alexander Redington | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Approval: | Vetted |
| Description |
|
Certain kinds of errors in loaded source files are coming back tagged with the correct source file, but what seems to be the REPL line number. jawolfe@[~/Projects/testproj]: cat > src/test.clj bla (bla) |
| Comments |
| Comment by Assembla Importer [ 28/Sep/10 9:59 PM ] |
|
Converted from http://www.assembla.com/spaces/clojure/tickets/420 |
| Comment by Assembla Importer [ 28/Sep/10 9:59 PM ] |
|
stu said: Updating tickets (#427, #426, #421, #420, #397) |
| Comment by Assembla Importer [ 28/Sep/10 9:59 PM ] |
|
stu said: Updating tickets (#429, #437, #397, #420) |
[CLJ-701] Compiler loses 'loop's return type in some cases Created: 03/Jan/11 Updated: 12/Apr/13 |
|
| Status: | Open |
| Project: | Clojure |
| Component/s: | None |
| Affects Version/s: | Approved Backlog |
| Fix Version/s: | Release 1.6 |
| Type: | Defect | Priority: | Major |
| Reporter: | Chouser | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Clojure commit 9052ca1854b7b6202dba21fe2a45183a4534c501, version 1.3.0-master-SNAPSHOT |
||
| Approval: | Vetted |
| Description |
(set! *warn-on-reflection* true)
(fn [] (loop [b 0] (recur (loop [a 1] a))))
Generates the following warnings: recur arg for primitive local: b is not matching primitive, had: Object, needed: long Auto-boxing loop arg: b This is interesting for several reasons. For one, if the arg to recur is a let form, there is no warning: (fn [] (loop [b 0] (recur (let [a 1] a)))) Also, the compiler appears to understand the return type of loop forms just fine: (use '[clojure.contrib.repl-utils :only [expression-info]])
(expression-info '(loop [a 1] a))
;=> {:class long, :primitive? true}
The problem can of course be worked around using an explicit cast on the loop form: (fn [] (loop [b 0] (recur (long (loop [a 1] a)))))
Reported by leafw in IRC: http://clojure-log.n01se.net/date/2011-01-03.html#10:31 |
| Comments |
| Comment by a_strange_guy [ 03/Jan/11 4:36 PM ] |
|
The problem is that a 'loop form gets converted into an anonymous fn that gets called immediately, when the loop is in a expression context (eg. its return value is needed, but not as the return value of a method/fn). so (fn [] (loop [b 0] (recur (loop [a 1] a)))) gets converted into (fn [] (loop [b 0] (recur ((fn [] (loop [a 1] a)))))) see the code in the compiler: this conversion already bites you if you have mutable fields in a deftype and want to 'set! them in a loop |
| Comment by Christophe Grand [ 23/Nov/12 2:28 AM ] |
|
loops in expression context are lifted into fns because else Hotspot doesn't optimize them.
Adressing all those problems isn't easy. [1] beware of |
[CLJ-1058] StackOverflowError on exception in reducef for PersistentHashMap fold Created: 02/Sep/12 Updated: 12/Apr/13 |
|
| Status: | Open |
| Project: | Clojure |
| Component/s: | None |
| Affects Version/s: | Release 1.5 |
| Fix Version/s: | Release 1.6 |
| Type: | Defect | Priority: | Major |
| Reporter: | Tom Jack | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Clojure 1.5.0-alpha4, Sun Java 1.6.0_35, with [org.codehaus.jsr166-mirror/jsr166y "1.7.0"] |
||
| Approval: | Vetted |
| Description |
|
If reducef throws an exception, the PHM fold code can descend into an infinite loop, causing a stack overflow which masks the problem. This situation is commented "aargh" in PersistentHashMap.java line 444 (as of 412a51d). To reproduce: user> (require '[clojure.core.reducers :as r])
nil
user> (r/fold (fn ([]) ([ret k v] (+ 3 "foo") ret)) (into {} (map (juxt identity identity) (range 10000))))
;; boom
This results in a stack like: https://raw.github.com/gist/3bab917287a7fd635a84/f38bfe3e270556e467f3fc02062af7ea10781390/gistfile1.txt |
| Comments |
| Comment by Timothy Baldridge [ 30/Nov/12 3:40 PM ] |
|
Verified as a bug. |
[CLJ-1100] Reader literals cannot contain periods Created: 02/Nov/12 Updated: 14/Feb/13 |
|
| Status: | Open |
| Project: | Clojure |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Defect | Priority: | Major |
| Reporter: | Kevin Lynagh | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | reader | ||
| Approval: | Vetted |
| Description |
|
The LispReader tries to read a record instead of a literal if the tag contains periods: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/LispReader.java#L1171 Which effectively means that reader tags cannot contain periods.
(issue opened: https://github.com/edn-format/edn/issues/39) If periods are allowed, then the LispReader should first check to see if the tag is in *data-readers* and only then if not try to initialize a Java class. I'm happy to write the patch if this behavior is what is desired. |
| Comments |
| Comment by Steve Miner [ 06/Nov/12 9:41 AM ] |
|
The suggested patch (clj-1100-reader-literal-periods.patch) will break reading records when *default-data-reader-fn* is set. Try adding a test like this: (deftest tags-containing-periods-with-default ;; we need a predefined record for this test so we (mis)use clojure.reflect.Field for convenience (let [v "#clojure.reflect.Field{:name \"fake\" :type :fake :declaring-class \"Fake\" :flags nil}"] (binding [*default-data-reader-fn* nil] (is (= (read-string v) #clojure.reflect.Field{:name "fake" :type :fake :declaring-class "Fake" :flags nil}))) (binding [*default-data-reader-fn* (fn [tag val] (assoc val :meaning 42))] (is (= (read-string v) #clojure.reflect.Field{:name "fake" :type :fake :declaring-class "Fake" :flags nil}))))) |
| Comment by Rich Hickey [ 29/Nov/12 9:36 AM ] |
|
The problem assessment is ok, but the resolution approach may not be. What happens should be based not upon what is in data-readers but whether or not the name names a class. Is the intent here to allow readers to circumvent records? I'm not in favor of that. |
| Comment by Steve Miner [ 29/Nov/12 4:01 PM ] |
|
New patch following Rich's comments. The decision to read a record is now based on the symbol containing periods and not having a namespace. Otherwise, it is considered a data reader tag. User |
| Comment by Steve Miner [ 29/Nov/12 4:17 PM ] |
|
I deleted my old patch and some comments referring to it to avoid confusion. In Clojure 1.5 beta 1, # followed by a qualified symbol with a period in the name is considered a record and causes an exception for the missing record class. With the patch, only non-qualified symbols containing periods are considered records. That allows user-defined qualified symbols with periods in their names to be used as data reader tags. |
| Comment by Andy Fingerhut [ 07/Feb/13 9:05 AM ] |
|
clj-1100-periods-in-data-reader-tags-patch-v2.txt dated Feb 7 2013 is identical to CLJ-1100-periods-in-data-reader-tags.patch dated Nov 29 2012, except it applies cleanly to latest master. The only change appears to be in some white space in the context lines. |
| Comment by Andy Fingerhut [ 07/Feb/13 12:53 PM ] |
|
I've removed clj-1100-periods-in-data-reader-tags-patch-v2.txt mentioned in the previous comment, because I learned that CLJ-1100-periods-in-data-reader-tags.patch dated Nov 29 2012 applies cleanly to latest master and passes all tests if you use this command to apply it. % git am --keep-cr -s --ignore-whitespace < CLJ-1100-periods-in-data-reader-tags.patch I've already updated the JIRA workflow and screening patches wiki pages to mention this --ignore-whitespace option. |
| Comment by Andy Fingerhut [ 13/Feb/13 11:31 AM ] |
|
Both of the current patches, CLJ-1100-periods-in-data-reader-tags.patch dated Nov 29 2012, and clj-1100-reader-literal-periods.patch dated Nov 6 2012, fail to apply cleanly to latest master (1.5.0-RC15) as of today, although they did last week. Given all of the changes around read / read-string and edn recently, they should probably be evaluated by their authors to see how they should be updated. |
| Comment by Steve Miner [ 14/Feb/13 12:23 PM ] |
|
I deleted my patch: CLJ-1100-periods-in-data-reader-tags.patch. clj-1100-reader-literal-periods.patch is clearly wrong, but the original author or an administrator has to delete that. |
| Comment by Kevin Lynagh [ 14/Feb/13 1:28 PM ] |
|
I cannot figure out how to remove my attachment (clj-1100-reader-literal-periods.patch) in JIRA. |
| Comment by Steve Miner [ 14/Feb/13 1:43 PM ] |
|
Downarrow (popup) menu to the right of the "Attachments" section. Choose "manager attachments". |
| Comment by Kevin Lynagh [ 14/Feb/13 2:02 PM ] |
|
Great, thanks Steve. Are you going to take another pass at this issue, or should I give it a go? |
| Comment by Steve Miner [ 14/Feb/13 3:04 PM ] |
|
Kevin, I'm not planning to work on this right now as 1.5 is pretty much done. It might be worthwhile discussing the issue a bit on the dev mailing list before working on a patch, but that's up to you. I think my approach was correct, although now changes would have to be applied to both LispReader and EdnReader. |
[CLJ-348] reify allows use of qualified name as method parameter Created: 13/May/10 Updated: 01/Mar/13 |
|
| Status: | Open |
| Project: | Clojure |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | Approved Backlog |
| Type: | Defect | Priority: | Minor |
| Reporter: | Assembla Importer | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Approval: | Vetted |
| Description |
|
This should complain about using a fully-qualified name as a parameter: (defmacro lookup [] Instead it simply ignores that parameter in the method body in favour of clojure.core/key. |
| Comments |
| Comment by Assembla Importer [ 24/Aug/10 8:03 AM ] |
|
Converted from http://www.assembla.com/spaces/clojure/tickets/348 |
| Comment by Assembla Importer [ 24/Aug/10 8:03 AM ] |
|
technomancy said: [file:d2xUJIxTyr36fseJe5cbLA]: A test to expose the unwanted behaviour |
| Comment by Assembla Importer [ 24/Aug/10 8:03 AM ] |
|
richhickey said: I'm not sure the bug is what you say it is, or the resolution should be what you suggest. The true problem is the resolution of key when qualified. Another possibility is to ignore the qualifier there. |
| Comment by Assembla Importer [ 24/Aug/10 8:03 AM ] |
|
technomancy said: Interesting. So it's not appropriate to require auto-gensym here? Why are the rules different for reify methods vs proxy methods? > (defmacro lookup [] Can't use qualified name as parameter: clojure.core/key |
[CLJ-731] Create macro to variadically unroll a combinator function definition Created: 26/Jan/11 Updated: 28/Jan/11 |
|
| Status: | Open |
| Project: | Clojure |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | Approved Backlog |
| Type: | Enhancement | Priority: | Minor |
| Reporter: | Fogus | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Approval: | Vetted |
| Description |
|
Clojure contains a set of combinators that are implemented in a similar, but slightly different way. That is, they are implemented as a complete set of variadic overloads on both the call-side and also on the functions that they return. Visually, they all tend to look something like: (defn foo
([f]
(fn
([] do stuff...)
([x] do stuff...)
([x y] do stuff...)
([x y z] do stuff...)
([x y z & args] do variadic stuff...)))
([f1 f2]
(fn
([] do stuff...)
([x] do stuff...)
([x y] do stuff...)
([x y z] do stuff...)
([x y z & args] do variadic stuff...)))
([f1 f2 f3]
(fn
([] do stuff...)
([x] do stuff...)
([x y] do stuff...)
([x y z] do stuff...)
([x y z & args] do variadic stuff...)))
([f1 f2 f3 & fs]
(fn
([] do stuff...)
([x] do stuff...)
([x y] do stuff...)
([x y z] do stuff...)
([x y z & args] do variadic stuff...))))
To build this type of function for each combinator is tedious and error-prone. There must be a way to implement a macro that takes a "specification" of a combinator including: 1. name And builds something like the function foo above. This macro should be able to implement the current batch of combinators (assuming that http://dev.clojure.org/jira/browse/CLJ-730 is completed first for the sake of verification). |
| Comments |
| Comment by Stuart Halloway [ 28/Jan/11 9:03 AM ] |
|
This seems useful. Rich, would you accept a patch? |
| Comment by Stuart Halloway [ 28/Jan/11 9:40 AM ] |
|
Nevermind, just saw that Rich already suggested this on the dev list. Patch away. |
[CLJ-787] transient blows up when passed a vector created by subvec Created: 03/May/11 Updated: 12/Apr/13 |
|
| Status: | Open |
| Project: | Clojure |
| Component/s: | None |
| Affects Version/s: | Backlog |
| Fix Version/s: | Release 1.6 |
| Type: | Defect | Priority: | Minor |
| Reporter: | Alexander Redington | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Approval: | Vetted |
| Description |
|
Subvectors created with subvec from a PersistentVector cannot be made transient: user=> (transient (subvec [1 2 3 4] 2)) ClassCastException clojure.lang.APersistentVector$SubVector cannot be cast to clojure.lang.IEditableCollection clojure.core/transient (core.clj:2864) |
| Comments |
| Comment by Stuart Sierra [ 31/May/11 9:28 AM ] |
|
Confirmed. APersistentVector$SubVector does not implement IEditableCollection. The current implementation of TransientVector depends on implementation details of PersistentVector, so it is not a trivial fix. The simplest fix might be to implement IEditableCollection.asTransient in SubVector by creating a new PersistentVector, but I do not know the performance implications. |
[CLJ-823] Piping seque into seque can deadlock Created: 03/Aug/11 Updated: 12/Apr/13 |
|
| Status: | Open |
| Project: | Clojure |
| Component/s: | None |
| Affects Version/s: | Release 1.3 |
| Fix Version/s: | None |
| Type: | Defect | Priority: | Minor |
| Reporter: | Greg Chapman | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | None | ||
| Environment: |
Windows 7; JVM 1.6; Clojure 1.3 beta 1 |
||
| Approval: | Vetted |
| Description |
|
I'm not sure if this is a supported scenario, but the following deadlocks in Clojure 1.3: (let [xs (seque (range 150000)) As I understand it, the problem is that ys' fill takes place on an agent thread, so when it calls xs' drain, the (send-off agt fill) does not immediately trigger xs' fill, but is instead put on the nested list to be performed when ys' agent returns. Unfortunately, ys' fill will eventually block trying to take from xs, and so it never returns and the pending send-offs are never sent. Wrapping the send-off in drain to: (future (send-off agt fill)) is a simple (probably not optimal) way to fix the deadlock. |
| Comments |
| Comment by Peter Monks [ 07/Jan/13 3:43 PM ] |
|
Reproduced on 1.4.0 and 1.5.0-RC1 as well, albeit with this example: (seque 3 (seque 3 (range 10))) |
| Comment by Stuart Halloway [ 30/Mar/13 9:16 AM ] |
|
release-pending-sends? |
[CLJ-1033] pr-str and read-string don't handle @ symbols inside keywords properly Created: 26/Jul/12 Updated: 13/Jan/13 |
|
| Status: | Open |
| Project: | Clojure |
| Component/s: | None |
| Affects Version/s: | Release 1.4 |
| Fix Version/s: | None |
| Type: | Enhancement | Priority: | Minor |
| Reporter: | Steven Ruppert | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | reader | ||
| Environment: |
Ubuntu 12.04 LTS; Java 1.7.0_05 Java HotSpot(TM) Client VM |
||
| Approval: | Vetted |
| Description |
user=> (read-string (pr-str {(keyword "key@other") :stuff}))
RuntimeException Map literal must contain an even number of forms clojure.lang.Util.runtimeException (Util.java:170)
pr-str emits "{:key@other :stuff}", which read-string fails to interpret correctly. Either pr-str needs to escape the @ symbol, or read-string needs to handle the symbol inside a keyword. Background: I'm passing a map with email addresses as keys through Storm bolts, which require a thrift-serializable form. Using the pr-str/read-string combo fails on these keys, so I've fallen back to JSON serialization. |
| Comments |
| Comment by Stuart Halloway [ 10/Aug/12 12:51 PM ] |
|
The '@' character is not a legal character for keywords or symbols (see http://clojure.org/reader). Recategorized as enhancement request. |
| Comment by Steven Ruppert [ 10/Aug/12 1:04 PM ] |
|
Then why doesn't (keyword "keywith@") throw an exception? It seems inconsistent with your statement. |
| Comment by Andy Fingerhut [ 13/Sep/12 2:23 PM ] |
|
It is a long standing property of Clojure that it does not throw exceptions for everything that is illegal. |
| Comment by Steven Ruppert [ 17/Sep/12 2:16 PM ] |
|
Yeah, but read-string clearly does. Is there a good reason that the "keyword" function can't throw an exception? With the other special rules on namespaces within symbol names, the "keyword" function really should be doing validation. Another solution would be to allow a ruby-like :"symbol with disallowed characters" literal, but that would also be confusing with how the namespace is handled. https://groups.google.com/forum/?fromgroups=#!topic/clojure/Ct5v9w0yNAE has some older discussion on this topic. |
| Comment by Andy Fingerhut [ 17/Sep/12 7:43 PM ] |
|
Disclaimer: I'm not a Clojure/core member, just an interested contributor who doesn't know all the design decisions that were made here. Steven, I think perhaps a couple of concerns are: (1) doing such checks would be slower than not doing them, and (2) implementing such checks means having to update them if/when the rules for legal symbols, keywords, namespace names, etc. change. Would you be interested in writing strict versions of functions like symbol and keyword for addition to a contrib library? And test suites that try to hit a significant number of corner cases in the rules for what is legal and what is not? I mean those as serious questions, not rhetorical ones. This would permit people that want to use the strict versions of these functions to do so, and at the same time make it easy to measure performance differences between the strict and loose versions. |
| Comment by Steven Ruppert [ 13/Jan/13 10:58 PM ] |
|
Looking back at this, the root cause of the problem is that the {pr} function, although it by default "print[s] in a way that objects can be read by the reader" [0], doesn't always do so. Thus, the easiest "fix" is to change its docstring to warn that not all keywords can be read back. The deeper problem is that symbol don't have a reader form that can represent all actually possible keywords (in this case, those with "@" in them). Restricting the actually-possible keywords to match the reader form, i.e. writing a strict "keyword" function actually seems like a worse solution overall to me. The better solution would be to somehow extend the keyword reader form to allow it to express all possible keywords, possibly ruby's :"keyword" syntax. Plus, that solution would avoid having to keep hypothetical strict keyword/symbol functions in sync with reader operation, and write test cases for that, and so on. Thus, the resolution of this bug comes down to how far we're willing to go. Changing the docstring would be the easiest, but extending the keyword form would be the "best" resolution, IMO. |
[CLJ-1039] Using 'def with metadata {:type :anything} throws ClassCastException Created: 09/Aug/12 Updated: 10/Aug/12 |
|
| Status: | Open |
| Project: | Clojure |
| Component/s: | None |
| Affects Version/s: | Release 1.4 |
| Fix Version/s: | None |
| Type: | Defect | Priority: | Minor |
| Reporter: | Gunnar Völkel | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Ubuntu, lein 1.7.1 - lein repl |
||
| Approval: | Vetted |
| Description |
|
In lein 1.7.1 (and CCW) the form (def ^{:type :anything} mydef 1) throws "ClassCastException clojure.lang.Var cannot be cast to clojure.lang.IObj clojure.core/with-meta (core.clj:211)". If it is intended to forbid setting the :type metadata, then there should be an appropriate error message instead of the ClassCastException In lein2 repl which is using "REPL-y 0.1.0-beta8" the exception does not occur. Full stacktrace: |
| Comments |
| Comment by Stuart Halloway [ 10/Aug/12 1:40 PM ] |
|
This is caused by the printer dispatch function (defmulti print-method (fn [x writer]
(let [t (get (meta x) :type)]
(if (keyword? t) t (class x)))))
which ends up calling the default dispatch, which tries to vary-meta. |
[CLJ-1056] defprotocol: invalid method overload syntax getting accepted Created: 01/Sep/12 Updated: 29/Nov/12 |
|
| Status: | Open |
| Project: | Clojure |
| Component/s: | None |
| Affects Version/s: | Release 1.5 |
| Fix Version/s: | None |
| Type: | Defect | Priority: | Minor |
| Reporter: | Víctor M. Valenzuela | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Approval: | Vetted |
| Description |
|
The compiler accepts both of these erroneous forms which while silly, are not imposible to come up with. (defprotocol Foo (f ([this]) ([this arg]))) |
| Comments |
| Comment by Timothy Baldridge [ 29/Nov/12 4:02 PM ] |
|
Can not reproduce the fist error: user=> (defprotocol Foo (f ([this]) ([this arg]))) But the 2nd one I can reproduce: user=> (defprotocol Bar (m [this]) (m [this arg])) Notice that :arglists only has one entry Vetting |
[CLJ-1105] defrecord classes implement IPersistentCollection but not .empty, clojure.walk assumes collections support empty Created: 08/Nov/12 Updated: 12/Apr/13 |
|
| Status: | Open |
| Project: | Clojure |
| Component/s: | None |
| Affects Version/s: | Release 1.4 |
| Fix Version/s: | Release 1.6 |
| Type: | Defect | Priority: | Minor |
| Reporter: | Jouni K. Seppänen | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | None | ||
| Approval: | Vetted |
| Description |
|
Using clojure.walk functions fails surprisingly for data containing records defined with defrecord: user=> (defrecord Foo [x]) This seems to be because clojure.walk/walk guards a call to (empty form) with a (coll? form) check. The check succeeds because records implement IPersistentCollection, but (empty form) throws an exception. This looks to me like a bug in clojure.walk (it should check records separately and either treat them as atomic or implement a way of walking through them) but perhaps it is a sign of some unclarity in the contract of collections. |
| Comments |
| Comment by Nicola Mometto [ 08/Nov/12 2:35 PM ] |
|
maybe clojure should follow clojurescript's footsteps and move empty out of IPersistentCollection and create an |
| Comment by Stuart Halloway [ 25/Nov/12 6:39 PM ] |
|
Can whoever claims this please consider walk's behavior in the face of all different collection types? I think it also fails with Java collections. Also, the collection partitioning code in clojure.data may be of use. |
[CLJ-1184] Evaling #{do ...} or [do ...] is treated as the do special form Created: 16/Mar/13 Updated: 12/Apr/13 |
|
| Status: | Open |
| Project: | Clojure |
| Component/s: | None |
| Affects Version/s: | Release 1.5 |
| Fix Version/s: | Release 1.6 |
| Type: | Defect | Priority: | Trivial |
| Reporter: | Jiří Maršík | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | Compiler, bug | ||
| Approval: | Vetted |
| Description |
|
Evaluating a persistent collection for which the function 'first' returns the symbol 'do' leads to that collection being treated as the do special form, even though it may be a vector or even a set. IMHO, the expected result would be to report that 'do' cannot be resolved. For the cause, see the if condition on line 6604 of Compiler.java in clojure-1.5.1. E.g.: #{"hello" "goodbye" do} |