| Anonymous | Login | Signup for a new account | 2013-05-19 14:41 CEST | ![]() |
| Main | My View | View Issues | Change Log | Roadmap |
| View Issue Details [ Jump to Notes ] | [ Issue History ] [ Print ] | |||||||||||
| ID | Project | Category | View Status | Date Submitted | Last Update | |||||||
| 0005309 | OCaml | OCaml general | public | 2011-07-06 11:03 | 2012-05-07 15:36 | |||||||
| Reporter | lefessan | |||||||||||
| Assigned To | lefessan | |||||||||||
| Priority | normal | Severity | minor | Reproducibility | always | |||||||
| Status | resolved | Resolution | fixed | |||||||||
| Platform | all | OS | all | OS Version | all | |||||||
| Product Version | 3.12.1+dev | |||||||||||
| Target Version | Fixed in Version | 3.13.0+dev | ||||||||||
| Summary | 0005309: Queue.add is not thread/signal safe | |||||||||||
| Description | If an exception is raised in a signal after the first line of Queue.add (i.e. increasing the length counter of the queue), the queue invariants are broken and bad things can happen (segfault...). In the additional information, I provide a new "add" function that should be thread/signal safe. | |||||||||||
| Additional Information | let add x q = if q.length = 0 then let rec cell = { content = x; next = cell } in q.length <- q.length + 1; q.tail <- cell else let tail = q.tail in let head = tail.next in let cell = { content = x; next = head } in q.length <- q.length + 1; tail.next <- cell; q.tail <- cell | |||||||||||
| Tags | No tags attached. | |||||||||||
| Attached Files | ||||||||||||
Notes |
|
|
(0006041) mottl (reporter) 2011-07-06 16:02 |
Nitpicking here: q.length <- q.length + 1; can be replaced by: q.length <- 1; in the first branch. |
|
(0006923) gasche (developer) 2012-02-15 09:07 |
To sum up yesterday's discussion: the OCaml library is not guaranteed to be signal-safe, or rather, it is voluntarily guaranteed *not* to be signal-safe. Users should acknowledge that using mutable data structures expose them to signal hazards, and stick to immutable data structures or use different, specialized signal-hardened libraries. That said, this specific patch is relatively harmless -- in particular, it does not impact clarity and readability -- and Fabrice may include it. As a personal note: we may also write begin if q.length = 1 then .. else .. end; q.length <- q.length + 1 to avoid duplicating the common length-extension logic. Of course, it's only a dispensable detail. |
|
(0006936) lefessan (developer) 2012-02-18 10:36 |
Fixed in commit r12163 in SVN trunk. |
Issue History |
|||
| Date Modified | Username | Field | Change |
| 2011-07-06 11:03 | lefessan | New Issue | |
| 2011-07-06 16:02 | mottl | Note Added: 0006041 | |
| 2012-02-15 09:07 | gasche | Note Added: 0006923 | |
| 2012-02-15 09:07 | gasche | Assigned To | => lefessan |
| 2012-02-15 09:07 | gasche | Status | new => assigned |
| 2012-02-18 10:36 | lefessan | Note Added: 0006936 | |
| 2012-02-18 10:36 | lefessan | Status | assigned => resolved |
| 2012-02-18 10:36 | lefessan | Fixed in Version | => 3.13.0+dev |
| 2012-02-18 10:36 | lefessan | Resolution | open => fixed |
| Copyright © 2000 - 2011 MantisBT Group |