From tr@ver@c @end|ng |rom gm@||@com  Wed Feb 27 21:33:37 2019
From: tr@ver@c @end|ng |rom gm@||@com (Travers Ching)
Date: Wed, 27 Feb 2019 12:33:37 -0800
Subject: [Rd] Intermittent crashes with inset `[<-` command
In-Reply-To: <CAPLMX9Fn4PVN5VL4SSAzXU0_9CX35QH-D12UvOEOyA2GCUaWgA@mail.gmail.com>
References: <1345861204.5109355.1551154699341.ref@mail.yahoo.com>
 <1345861204.5109355.1551154699341@mail.yahoo.com>
 <CAD4oTHFgrBKncycjoFLpN3mgb1KQqNHE5eU86GaTDXvJoHsjMw@mail.gmail.com>
 <CAF8bMcYZgubfYQYi29n1RNBiA1EU2APN+HAJeGuN4M5Ok_Q7sg@mail.gmail.com>
 <CAPLMX9Fn4PVN5VL4SSAzXU0_9CX35QH-D12UvOEOyA2GCUaWgA@mail.gmail.com>
Message-ID: <CAPLMX9GK0T=fwTGB4x=OOmuyJgDh+fePaACi3C026TjeaW9RaQ@mail.gmail.com>

Some testing:

Adding `gc()` inside the for loop prevented a crash for 10,000+
iterations, whereas adding `Sys.sleep(.2)` (which takes longer) did
not.  I couldn't wrap my head around the `vectorAssign` source code,
but I suspect it is a matter of an intermediate object not being
protected and being gc'ed.  Hope that helps someone....

Travers


Travers

On Wed, Feb 27, 2019 at 11:48 AM Travers Ching <traversc at gmail.com> wrote:
>
> On an azure centos VM, I can reproduce this bug which reports either:
>
>  *** caught segfault ***
> address 0x70000006a, cause 'memory not mapped' (crash)
>
> Or
>
> incompatible types (from builtin to integer) in subassignment type fix
> (no crash)
>
> Like Gabriel, I could not reproduce the bug on a mac laptop.  Both R
> versions 3.5.1.
>
> Travers
>
> On Wed, Feb 27, 2019 at 9:08 AM William Dunlap via R-devel
> <r-devel at r-project.org> wrote:
> >
> > Valgrind (without gctorture) reports memory misuse:
> >
> > % R --debugger=valgrind --debugger-args="--leak-check=full --num-callers=18"
> > ...
> > > x <- 1:200000
> > > y <- rep(letters[1:5], length(x) / 5L)
> > > for (i in 1:1000) {
> > +   # x[y == 'a'] <- x[y == 'b']
> > +   x <- `[<-`(x, y == 'a', x[y == 'b'])
> > +   cat(i, '')
> > + }
> > 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
> > 29 30 31 32 33 34 35 36 37 ==4711== Invalid read of size 1
> > ==4711==    at 0x501A40F: Rf_xlength (Rinlinedfuns.h:542)
> > ==4711==    by 0x501A40F: VectorAssign (subassign.c:658)
> > ==4711==    by 0x501CDFE: do_subassign_dflt (subassign.c:1641)
> > ==4711==    by 0x5020100: do_subassign (subassign.c:1571)
> > ==4711==    by 0x4F66398: bcEval (eval.c:6795)
> > ==4711==    by 0x4F7D86D: R_compileAndExecute (eval.c:1407)
> > ==4711==    by 0x4F7DA70: do_for (eval.c:2185)
> > ==4711==    by 0x4F7741C: Rf_eval (eval.c:691)
> > ==4711==    by 0x4FA7181: Rf_ReplIteration (main.c:258)
> > ==4711==    by 0x4FA7570: R_ReplConsole (main.c:308)
> > ==4711==    by 0x4FA760E: run_Rmainloop (main.c:1082)
> > ==4711==    by 0x40075A: main (Rmain.c:29)
> > ==4711==  Address 0x19b3ab90 is 0 bytes inside a block of size 160,048
> > free'd
> > ==4711==    at 0x4C2ACBD: free (vg_replace_malloc.c:530)
> > ==4711==    by 0x4FAFCB2: ReleaseLargeFreeVectors (memory.c:1055)
> > ==4711==    by 0x4FAFCB2: RunGenCollect (memory.c:1825)
> > ==4711==    by 0x4FAFCB2: R_gc_internal (memory.c:2998)
> > ==4711==    by 0x4FB166F: Rf_allocVector3 (memory.c:2682)
> > ==4711==    by 0x4FB2310: Rf_allocVector (Rinlinedfuns.h:577)
> > ==4711==    by 0x4FB2310: R_alloc (memory.c:2197)
> > ==4711==    by 0x5023F7A: logicalSubscript (subscript.c:575)
> > ==4711==    by 0x5026DA3: Rf_makeSubscript (subscript.c:994)
> > ==4711==    by 0x501A2F3: VectorAssign (subassign.c:656)
> > ==4711==    by 0x501CDFE: do_subassign_dflt (subassign.c:1641)
> > ==4711==    by 0x5020100: do_subassign (subassign.c:1571)
> > ==4711==    by 0x4F66398: bcEval (eval.c:6795)
> > ==4711==    by 0x4F7D86D: R_compileAndExecute (eval.c:1407)
> > ==4711==    by 0x4F7DA70: do_for (eval.c:2185)
> > ==4711==    by 0x4F7741C: Rf_eval (eval.c:691)
> > ==4711==    by 0x4FA7181: Rf_ReplIteration (main.c:258)
> > ==4711==    by 0x4FA7570: R_ReplConsole (main.c:308)
> > ==4711==    by 0x4FA760E: run_Rmainloop (main.c:1082)
> > ==4711==    by 0x40075A: main (Rmain.c:29)
> > ==4711==  Block was alloc'd at
> > ==4711==    at 0x4C29BC3: malloc (vg_replace_malloc.c:299)
> > ==4711==    by 0x4FB1B04: Rf_allocVector3 (memory.c:2712)
> > ==4711==    by 0x5027574: Rf_allocVector (Rinlinedfuns.h:577)
> > ==4711==    by 0x5027574: Rf_ExtractSubset (subset.c:115)
> > ==4711==    by 0x502ADCD: VectorSubset (subset.c:198)
> > ==4711==    by 0x502ADCD: do_subset_dflt (subset.c:823)
> > ==4711==    by 0x502BE90: do_subset (subset.c:661)
> > ==4711==    by 0x4F7741C: Rf_eval (eval.c:691)
> > ==4711==    by 0x4F7BAC3: Rf_evalListKeepMissing (eval.c:2955)
> > ==4711==    by 0x50200CB: R_DispatchOrEvalSP (subassign.c:1535)
> > ==4711==    by 0x50200CB: do_subassign (subassign.c:1567)
> > ==4711==    by 0x4F66398: bcEval (eval.c:6795)
> > ==4711==    by 0x4F7D86D: R_compileAndExecute (eval.c:1407)
> > ==4711==    by 0x4F7DA70: do_for (eval.c:2185)
> > ==4711==    by 0x4F7741C: Rf_eval (eval.c:691)
> > ==4711==    by 0x4FA7181: Rf_ReplIteration (main.c:258)
> > ==4711==    by 0x4FA7570: R_ReplConsole (main.c:308)
> > ==4711==    by 0x4FA760E: run_Rmainloop (main.c:1082)
> > ==4711==    by 0x40075A: main (Rmain.c:29)
> > ==4711==
> > ==4711== Invalid read of size 8
> > ==4711==    at 0x501A856: XLENGTH_EX (Rinlinedfuns.h:189)
> > ==4711==    by 0x501A856: Rf_xlength (Rinlinedfuns.h:554)
> > ==4711==    by 0x501A856: VectorAssign (subassign.c:658)
> > ==4711==    by 0x501CDFE: do_subassign_dflt (subassign.c:1641)
> > ==4711==    by 0x5020100: do_subassign (subassign.c:1571)
> > ==4711==    by 0x4F66398: bcEval (eval.c:6795)
> > ==4711==    by 0x4F7D86D: R_compileAndExecute (eval.c:1407)
> > ==4711==    by 0x4F7DA70: do_for (eval.c:2185)
> > ==4711==    by 0x4F7741C: Rf_eval (eval.c:691)
> > ==4711==    by 0x4FA7181: Rf_ReplIteration (main.c:258)
> > ==4711==    by 0x4FA7570: R_ReplConsole (main.c:308)
> > ==4711==    by 0x4FA760E: run_Rmainloop (main.c:1082)
> > ==4711==    by 0x40075A: main (Rmain.c:29)
> > ==4711==  Address 0x19b3abb0 is 32 bytes inside a block of size 160,048
> > free'd
> > ==4711==    at 0x4C2ACBD: free (vg_replace_malloc.c:530)
> > ==4711==    by 0x4FAFCB2: ReleaseLargeFreeVectors (memory.c:1055)
> > ==4711==    by 0x4FAFCB2: RunGenCollect (memory.c:1825)
> > ==4711==    by 0x4FAFCB2: R_gc_internal (memory.c:2998)
> > ==4711==    by 0x4FB166F: Rf_allocVector3 (memory.c:2682)
> > ==4711==    by 0x4FB2310: Rf_allocVector (Rinlinedfuns.h:577)
> > ==4711==    by 0x4FB2310: R_alloc (memory.c:2197)
> > ==4711==    by 0x5023F7A: logicalSubscript (subscript.c:575)
> > ==4711==    by 0x5026DA3: Rf_makeSubscript (subscript.c:994)
> > ==4711==    by 0x501A2F3: VectorAssign (subassign.c:656)
> > ==4711==    by 0x501CDFE: do_subassign_dflt (subassign.c:1641)
> > ==4711==    by 0x5020100: do_subassign (subassign.c:1571)
> > ==4711==    by 0x4F66398: bcEval (eval.c:6795)
> > ==4711==    by 0x4F7D86D: R_compileAndExecute (eval.c:1407)
> > ==4711==    by 0x4F7DA70: do_for (eval.c:2185)
> > ==4711==    by 0x4F7741C: Rf_eval (eval.c:691)
> > ==4711==    by 0x4FA7181: Rf_ReplIteration (main.c:258)
> > ==4711==    by 0x4FA7570: R_ReplConsole (main.c:308)
> > ==4711==    by 0x4FA760E: run_Rmainloop (main.c:1082)
> > ==4711==    by 0x40075A: main (Rmain.c:29)
> > ==4711==  Block was alloc'd at
> > ==4711==    at 0x4C29BC3: malloc (vg_replace_malloc.c:299)
> > ==4711==    by 0x4FB1B04: Rf_allocVector3 (memory.c:2712)
> > ==4711==    by 0x5027574: Rf_allocVector (Rinlinedfuns.h:577)
> > ==4711==    by 0x5027574: Rf_ExtractSubset (subset.c:115)
> > ==4711==    by 0x502ADCD: VectorSubset (subset.c:198)
> > ==4711==    by 0x502ADCD: do_subset_dflt (subset.c:823)
> > ==4711==    by 0x502BE90: do_subset (subset.c:661)
> > ==4711==    by 0x4F7741C: Rf_eval (eval.c:691)
> > ==4711==    by 0x4F7BAC3: Rf_evalListKeepMissing (eval.c:2955)
> > ==4711==    by 0x50200CB: R_DispatchOrEvalSP (subassign.c:1535)
> > ==4711==    by 0x50200CB: do_subassign (subassign.c:1567)
> > ==4711==    by 0x4F66398: bcEval (eval.c:6795)
> > ==4711==    by 0x4F7D86D: R_compileAndExecute (eval.c:1407)
> > ==4711==    by 0x4F7DA70: do_for (eval.c:2185)
> > ==4711==    by 0x4F7741C: Rf_eval (eval.c:691)
> > ==4711==    by 0x4FA7181: Rf_ReplIteration (main.c:258)
> > ==4711==    by 0x4FA7570: R_ReplConsole (main.c:308)
> > ==4711==    by 0x4FA760E: run_Rmainloop (main.c:1082)
> > ==4711==    by 0x40075A: main (Rmain.c:29)
> > ==4711==
> > ==4711== Invalid read of size 1
> > ==4711==    at 0x501997E: SubassignTypeFix (subassign.c:318)
> > ==4711==    by 0x501A4A2: VectorAssign (subassign.c:666)
> > ==4711==    by 0x501CDFE: do_subassign_dflt (subassign.c:1641)
> > ==4711==    by 0x5020100: do_subassign (subassign.c:1571)
> > ==4711==    by 0x4F66398: bcEval (eval.c:6795)
> > ==4711==    by 0x4F7D86D: R_compileAndExecute (eval.c:1407)
> > ==4711==    by 0x4F7DA70: do_for (eval.c:2185)
> > ==4711==    by 0x4F7741C: Rf_eval (eval.c:691)
> > ==4711==    by 0x4FA7181: Rf_ReplIteration (main.c:258)
> > ==4711==    by 0x4FA7570: R_ReplConsole (main.c:308)
> > ==4711==    by 0x4FA760E: run_Rmainloop (main.c:1082)
> > ==4711==    by 0x40075A: main (Rmain.c:29)
> > ==4711==  Address 0x19b3ab90 is 0 bytes inside a block of size 160,048
> > free'd
> > ==4711==    at 0x4C2ACBD: free (vg_replace_malloc.c:530)
> > ==4711==    by 0x4FAFCB2: ReleaseLargeFreeVectors (memory.c:1055)
> > ==4711==    by 0x4FAFCB2: RunGenCollect (memory.c:1825)
> > ==4711==    by 0x4FAFCB2: R_gc_internal (memory.c:2998)
> > ==4711==    by 0x4FB166F: Rf_allocVector3 (memory.c:2682)
> > ==4711==    by 0x4FB2310: Rf_allocVector (Rinlinedfuns.h:577)
> > ==4711==    by 0x4FB2310: R_alloc (memory.c:2197)
> > ==4711==    by 0x5023F7A: logicalSubscript (subscript.c:575)
> > ==4711==    by 0x5026DA3: Rf_makeSubscript (subscript.c:994)
> > ==4711==    by 0x501A2F3: VectorAssign (subassign.c:656)
> > ==4711==    by 0x501CDFE: do_subassign_dflt (subassign.c:1641)
> > ==4711==    by 0x5020100: do_subassign (subassign.c:1571)
> > ==4711==    by 0x4F66398: bcEval (eval.c:6795)
> > ==4711==    by 0x4F7D86D: R_compileAndExecute (eval.c:1407)
> > ==4711==    by 0x4F7DA70: do_for (eval.c:2185)
> > ==4711==    by 0x4F7741C: Rf_eval (eval.c:691)
> > ==4711==    by 0x4FA7181: Rf_ReplIteration (main.c:258)
> > ==4711==    by 0x4FA7570: R_ReplConsole (main.c:308)
> > ==4711==    by 0x4FA760E: run_Rmainloop (main.c:1082)
> > ==4711==    by 0x40075A: main (Rmain.c:29)
> > ==4711==  Block was alloc'd at
> > ==4711==    at 0x4C29BC3: malloc (vg_replace_malloc.c:299)
> > ==4711==    by 0x4FB1B04: Rf_allocVector3 (memory.c:2712)
> > ==4711==    by 0x5027574: Rf_allocVector (Rinlinedfuns.h:577)
> > ==4711==    by 0x5027574: Rf_ExtractSubset (subset.c:115)
> > ==4711==    by 0x502ADCD: VectorSubset (subset.c:198)
> > ==4711==    by 0x502ADCD: do_subset_dflt (subset.c:823)
> > ==4711==    by 0x502BE90: do_subset (subset.c:661)
> > ==4711==    by 0x4F7741C: Rf_eval (eval.c:691)
> > ==4711==    by 0x4F7BAC3: Rf_evalListKeepMissing (eval.c:2955)
> > ==4711==    by 0x50200CB: R_DispatchOrEvalSP (subassign.c:1535)
> > ==4711==    by 0x50200CB: do_subassign (subassign.c:1567)
> > ==4711==    by 0x4F66398: bcEval (eval.c:6795)
> > ==4711==    by 0x4F7D86D: R_compileAndExecute (eval.c:1407)
> > ==4711==    by 0x4F7DA70: do_for (eval.c:2185)
> > ==4711==    by 0x4F7741C: Rf_eval (eval.c:691)
> > ==4711==    by 0x4FA7181: Rf_ReplIteration (main.c:258)
> > ==4711==    by 0x4FA7570: R_ReplConsole (main.c:308)
> > ==4711==    by 0x4FA760E: run_Rmainloop (main.c:1082)
> > ==4711==    by 0x40075A: main (Rmain.c:29)
> > ==4711==
> > ==4711== Invalid read of size 1
> > ==4711==    at 0x501A4B4: Rf_xlength (Rinlinedfuns.h:542)
> > ==4711==    by 0x501A4B4: VectorAssign (subassign.c:672)
> > ==4711==    by 0x501CDFE: do_subassign_dflt (subassign.c:1641)
> > ==4711==    by 0x5020100: do_subassign (subassign.c:1571)
> > ==4711==    by 0x4F66398: bcEval (eval.c:6795)
> > ==4711==    by 0x4F7D86D: R_compileAndExecute (eval.c:1407)
> > ==4711==    by 0x4F7DA70: do_for (eval.c:2185)
> > ==4711==    by 0x4F7741C: Rf_eval (eval.c:691)
> > ==4711==    by 0x4FA7181: Rf_ReplIteration (main.c:258)
> > ==4711==    by 0x4FA7570: R_ReplConsole (main.c:308)
> > ==4711==    by 0x4FA760E: run_Rmainloop (main.c:1082)
> > ==4711==    by 0x40075A: main (Rmain.c:29)
> > ==4711==  Address 0x19b3ab90 is 0 bytes inside a block of size 160,048
> > free'd
> > ==4711==    at 0x4C2ACBD: free (vg_replace_malloc.c:530)
> > ==4711==    by 0x4FAFCB2: ReleaseLargeFreeVectors (memory.c:1055)
> > ==4711==    by 0x4FAFCB2: RunGenCollect (memory.c:1825)
> > ==4711==    by 0x4FAFCB2: R_gc_internal (memory.c:2998)
> > ==4711==    by 0x4FB166F: Rf_allocVector3 (memory.c:2682)
> > ==4711==    by 0x4FB2310: Rf_allocVector (Rinlinedfuns.h:577)
> > ==4711==    by 0x4FB2310: R_alloc (memory.c:2197)
> > ==4711==    by 0x5023F7A: logicalSubscript (subscript.c:575)
> > ==4711==    by 0x5026DA3: Rf_makeSubscript (subscript.c:994)
> > ==4711==    by 0x501A2F3: VectorAssign (subassign.c:656)
> > ==4711==    by 0x501CDFE: do_subassign_dflt (subassign.c:1641)
> > ==4711==    by 0x5020100: do_subassign (subassign.c:1571)
> > ==4711==    by 0x4F66398: bcEval (eval.c:6795)
> > ==4711==    by 0x4F7D86D: R_compileAndExecute (eval.c:1407)
> > ==4711==    by 0x4F7DA70: do_for (eval.c:2185)
> > ==4711==    by 0x4F7741C: Rf_eval (eval.c:691)
> > ==4711==    by 0x4FA7181: Rf_ReplIteration (main.c:258)
> > ==4711==    by 0x4FA7570: R_ReplConsole (main.c:308)
> > ==4711==    by 0x4FA760E: run_Rmainloop (main.c:1082)
> > ==4711==    by 0x40075A: main (Rmain.c:29)
> > ==4711==  Block was alloc'd at
> > ==4711==    at 0x4C29BC3: malloc (vg_replace_malloc.c:299)
> > ==4711==    by 0x4FB1B04: Rf_allocVector3 (memory.c:2712)
> > ==4711==    by 0x5027574: Rf_allocVector (Rinlinedfuns.h:577)
> > ==4711==    by 0x5027574: Rf_ExtractSubset (subset.c:115)
> > ==4711==    by 0x502ADCD: VectorSubset (subset.c:198)
> > ==4711==    by 0x502ADCD: do_subset_dflt (subset.c:823)
> > ==4711==    by 0x502BE90: do_subset (subset.c:661)
> > ==4711==    by 0x4F7741C: Rf_eval (eval.c:691)
> > ==4711==    by 0x4F7BAC3: Rf_evalListKeepMissing (eval.c:2955)
> > ==4711==    by 0x50200CB: R_DispatchOrEvalSP (subassign.c:1535)
> > ==4711==    by 0x50200CB: do_subassign (subassign.c:1567)
> > ==4711==    by 0x4F66398: bcEval (eval.c:6795)
> > ==4711==    by 0x4F7D86D: R_compileAndExecute (eval.c:1407)
> > ==4711==    by 0x4F7DA70: do_for (eval.c:2185)
> > ==4711==    by 0x4F7741C: Rf_eval (eval.c:691)
> > ==4711==    by 0x4FA7181: Rf_ReplIteration (main.c:258)
> > ==4711==    by 0x4FA7570: R_ReplConsole (main.c:308)
> > ==4711==    by 0x4FA760E: run_Rmainloop (main.c:1082)
> > ==4711==    by 0x40075A: main (Rmain.c:29)
> > ==4711==
> > ==4711== Invalid read of size 8
> > ==4711==    at 0x501A573: XLENGTH_EX (Rinlinedfuns.h:189)
> > ==4711==    by 0x501A573: Rf_xlength (Rinlinedfuns.h:554)
> > ==4711==    by 0x501A573: VectorAssign (subassign.c:672)
> > ==4711==    by 0x501CDFE: do_subassign_dflt (subassign.c:1641)
> > ==4711==    by 0x5020100: do_subassign (subassign.c:1571)
> > ==4711==    by 0x4F66398: bcEval (eval.c:6795)
> > ==4711==    by 0x4F7D86D: R_compileAndExecute (eval.c:1407)
> > ==4711==    by 0x4F7DA70: do_for (eval.c:2185)
> > ==4711==    by 0x4F7741C: Rf_eval (eval.c:691)
> > ==4711==    by 0x4FA7181: Rf_ReplIteration (main.c:258)
> > ==4711==    by 0x4FA7570: R_ReplConsole (main.c:308)
> > ==4711==    by 0x4FA760E: run_Rmainloop (main.c:1082)
> > ==4711==    by 0x40075A: main (Rmain.c:29)
> > ==4711==  Address 0x19b3abb0 is 32 bytes inside a block of size 160,048
> > free'd
> > ==4711==    at 0x4C2ACBD: free (vg_replace_malloc.c:530)
> > ==4711==    by 0x4FAFCB2: ReleaseLargeFreeVectors (memory.c:1055)
> > ==4711==    by 0x4FAFCB2: RunGenCollect (memory.c:1825)
> > ==4711==    by 0x4FAFCB2: R_gc_internal (memory.c:2998)
> > ==4711==    by 0x4FB166F: Rf_allocVector3 (memory.c:2682)
> > ==4711==    by 0x4FB2310: Rf_allocVector (Rinlinedfuns.h:577)
> > ==4711==    by 0x4FB2310: R_alloc (memory.c:2197)
> > ==4711==    by 0x5023F7A: logicalSubscript (subscript.c:575)
> > ==4711==    by 0x5026DA3: Rf_makeSubscript (subscript.c:994)
> > ==4711==    by 0x501A2F3: VectorAssign (subassign.c:656)
> > ==4711==    by 0x501CDFE: do_subassign_dflt (subassign.c:1641)
> > ==4711==    by 0x5020100: do_subassign (subassign.c:1571)
> > ==4711==    by 0x4F66398: bcEval (eval.c:6795)
> > ==4711==    by 0x4F7D86D: R_compileAndExecute (eval.c:1407)
> > ==4711==    by 0x4F7DA70: do_for (eval.c:2185)
> > ==4711==    by 0x4F7741C: Rf_eval (eval.c:691)
> > ==4711==    by 0x4FA7181: Rf_ReplIteration (main.c:258)
> > ==4711==    by 0x4FA7570: R_ReplConsole (main.c:308)
> > ==4711==    by 0x4FA760E: run_Rmainloop (main.c:1082)
> > ==4711==    by 0x40075A: main (Rmain.c:29)
> > ==4711==  Block was alloc'd at
> > ==4711==    at 0x4C29BC3: malloc (vg_replace_malloc.c:299)
> > ==4711==    by 0x4FB1B04: Rf_allocVector3 (memory.c:2712)
> > ==4711==    by 0x5027574: Rf_allocVector (Rinlinedfuns.h:577)
> > ==4711==    by 0x5027574: Rf_ExtractSubset (subset.c:115)
> > ==4711==    by 0x502ADCD: VectorSubset (subset.c:198)
> > ==4711==    by 0x502ADCD: do_subset_dflt (subset.c:823)
> > ==4711==    by 0x502BE90: do_subset (subset.c:661)
> > ==4711==    by 0x4F7741C: Rf_eval (eval.c:691)
> > ==4711==    by 0x4F7BAC3: Rf_evalListKeepMissing (eval.c:2955)
> > ==4711==    by 0x50200CB: R_DispatchOrEvalSP (subassign.c:1535)
> > ==4711==    by 0x50200CB: do_subassign (subassign.c:1567)
> > ==4711==    by 0x4F66398: bcEval (eval.c:6795)
> > ==4711==    by 0x4F7D86D: R_compileAndExecute (eval.c:1407)
> > ==4711==    by 0x4F7DA70: do_for (eval.c:2185)
> > ==4711==    by 0x4F7741C: Rf_eval (eval.c:691)
> > ==4711==    by 0x4FA7181: Rf_ReplIteration (main.c:258)
> > ==4711==    by 0x4FA7570: R_ReplConsole (main.c:308)
> > ==4711==    by 0x4FA760E: run_Rmainloop (main.c:1082)
> > ==4711==    by 0x40075A: main (Rmain.c:29)
> > ==4711==
> > ==4711== Invalid read of size 1
> > ==4711==    at 0x501C582: INTEGER_ELT (Rinlinedfuns.h:381)
> > ==4711==    by 0x501C582: VectorAssign (subassign.c:710)
> > ==4711==    by 0x501CDFE: do_subassign_dflt (subassign.c:1641)
> > ==4711==    by 0x5020100: do_subassign (subassign.c:1571)
> > ==4711==    by 0x4F66398: bcEval (eval.c:6795)
> > ==4711==    by 0x4F7D86D: R_compileAndExecute (eval.c:1407)
> > ==4711==    by 0x4F7DA70: do_for (eval.c:2185)
> > ==4711==    by 0x4F7741C: Rf_eval (eval.c:691)
> > ==4711==    by 0x4FA7181: Rf_ReplIteration (main.c:258)
> > ==4711==    by 0x4FA7570: R_ReplConsole (main.c:308)
> > ==4711==    by 0x4FA760E: run_Rmainloop (main.c:1082)
> > ==4711==    by 0x40075A: main (Rmain.c:29)
> > ==4711==  Address 0x19b3ab90 is 0 bytes inside a block of size 160,048
> > free'd
> > ==4711==    at 0x4C2ACBD: free (vg_replace_malloc.c:530)
> > ==4711==    by 0x4FAFCB2: ReleaseLargeFreeVectors (memory.c:1055)
> > ==4711==    by 0x4FAFCB2: RunGenCollect (memory.c:1825)
> > ==4711==    by 0x4FAFCB2: R_gc_internal (memory.c:2998)
> > ==4711==    by 0x4FB166F: Rf_allocVector3 (memory.c:2682)
> > ==4711==    by 0x4FB2310: Rf_allocVector (Rinlinedfuns.h:577)
> > ==4711==    by 0x4FB2310: R_alloc (memory.c:2197)
> > ==4711==    by 0x5023F7A: logicalSubscript (subscript.c:575)
> > ==4711==    by 0x5026DA3: Rf_makeSubscript (subscript.c:994)
> > ==4711==    by 0x501A2F3: VectorAssign (subassign.c:656)
> > ==4711==    by 0x501CDFE: do_subassign_dflt (subassign.c:1641)
> > ==4711==    by 0x5020100: do_subassign (subassign.c:1571)
> > ==4711==    by 0x4F66398: bcEval (eval.c:6795)
> > ==4711==    by 0x4F7D86D: R_compileAndExecute (eval.c:1407)
> > ==4711==    by 0x4F7DA70: do_for (eval.c:2185)
> > ==4711==    by 0x4F7741C: Rf_eval (eval.c:691)
> > ==4711==    by 0x4FA7181: Rf_ReplIteration (main.c:258)
> > ==4711==    by 0x4FA7570: R_ReplConsole (main.c:308)
> > ==4711==    by 0x4FA760E: run_Rmainloop (main.c:1082)
> > ==4711==    by 0x40075A: main (Rmain.c:29)
> > ==4711==  Block was alloc'd at
> > ==4711==    at 0x4C29BC3: malloc (vg_replace_malloc.c:299)
> > ==4711==    by 0x4FB1B04: Rf_allocVector3 (memory.c:2712)
> > ==4711==    by 0x5027574: Rf_allocVector (Rinlinedfuns.h:577)
> > ==4711==    by 0x5027574: Rf_ExtractSubset (subset.c:115)
> > ==4711==    by 0x502ADCD: VectorSubset (subset.c:198)
> > ==4711==    by 0x502ADCD: do_subset_dflt (subset.c:823)
> > ==4711==    by 0x502BE90: do_subset (subset.c:661)
> > ==4711==    by 0x4F7741C: Rf_eval (eval.c:691)
> > ==4711==    by 0x4F7BAC3: Rf_evalListKeepMissing (eval.c:2955)
> > ==4711==    by 0x50200CB: R_DispatchOrEvalSP (subassign.c:1535)
> > ==4711==    by 0x50200CB: do_subassign (subassign.c:1567)
> > ==4711==    by 0x4F66398: bcEval (eval.c:6795)
> > ==4711==    by 0x4F7D86D: R_compileAndExecute (eval.c:1407)
> > ==4711==    by 0x4F7DA70: do_for (eval.c:2185)
> > ==4711==    by 0x4F7741C: Rf_eval (eval.c:691)
> > ==4711==    by 0x4FA7181: Rf_ReplIteration (main.c:258)
> > ==4711==    by 0x4FA7570: R_ReplConsole (main.c:308)
> > ==4711==    by 0x4FA760E: run_Rmainloop (main.c:1082)
> > ==4711==    by 0x40075A: main (Rmain.c:29)
> > ==4711==
> > ==4711== Invalid read of size 4
> > ==4711==    at 0x501C587: INTEGER_ELT (Rinlinedfuns.h:381)
> > ==4711==    by 0x501C587: VectorAssign (subassign.c:710)
> > ==4711==    by 0x501CDFE: do_subassign_dflt (subassign.c:1641)
> > ==4711==    by 0x5020100: do_subassign (subassign.c:1571)
> > ==4711==    by 0x4F66398: bcEval (eval.c:6795)
> > ==4711==    by 0x4F7D86D: R_compileAndExecute (eval.c:1407)
> > ==4711==    by 0x4F7DA70: do_for (eval.c:2185)
> > ==4711==    by 0x4F7741C: Rf_eval (eval.c:691)
> > ==4711==    by 0x4FA7181: Rf_ReplIteration (main.c:258)
> > ==4711==    by 0x4FA7570: R_ReplConsole (main.c:308)
> > ==4711==    by 0x4FA760E: run_Rmainloop (main.c:1082)
> > ==4711==    by 0x40075A: main (Rmain.c:29)
> > ==4711==  Address 0x19b3abc0 is 48 bytes inside a block of size 160,048
> > free'd
> > ==4711==    at 0x4C2ACBD: free (vg_replace_malloc.c:530)
> > ==4711==    by 0x4FAFCB2: ReleaseLargeFreeVectors (memory.c:1055)
> > ==4711==    by 0x4FAFCB2: RunGenCollect (memory.c:1825)
> > ==4711==    by 0x4FAFCB2: R_gc_internal (memory.c:2998)
> > ==4711==    by 0x4FB166F: Rf_allocVector3 (memory.c:2682)
> > ==4711==    by 0x4FB2310: Rf_allocVector (Rinlinedfuns.h:577)
> > ==4711==    by 0x4FB2310: R_alloc (memory.c:2197)
> > ==4711==    by 0x5023F7A: logicalSubscript (subscript.c:575)
> > ==4711==    by 0x5026DA3: Rf_makeSubscript (subscript.c:994)
> > ==4711==    by 0x501A2F3: VectorAssign (subassign.c:656)
> > ==4711==    by 0x501CDFE: do_subassign_dflt (subassign.c:1641)
> > ==4711==    by 0x5020100: do_subassign (subassign.c:1571)
> > ==4711==    by 0x4F66398: bcEval (eval.c:6795)
> > ==4711==    by 0x4F7D86D: R_compileAndExecute (eval.c:1407)
> > ==4711==    by 0x4F7DA70: do_for (eval.c:2185)
> > ==4711==    by 0x4F7741C: Rf_eval (eval.c:691)
> > ==4711==    by 0x4FA7181: Rf_ReplIteration (main.c:258)
> > ==4711==    by 0x4FA7570: R_ReplConsole (main.c:308)
> > ==4711==    by 0x4FA760E: run_Rmainloop (main.c:1082)
> > ==4711==    by 0x40075A: main (Rmain.c:29)
> > ==4711==  Block was alloc'd at
> > ==4711==    at 0x4C29BC3: malloc (vg_replace_malloc.c:299)
> > ==4711==    by 0x4FB1B04: Rf_allocVector3 (memory.c:2712)
> > ==4711==    by 0x5027574: Rf_allocVector (Rinlinedfuns.h:577)
> > ==4711==    by 0x5027574: Rf_ExtractSubset (subset.c:115)
> > ==4711==    by 0x502ADCD: VectorSubset (subset.c:198)
> > ==4711==    by 0x502ADCD: do_subset_dflt (subset.c:823)
> > ==4711==    by 0x502BE90: do_subset (subset.c:661)
> > ==4711==    by 0x4F7741C: Rf_eval (eval.c:691)
> > ==4711==    by 0x4F7BAC3: Rf_evalListKeepMissing (eval.c:2955)
> > ==4711==    by 0x50200CB: R_DispatchOrEvalSP (subassign.c:1535)
> > ==4711==    by 0x50200CB: do_subassign (subassign.c:1567)
> > ==4711==    by 0x4F66398: bcEval (eval.c:6795)
> > ==4711==    by 0x4F7D86D: R_compileAndExecute (eval.c:1407)
> > ==4711==    by 0x4F7DA70: do_for (eval.c:2185)
> > ==4711==    by 0x4F7741C: Rf_eval (eval.c:691)
> > ==4711==    by 0x4FA7181: Rf_ReplIteration (main.c:258)
> > ==4711==    by 0x4FA7570: R_ReplConsole (main.c:308)
> > ==4711==    by 0x4FA760E: run_Rmainloop (main.c:1082)
> > ==4711==    by 0x40075A: main (Rmain.c:29)
> > ==4711==
> > 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
> > ...
> >
> > Bill Dunlap
> > TIBCO Software
> > wdunlap tibco.com
> >
> >
> > On Wed, Feb 27, 2019 at 12:31 AM Gabriel Becker <gabembecker at gmail.com>
> > wrote:
> >
> > > Hi Brian,
> > >
> > > I don't have a windows machine, but on a modern macbook pro I'm not able to
> > > get this to crash in 3.5.1 or a very recent built-from-source R-devel.  I
> > > increased the length of x by 2 orders of magnitude but that just made the
> > > loop take a lot longer to successfully run in both R versions i tested.
> > >
> > > So seems like there is some OS/machine dependency at work here (?).
> > >
> > > Best,
> > > ~G
> > >
> > > On Wed, Feb 27, 2019 at 12:01 AM Brian Montgomery via R-devel <
> > > r-devel at r-project.org> wrote:
> > >
> > > > The following code crashes after about 300 iterations on
> > > > my x86_64-w64-mingw32 machine on R 3.5.2 --vanilla.
> > > > Others have duplicated this (see
> > > > https://github.com/tidyverse/magrittr/issues/190 if necessary), but I
> > > > don't know how machine/OS-dependent it may be.
> > > > If it doesn't crash for you, please try increasing the length of the x
> > > > vector.
> > > >
> > > > Substituting the commented-out line for the one below it works correctly
> > > > (prints out 1:1000 and ends normally) every time.
> > > >
> > > > x <- 1:200000
> > > > y <- rep(letters[1:5], length(x) / 5L)
> > > > for (i in 1:1000) {
> > > >   # x[y == 'a'] <- x[y == 'b']
> > > >   x <- `[<-`(x, y == 'a', x[y == 'b'])
> > > >   cat(i, '')
> > > > }
> > > > cat('\n')
> > > >
> > > > The point of using this syntax is to make it work better with pipes, but
> > > > the errors occur without pipes or magrittr.
> > > >
> > > > Thank you for your help!
> > > >
> > > > ______________________________________________
> > > > R-devel at r-project.org mailing list
> > > > https://stat.ethz.ch/mailman/listinfo/r-devel
> > > >
> > >
> > >         [[alternative HTML version deleted]]
> > >
> > > ______________________________________________
> > > R-devel at r-project.org mailing list
> > > https://stat.ethz.ch/mailman/listinfo/r-devel
> > >
> >
> >         [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-devel at r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-devel



[Rd] Intermittent crashes with inset `[<-` command
Travers Ching