You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 6460 Reporter:@lpw25 Assigned to:@damiendoligez Status: closed (set by @xavierleroy on 2016-12-07T10:34:20Z) Resolution: fixed Priority: normal Severity: minor Version: 4.02.0+dev Target version: 4.02.0+dev Fixed in version: 4.02.0+dev Category: runtime system and C interface Tags: patch, junior_job Monitored by:@gasche@jmeber@hcarty
Bug description
caml_make_array asserts that the size of the array is less than Max_young_wosize so that it can use caml_alloc_small. However, the compiler does not enforce this invariant.
This bug is interesting because any literal given (including the one in test.ml) will be valid as long as it is smaller than the size of the minor heap which is a lot bigger than the enforced invariant.
So we found a minimal test that trashes the memory because of the violated invariant and we have attached a simple patch that corrects the problem by calling caml_alloc_shr when the size goes over Max_young_wosize. The new example and the patch work both on bytecode and native.
Maybe this was not done before for a good reason, in that case we might consider something along the lines of refusing too big literals, any constant smaller than Minor_heap_min would be good enough.
Fixed as proposed in 4.02 (commit 15010) and on trunk (commit 15011).
I heard some questions about the use of caml_check_urgent_gc after caml_alloc_shr. This is correct, this is cheap, and this can help memory performance. caml_alloc_shr never triggers a GC, because often it is being called during a minor GC. However, caml_alloc_shr can set flags saying that it is "urgent" to perform a GC in the future. caml_check_urgent_gc will check and honor this flag, without waiting for the next polling of this flag by the bytecode interpreter or generated native code.
Original bug ID: 6460
Reporter: @lpw25
Assigned to: @damiendoligez
Status: closed (set by @xavierleroy on 2016-12-07T10:34:20Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 4.02.0+dev
Target version: 4.02.0+dev
Fixed in version: 4.02.0+dev
Category: runtime system and C interface
Tags: patch, junior_job
Monitored by: @gasche @jmeber @hcarty
Bug description
caml_make_array asserts that the size of the array is less than Max_young_wosize so that it can use caml_alloc_small. However, the compiler does not enforce this invariant.
File attachments
The text was updated successfully, but these errors were encountered: