Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct a Java SWIG type mapping that produces SEGV crashes #1838

Merged
merged 1 commit into from
Jan 13, 2020

Conversation

ateirney
Copy link
Contributor

Whilst attempting to use dimension breaks via Java SWIG bindings I encountered SEGV crashes.

Below is a very simple code example that exhibits the SEGV crashes.

package tmp;

import com.google.ortools.constraintsolver.IntervalVar;
import com.google.ortools.constraintsolver.RoutingDimension;
import com.google.ortools.constraintsolver.RoutingIndexManager;
import com.google.ortools.constraintsolver.RoutingModel;

public class Tmp {
    static {
        System.loadLibrary("jniortools");
    }

    public static void main(String[] args) {
        RoutingIndexManager manager = new RoutingIndexManager(2, 1, new int[]{0}, new int[]{1});
        RoutingModel model = new RoutingModel(manager);
        model.addConstantDimension(0, 0, false, "tmp");
        RoutingDimension dimension = model.getMutableDimension("tmp");
        // The line below causes the SEGV
        dimension.setBreakIntervalsOfVehicle(new IntervalVar[]{}, 0, -1, -1);
    }
}

This changeset aims to correct the java swig in type maps for std::vector<CType*>

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@ateirney
Copy link
Contributor Author

@googlebot I signed it!

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@Mizux Mizux added Bug Lang: Java Java wrapper issue labels Jan 13, 2020
@Mizux Mizux added this to the v7.5 milestone Jan 13, 2020
@Mizux Mizux self-assigned this Jan 13, 2020
@Mizux
Copy link
Collaborator

Mizux commented Jan 13, 2020

Good Catch many thanks for the patch !

Tested and confirmed the patch is working (basically it's the same code than std::vector<CType *>& line 118 just above...)

note: I also check for other remaining 'JavaPackage' in the ortools/gen/ortools/constraint_solver/constraint_solver_java_wrap.cc

@Mizux Mizux merged commit 747ea98 into google:master Jan 13, 2020
@ateirney ateirney deleted the fix/java-swig-segv branch January 13, 2020 19:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Lang: Java Java wrapper issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants