phillipstanleymarbell / Noisy-lang-compiler

Noisy language compiler
MIT License
17 stars 1 forks source link

Invariants file causing `Segmentation fault: 11` bad access when calling `irPass-dimensionalMatrixConvertToList` #382

Open Siegfriedchao opened 6 years ago

Siegfriedchao commented 6 years ago

There currently is a bug when running some .nt files with more than one invariants, which causes Segmentation fault when accessing N->invariantList->reorderedNullSpace.

Additionally, the same seg-fault error could also be found when accessing certain .nt files with the number of kernels being as many as 1000+ (e.g. SelectiveLaserMelting.nt).

This issue has been reported in Pull Request #378. The bug should ideally be fixed after issue #372 is complete to avoid comflicts due to the potential reordering of nullspace in issue #372.

Siegfriedchao commented 5 years ago

Describe the bug Invalid access, Segmentation fault: 11 when running the following .nt, the original nullspace kernel count is 1365 and the weeded out kernel count is 1360:

include "NewtonBaseSignals.nt"

oxygenLevel : signal =
{
    name        = "% oxygen level" English;
    symbol      = percentage;
    derivation  = dimensionless;
}

beamQuality : signal =
{
    name        = "beam quality" English;
    symbol      = Msquared;
    derivation  = dimensionless;
}

dynamicViscosity : signal =
{
    name        = "dynamic viscosity" English;
    symbol      = mu;
    derivation  = mass / (distance * time);
}

surfaceTension : signal =
{
    name        = "surface tension" English;
    symbol      = theta;
    derivation  = force / distance;
}

thermalDiffusivity : signal =
{
    name        = "diffusivity" English;
    symbol      = kappa;
    derivation  = distance ** 2 / time;
}

latentHeatOfFusion : signal =
{
    name        = "latent heat of fusion" English;
    symbol      = Lf;
    derivation  = work / mass;
}

selectiveLaserMelting : invariant(  ox_Level: oxygenLevel,
                    beam_Q: beamQuality,
                    dyn_Vis: dynamicViscosity,
                    surf_tension: surfaceTension,
                    enthalpy: work,
                    laser_P: power,
                    spot_size: distance,
                    scan_spa: distance,
                    scan_V: speed,
                    layer_thick: distance,
                    thermal_diff: thermalDiffusivity,
                    bulk_density: density,
                    heat_fusion: latentHeatOfFusion,
                    delta_T: temperature,
                    powder_density: density) =
{
}

To Reproduce Execute ./newton-darwin-EN -v 2 -p ../../applications/newton/invariants/SelectiveLaserMelting.nt

* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x50)
    frame #0: 0x000000010000fd39 newton-darwin-EN`irPassGenLoopsInRightExpression(N=0x0000000100408490, newNodeQTerm=0x0000000107a46de0, genSrcInfo=0x00000001079fc040, row=0x0000000105a3a000, col=0x0000000105a3cc00, rowIndependent=0x0000000105a3f800, colIndependent=0x0000000105a42400, kernel=0, whichParameter=0, whichIndependentParameter=16) at newton-irPass-dimensionalMatrixConvertToList.c:161
   158                  NULL,
   159                  NULL,
   160                  genSrcInfo);
-> 161      newNodeExponentConst->value = 0 - N->invariantList->nullSpaceCanonicallyReordered[kernel]
   162                                      [colIndependent[kernel][whichParameter][whichIndependentParameter]]
   163                                      [rowIndependent[kernel][whichParameter][whichIndependentParameter]];
   164      Token *     tokenExponentConst = (Token *) calloc(1, sizeof(Token));
Target 3: (newton-darwin-EN) stopped.
Siegfriedchao commented 5 years ago

This issue is fixed in #388 bundle update.

phillipstanleymarbell commented 5 years ago

The comment above says this is fixed in #388. Moving to verify.